In CodeGen/DwarfWriter.cpp's EmitDebugLine file, these lines are causing havoc on Mac OS X systems: // If there are no lines to emit (such as when we're using .loc directives // to emit .debug_line information) don't emit a .debug_line header. if (SectionSourceLines.empty()) return; Basically, if there's a file with only data in it, we still need the debug_line prologue generated. $ cat a.c const char ver[] __attribute__((used)) = "Hello world\n"; $ gcc -g -O0 -c a.c -o a.gcc.o $ dwarfdump --debug-line=0 a.gcc.o ---------------------------------------------------------------------- File: a.gcc.o (architecture i386) ---------------------------------------------------------------------- .debug_line contents: ---------------------------------------------------------------------- debug_line[0x00000000] ---------------------------------------------------------------------- Line table prologue: total_length: 0x00000027 version: 0x0002 prologue_length: 0x00000017 min_inst_length: 0x01 default_is_stmt: 0x01 line_base: -10 line_range: 245 opcode_base: 0x0a standard_opcode_lengths[ DW_LNS_copy ] = 0 standard_opcode_lengths[ DW_LNS_advance_pc ] = 1 standard_opcode_lengths[ DW_LNS_advance_line ] = 1 standard_opcode_lengths[ DW_LNS_set_file ] = 1 standard_opcode_lengths[ DW_LNS_set_column ] = 1 standard_opcode_lengths[ DW_LNS_negate_stmt ] = 0 standard_opcode_lengths[ DW_LNS_set_basic_block ] = 0 standard_opcode_lengths[ DW_LNS_const_add_pc ] = 0 standard_opcode_lengths[ DW_LNS_fixed_advance_pc ] = 1 Dir Mod Time File Len File Name ---- ---------- ---------- --------------------------- file_names[ 1] 0 0x00000000 0x00000000 a.c 0x00000021: DW_LNE_set_address( 0x00000000 ) 0x00000028: DW_LNE_end_sequence 0x0000000000000000 1 1 0 By removing the "early exit" from EmitDebugLine, I got LLVM to generate this data. However, Dan pointed out that assemblers that use the ".loc" directive can't have their debug_line generated by the compiler. My suggestion was to have a flag that indicated that ".loc" was used. If it was, then we would exit out of the EmitDebugLine method early. Something like so: // If there are no lines to emit (such as when we're using .loc directives // to emit .debug_line information) don't emit a .debug_line header. if (LocDirectiveUsed()) return; Dan wasn't sure if this would work in all cases. We don't have a Linux box to test this on. Does this sound like a good idea? Those who work with Linux or other OSes, would this idea break things for you? -bw
On Jul 17, 2008, at 3:33 PM, Bill Wendling wrote:> In CodeGen/DwarfWriter.cpp's EmitDebugLine file, these lines are > causing havoc on Mac OS X systems: > > // If there are no lines to emit (such as when we're using .loc > directives > // to emit .debug_line information) don't emit a .debug_line > header. > if (SectionSourceLines.empty()) > return;The fix is to move the early exist to just below this line: EmitLabel("line_prolog_end", 0), right?> > > Basically, if there's a file with only data in it, we still need the > debug_line prologue generated.Right.> > By removing the "early exit" from EmitDebugLine, I got LLVM to > generate this data. However, Dan pointed out that assemblers that use > the ".loc" directive can't have their debug_line generated by the > compiler. My suggestion was to have a flag that indicated that ".loc"I am not sure I understand this statement? Evan> > was used. If it was, then we would exit out of the EmitDebugLine > method early. Something like so: > > > // If there are no lines to emit (such as when we're using .loc > directives > // to emit .debug_line information) don't emit a .debug_line > header. > if (LocDirectiveUsed()) > return; > > Dan wasn't sure if this would work in all cases. We don't have a Linux > box to test this on. Does this sound like a good idea? Those who work > with Linux or other OSes, would this idea break things for you? > > -bw > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Jul 17, 2008, at 3:33 PM, Bill Wendling wrote:> In CodeGen/DwarfWriter.cpp's EmitDebugLine file, these lines are > causing havoc on Mac OS X systems: > > // If there are no lines to emit (such as when we're using .loc > directives > // to emit .debug_line information) don't emit a .debug_line > header. > if (SectionSourceLines.empty()) > return; > > Basically, if there's a file with only data in it, we still need the > debug_line prologue generated. > > $ cat a.c > const char ver[] __attribute__((used)) = "Hello world\n"; > $ gcc -g -O0 -c a.c -o a.gcc.o > $ dwarfdump --debug-line=0 a.gcc.o > ---------------------------------------------------------------------- > File: a.gcc.o (architecture i386) > ---------------------------------------------------------------------- > > .debug_line contents: > ---------------------------------------------------------------------- > debug_line[0x00000000] > ---------------------------------------------------------------------- > Line table prologue: > total_length: 0x00000027 > version: 0x0002 > prologue_length: 0x00000017 > min_inst_length: 0x01 > default_is_stmt: 0x01 > line_base: -10 > line_range: 245 > opcode_base: 0x0a > standard_opcode_lengths[ DW_LNS_copy ] = 0 > standard_opcode_lengths[ DW_LNS_advance_pc ] = 1 > standard_opcode_lengths[ DW_LNS_advance_line ] = 1 > standard_opcode_lengths[ DW_LNS_set_file ] = 1 > standard_opcode_lengths[ DW_LNS_set_column ] = 1 > standard_opcode_lengths[ DW_LNS_negate_stmt ] = 0 > standard_opcode_lengths[ DW_LNS_set_basic_block ] = 0 > standard_opcode_lengths[ DW_LNS_const_add_pc ] = 0 > standard_opcode_lengths[ DW_LNS_fixed_advance_pc ] = 1 > Dir Mod Time File Len File Name > ---- ---------- ---------- --------------------------- > file_names[ 1] 0 0x00000000 0x00000000 a.c > 0x00000021: DW_LNE_set_address( 0x00000000 ) > 0x00000028: DW_LNE_end_sequence > 0x0000000000000000 1 1 0 > > By removing the "early exit" from EmitDebugLine, I got LLVM to > generate this data. However, Dan pointed out that assemblers that use > the ".loc" directive can't have their debug_line generated by the > compiler. My suggestion was to have a flag that indicated that ".loc" > was used. If it was, then we would exit out of the EmitDebugLine > method early. Something like so: > > // If there are no lines to emit (such as when we're using .loc > directives > // to emit .debug_line information) don't emit a .debug_line > header. > if (LocDirectiveUsed()) > return; > > Dan wasn't sure if this would work in all cases. We don't have a Linux > box to test this on. Does this sound like a good idea? Those who work > with Linux or other OSes, would this idea break things for you?I've now tested how GCC does this on Ubuntu, at least. It uses .loc and does not emit a separate .debug_line prologue. It apparently assumes that the .file numbers will directly correspond with file indicies in the debug line section, suitable for use with DW_AT_decl_file. So I think the way to fix this is to make it dependent on whether the target uses .loc or not. Something like this: // If the target is using .loc/.file, the assembler will be emitting // the .debug_line table automatically. if (TAI->hasDotLocAndDotFile()) return; Dan
On Jul 18, 2008, at 10:45 AM, Evan Cheng wrote:> On Jul 17, 2008, at 3:33 PM, Bill Wendling wrote: > >> In CodeGen/DwarfWriter.cpp's EmitDebugLine file, these lines are >> causing havoc on Mac OS X systems: >> >> // If there are no lines to emit (such as when we're using .loc >> directives >> // to emit .debug_line information) don't emit a .debug_line >> header. >> if (SectionSourceLines.empty()) >> return; > > The fix is to move the early exist to just below this line: > EmitLabel("line_prolog_end", 0), right? >No. We still need the emission of some of the labels after this. So it would get rid of the if-statement altogether. However, Dan came up with a better solution. :-)>> By removing the "early exit" from EmitDebugLine, I got LLVM to >> generate this data. However, Dan pointed out that assemblers that use >> the ".loc" directive can't have their debug_line generated by the >> compiler. My suggestion was to have a flag that indicated that ".loc" > > I am not sure I understand this statement? >Now that I read it, neither can I. :-) I was trying to say that the .loc and .file directives are there to indicate that the assembler should generate the debug_line section -- with line tables, etc. So the compiler shouldn't be outputting those sections. -bw
Reasonably Related Threads
- [LLVMdev] RFC: debug_line Emission
- [LLVMdev] [lldb-dev] How is variable info retrieved in debugging for executables generated by llvm backend?
- [LLVMdev] [lldb-dev] How is variable info retrieved in debugging for executables generated by llvm backend?
- [LLVMdev] How is variable info retrieved in debugging for executables generated by llvm backend?
- [LLVMdev] DebugInfo library and relocations in the .debug_line section