Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-15 Thread David Anderson via Dwarf-discuss
On 9/13/24 15:50, Lorenzo Gomez via Dwarf-discuss wrote: int dwarf_init_b(int    /*fd*/,     Dwarf_Unsigned    /*access*/,     unsigned          /*groupnumber*/,     Dwarf_Handler     /*errhand*/,     Dwarf_Ptr         /*errarg*/,     Dwarf_Debug*      /*dbg*/,     Dwarf_Error*      /*error

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Lorenzo Gomez via Dwarf-discuss
I did find it kind of odd too that it emitted "macinfo". I got a newer version of clang(Ubuntu clang version 14.0.0-1ubuntu1.1 ) and now it actually emits the DWARF5 version of macros: .debug_macro: Macro info for a single cu at macro Offset 0x Macro data from CU-DIE at .debug_info offset

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread David Anderson via Dwarf-discuss
On 9/13/24 09:37, Jakub Jelinek via Dwarf-discuss wrote: DW_MACRO_import 0 means include the .debug_macro chunk from offset 0 in the section, which with applied relocations would be endless recursion there. Most likely just dwarfdump doesn't distinguish in that 0x what it really is, it is

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread David Anderson via Dwarf-discuss
On 9/12/24 11:39, David Blaikie via Dwarf-discuss wrote: Oooh, fascinating. Certainly llvm-dwarfdump has explicit support for sections it expects to be fragmented (multiple sections with the same name, for comdat purposes, etc) - and so llvm-dwarfdump certainly wouldn't dump this correctly (prob

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Jakub Jelinek via Dwarf-discuss
On Fri, Sep 13, 2024 at 01:46:26PM -0500, Lorenzo Gomez wrote: > That makes sense. Interestingly enough when I run with clang > "clang -gdwarf-5 -fdebug-macro -g3 -c macro_test.c -o macro_test_clang.o" > and dwarfdump with "dwarfdump macro_test_clang.o > macro_test_clang_dwarf" > > yields all the

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Lorenzo Gomez via Dwarf-discuss
That makes sense. Interestingly enough when I run with clang "clang -gdwarf-5 -fdebug-macro -g3 -c macro_test.c -o macro_test_clang.o" and dwarfdump with "dwarfdump macro_test_clang.o > macro_test_clang_dwarf" yields all the macros: compilation-unit .debug_macinfo offset 0x num name sect

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Jakub Jelinek via Dwarf-discuss
On Fri, Sep 13, 2024 at 10:51:33AM -0500, Lorenzo Gomez wrote: > Thanks again for all of the insight into all this. The reason we're looking > into this is because we develop a tool that extracts dwarf info from an elf > file called juicer , which dumps > it

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Lorenzo Gomez via Dwarf-discuss
Would like to clarify: I ran dwarfdump on "macro_test_relocatable" On Fri, Sep 13, 2024 at 10:51 AM Lorenzo Gomez wrote: > Thanks again for all of the insight into all this. The reason we're > looking into this is because we develop a tool that extracts dwarf info > from an elf file called juice

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-13 Thread Lorenzo Gomez via Dwarf-discuss
Thanks again for all of the insight into all this. The reason we're looking into this is because we develop a tool that extracts dwarf info from an elf file called juicer , which dumps it into a SQLITE db for other tools. And we want to make sure we document

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-12 Thread Jakub Jelinek via Dwarf-discuss
On Thu, Sep 12, 2024 at 05:10:01PM -0500, Lorenzo Gomez wrote: > Thanks so much for the detailed explanation. So clearly all the macros are > there as we can see from readelf. I ran it myself and can see all the > macros as David pointed out. And just to make sure I understand, this is > what I too

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-12 Thread Lorenzo Gomez via Dwarf-discuss
Thanks so much for the detailed explanation. So clearly all the macros are there as we can see from readelf. I ran it myself and can see all the macros as David pointed out. And just to make sure I understand, this is what I took away: 1. All the macros are in the file as we can see from readelf o

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-12 Thread David Blaikie via Dwarf-discuss
On Thu, Sep 12, 2024 at 11:08 AM Jakub Jelinek wrote: > On Thu, Sep 12, 2024 at 10:52:33AM -0700, David Blaikie via Dwarf-discuss > wrote: > > Looks probably like a bug in GCC and best discussed in their forum? > (clang > > seems to produce the macro in the macinfo if you compile with > > `-fdebu

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-12 Thread Jakub Jelinek via Dwarf-discuss
On Thu, Sep 12, 2024 at 10:52:33AM -0700, David Blaikie via Dwarf-discuss wrote: > Looks probably like a bug in GCC and best discussed in their forum? (clang > seems to produce the macro in the macinfo if you compile with > `-fdebug-macro` (& you have to put some emitted entity (like a function > d

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-12 Thread David Blaikie via Dwarf-discuss
Looks probably like a bug in GCC and best discussed in their forum? (clang seems to produce the macro in the macinfo if you compile with `-fdebug-macro` (& you have to put some emitted entity (like a function definition) in the file before Clang will produce any debug info for the file)) On Wed, S

Re: [Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-11 Thread Lorenzo Gomez via Dwarf-discuss
Something else to note: If I link the "test_file1.o" file with "gcc  -g3  -nostartfiles -Llib -gdwarf-4  test_file1_copy.o -o test_file1_linked_dwarf4.o" the macro shows up in the DWARF, regardless of whether it is defined before/after the #include. On 9/11/24 1:47 PM, Lorenzo Gomez wrote:

[Dwarf-discuss] Macros after "#include" does not show up DWARF

2024-09-11 Thread Lorenzo Gomez via Dwarf-discuss
Hi there, I'm currently using dwarfdump "2020-01-14 10:13:32-08:00 Package Version "20200114"" to look at macros inside the DWARF. Imagine two files; test_file1.h and test_file1.cpp test_file1.cpp is defined as follows: /*  * test_file.cpp  *  */ #ifdef __cplusplus e