File tree 3 files changed +28
-1
lines changed 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -414,6 +414,7 @@ extern const char* Dylink;
414
414
extern const char * Dylink0;
415
415
extern const char * Linking;
416
416
extern const char * Producers;
417
+ extern const char * BuildId;
417
418
extern const char * TargetFeatures;
418
419
419
420
extern const char * AtomicsFeature;
Original file line number Diff line number Diff line change 16
16
17
17
#include < algorithm>
18
18
#include < fstream>
19
+ #include < iomanip>
19
20
20
21
#include " ir/eh-utils.h"
21
22
#include " ir/module-utils.h"
@@ -1211,7 +1212,31 @@ void WasmBinaryWriter::initializeDebugInfo() {
1211
1212
}
1212
1213
1213
1214
void WasmBinaryWriter::writeSourceMapProlog () {
1214
- *sourceMap << " {\" version\" :3,\" sources\" :[" ;
1215
+ *sourceMap << " {\" version\" :3," ;
1216
+
1217
+ for (const auto & section : wasm->customSections ) {
1218
+ if (section.name == BinaryConsts::CustomSections::BuildId) {
1219
+ U32LEB ret;
1220
+ size_t pos = 0 ;
1221
+ ret.read ([&]() { return section.data [pos++]; });
1222
+
1223
+ if (section.data .size () != pos + ret.value ) {
1224
+ std::cerr
1225
+ << " warning: build id section with an incorrect size detected!\n " ;
1226
+ break ;
1227
+ }
1228
+
1229
+ *sourceMap << " \" debugId\" :\" " ;
1230
+ for (size_t i = pos; i < section.data .size (); i++) {
1231
+ *sourceMap << std::setfill (' 0' ) << std::setw (2 ) << std::hex
1232
+ << +section.data [i];
1233
+ }
1234
+ *sourceMap << " \" ," ;
1235
+ break ;
1236
+ }
1237
+ }
1238
+
1239
+ *sourceMap << " \" sources\" :[" ;
1215
1240
for (size_t i = 0 ; i < wasm->debugInfoFileNames .size (); i++) {
1216
1241
if (i > 0 ) {
1217
1242
*sourceMap << " ," ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const char* Dylink = "dylink";
36
36
const char * Dylink0 = " dylink.0" ;
37
37
const char * Linking = " linking" ;
38
38
const char * Producers = " producers" ;
39
+ const char * BuildId = " build_id" ;
39
40
const char * TargetFeatures = " target_features" ;
40
41
const char * AtomicsFeature = " atomics" ;
41
42
const char * BulkMemoryFeature = " bulk-memory" ;
You can’t perform that action at this time.
0 commit comments