@@ -193,24 +193,39 @@ class DebugLineSectionEmitter {
193
193
Section.emitString (Include.getForm (), *IncludeStr);
194
194
}
195
195
196
+ bool HasChecksums = P.ContentTypes .HasMD5 ;
197
+ bool HasInlineSources = P.ContentTypes .HasSource ;
198
+
199
+ dwarf::Form FileNameForm = dwarf::DW_FORM_string;
200
+ dwarf::Form LLVMSourceForm = dwarf::DW_FORM_string;
201
+
196
202
if (P.FileNames .empty ()) {
197
203
// file_name_entry_format_count (ubyte).
198
204
Section.emitIntVal (0 , 1 );
199
205
} else {
206
+ FileNameForm = P.FileNames [0 ].Name .getForm ();
207
+ LLVMSourceForm = P.FileNames [0 ].Source .getForm ();
208
+
200
209
// file_name_entry_format_count (ubyte).
201
- Section.emitIntVal (2 + (P.ContentTypes .HasMD5 ? 1 : 0 ), 1 );
210
+ Section.emitIntVal (
211
+ 2 + (HasChecksums ? 1 : 0 ) + (HasInlineSources ? 1 : 0 ), 1 );
202
212
203
213
// file_name_entry_format (sequence of ULEB128 pairs).
204
214
encodeULEB128 (dwarf::DW_LNCT_path, Section.OS );
205
- encodeULEB128 (P. FileNames [ 0 ]. Name . getForm () , Section.OS );
215
+ encodeULEB128 (FileNameForm , Section.OS );
206
216
207
217
encodeULEB128 (dwarf::DW_LNCT_directory_index, Section.OS );
208
218
encodeULEB128 (dwarf::DW_FORM_data1, Section.OS );
209
219
210
- if (P. ContentTypes . HasMD5 ) {
220
+ if (HasChecksums ) {
211
221
encodeULEB128 (dwarf::DW_LNCT_MD5, Section.OS );
212
222
encodeULEB128 (dwarf::DW_FORM_data16, Section.OS );
213
223
}
224
+
225
+ if (HasInlineSources) {
226
+ encodeULEB128 (dwarf::DW_LNCT_LLVM_source, Section.OS );
227
+ encodeULEB128 (LLVMSourceForm, Section.OS );
228
+ }
214
229
}
215
230
216
231
// file_names_count (ULEB128).
@@ -226,14 +241,27 @@ class DebugLineSectionEmitter {
226
241
227
242
// A null-terminated string containing the full or relative path name of a
228
243
// source file.
229
- Section.emitString (File. Name . getForm () , *FileNameStr);
244
+ Section.emitString (FileNameForm , *FileNameStr);
230
245
Section.emitIntVal (File.DirIdx , 1 );
231
246
232
- if (P.ContentTypes .HasMD5 ) {
247
+ if (HasChecksums) {
248
+ assert ((File.Checksum .size () == 16 ) &&
249
+ " checksum size is not equal to 16 bytes." );
233
250
Section.emitBinaryData (
234
251
StringRef (reinterpret_cast <const char *>(File.Checksum .data ()),
235
252
File.Checksum .size ()));
236
253
}
254
+
255
+ if (HasInlineSources) {
256
+ std::optional<const char *> FileSourceStr =
257
+ dwarf::toString (File.Source );
258
+ if (!FileSourceStr) {
259
+ U.warn (" cann't read string from line table." );
260
+ return ;
261
+ }
262
+
263
+ Section.emitString (LLVMSourceForm, *FileSourceStr);
264
+ }
237
265
}
238
266
}
239
267
0 commit comments