Mario de Sousa
2012-Dec-28 17:33 UTC
[LLVMdev] Newbie question(?): How to correctly create debug info, when generating IR
Hello all,
Summary & Context:
-------------------------------
I am starting to write a front-end for some domain specific programming
languages. Code generation seems to be working fine.
However, I am having trouble generating debug info, to be used by gdb.
The problem:
--------------------
I generate a foo.ll file, that is later compiled into an executable foo.
The foo.ll file I generate already contains metadata for datatypes, compile
unit, subprograms, etc...
When debuging foo with ddd, I get the message that the file
<root_path>/sysdeps/i386/elf/start.S
does not exist. In other words, the debugger does not seem to know about the
existence of foo.xx, the original source file.
I have compiled a small helloworld.c program, and compared the debug info in
helloworld and foo, using 'readelf --debug-dump'.
I have noticed that in helloworld, the .debug_aranges section has 2 address
ranges,
- one pointing to a DW_TAG_compile_unit referencing the
/sysdeps/i386/elf/start.S file
- the other pointing to a DW_TAG_compile_unit with the helloworld,c file.
However, in the foo program, the .debug_aranges section has only 1 address
range, pointing to a DW_TAG_compile_unit referencing the
/sysdeps/i386/elf/start.S file.
The second DW_TAG_compile_unit referencing the foo.xx file is present in the
.debug_info section, but is not being referenced!
Strangely, some information that seems to be an address range referencing the
foo.xx DW_TAG_compile_unit, is present in the .debug_pubtypes section. Why is
this in the wrong section??
The question:
========
Does anybody have any idea what it is I am doing wrong?
The issue seems to be related to generating the info for a CompileUnit.
Currently, I am doing this:
dibuilder = new DIBuilder(themodule);
dibuilder->createCompileUnit(Lang,
StringRef("foo.xx")), /*finename*/
StringRef(".") /*Dir*/,
StringRef("XXX") /*Producer*/,
false /*isOptimized*/,
StringRef("") /*Flags*/,
0 /*RV: Runtime Version?*/);
DIFile file = dibuilder->createFile(StringRef("foo.x"),
StringRef("."));
DICompileUnit compile_unit = DICompileUnit(file);
dibuilder->createFunction(compile_unit /*Scope*/,
StringRef(function_name), StringRef(function_name),
file,
42 /* line number*/,
di_func_type,
false /*isLocalToUnit*/, true /*isDefinition*/,
42 /*ScopeLine*/
);
...
...
dibuilder->finalize();
module->dump();
To me, it seems wrong to create two compile units, one with
dibuilder->createCompileUnit()
and the other directly
DICompileUnit compile_unit = DICompileUnit(file);
However, I could not figure out how to get a handle to the compile unit
generated by dibuilder->createCompileUnit(), in order to pass it to
dibuilder->createFunction().
I can provide a lot more detail, but I do not want to bore you with this.
If there is any info you need in order to help me out, please just ask, and I
will do my best to provide it.
Cheers,
Mario.
Sid Manning
2012-Dec-28 20:19 UTC
[LLVMdev] Newbie question(?): How to correctly create debug info, when generating IR
On 12/28/12 11:33, Mario de Sousa wrote:> > > Hello all, > > > Summary& Context: > ------------------------------- > I am starting to write a front-end for some domain specific programming > languages. Code generation seems to be working fine. > > However, I am having trouble generating debug info, to be used by gdb. >I've has some issues with debug info and it was pointed out to me that llvm can emit dwarf4 bits that gdb may not like, this may not help but I needed to pass: -mllvm -use-dwarf3-form-flags to get output gdb would accept. ...> > Cheers, > > Mario. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Eric Christopher
2012-Dec-28 20:37 UTC
[LLVMdev] Newbie question(?): How to correctly create debug info, when generating IR
Easiest way is to look at how clang generates debug info. See clang/lib/CodeGen/CGDebugInfo.cpp. -eric On Fri, Dec 28, 2012 at 9:33 AM, Mario de Sousa <msousa at fe.up.pt> wrote:> > > Hello all, > > > Summary & Context: > ------------------------------- > I am starting to write a front-end for some domain specific programming > languages. Code generation seems to be working fine. > > However, I am having trouble generating debug info, to be used by gdb. > > > The problem: > -------------------- > I generate a foo.ll file, that is later compiled into an executable foo. > > The foo.ll file I generate already contains metadata for datatypes, > compile > unit, subprograms, etc... > > When debuging foo with ddd, I get the message that the file > <root_path>/sysdeps/i386/elf/start.S > does not exist. In other words, the debugger does not seem to know about > the > existence of foo.xx, the original source file. > > I have compiled a small helloworld.c program, and compared the debug info > in > helloworld and foo, using 'readelf --debug-dump'. > > I have noticed that in helloworld, the .debug_aranges section has 2 > address > ranges, > - one pointing to a DW_TAG_compile_unit referencing the > /sysdeps/i386/elf/start.S file > - the other pointing to a DW_TAG_compile_unit with the helloworld,c file. > > However, in the foo program, the .debug_aranges section has only 1 address > range, pointing to a DW_TAG_compile_unit referencing the > /sysdeps/i386/elf/start.S file. > The second DW_TAG_compile_unit referencing the foo.xx file is present in > the > .debug_info section, but is not being referenced! > > Strangely, some information that seems to be an address range referencing > the > foo.xx DW_TAG_compile_unit, is present in the .debug_pubtypes section. Why > is > this in the wrong section?? > > > > The question: > ========> > Does anybody have any idea what it is I am doing wrong? > > The issue seems to be related to generating the info for a CompileUnit. > Currently, I am doing this: > dibuilder = new DIBuilder(themodule); > dibuilder->createCompileUnit(Lang, > StringRef("foo.xx")), /*finename*/ > StringRef(".") /*Dir*/, > StringRef("XXX") /*Producer*/, > false /*isOptimized*/, > StringRef("") /*Flags*/, > 0 /*RV: Runtime Version?*/); > DIFile file = dibuilder->createFile(StringRef("foo.x"), StringRef(".")); > DICompileUnit compile_unit = DICompileUnit(file); > dibuilder->createFunction(compile_unit /*Scope*/, > StringRef(function_name), StringRef(function_name), > file, > 42 /* line number*/, > di_func_type, > false /*isLocalToUnit*/, true /*isDefinition*/, > 42 /*ScopeLine*/ > ); > ... > ... > dibuilder->finalize(); > module->dump(); > > > To me, it seems wrong to create two compile units, one with > dibuilder->createCompileUnit() > and the other directly > DICompileUnit compile_unit = DICompileUnit(file); > > However, I could not figure out how to get a handle to the compile unit > generated by dibuilder->createCompileUnit(), in order to pass it to > dibuilder->createFunction(). > > > > > I can provide a lot more detail, but I do not want to bore you with > this. > If there is any info you need in order to help me out, please just ask, > and I > will do my best to provide it. > > > > Cheers, > > Mario. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121228/694d7163/attachment.html>
Maybe Matching Threads
- [LLVMdev] Dwarf debug info misses while clang codegen
- [LLVMdev] Accessing metadata & creating DIVariable
- [LLVMdev] Debug info compileunit metadata strangeness..
- [LLVMdev] Accessing metadata & creating DIVariable
- [LLVMdev] Accessing metadata & creating DIVariable