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

Lorenzo Gomez lgomez@windhoverlabs.com
Wed Sep 11 18:50:51 GMT 2024


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:
>
> 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
>     extern "C" {
>     #endif
>
>     #include "test_file1.h"
>
>     #include <fcntl.h>
>     #include <stdio.h>
>     #include <sys/stat.h>
>     #include <sys/types.h>
>     #include <unistd.h>
>
>     Square                                         sq = {};
>     Circle                                         ci = {};
>     #ifdef __cplusplus
>     }
>     #endif
>
>
>
>
>
> Here are two scenarios for the definition of test_file1.h.
>
>
> Scenario #1
>
>   test_file.h is defined as follows:
>
>     #include "stdint.h"
>
>     #define CFE_MISSION_ES_PERF_MAX_IDS 128
>
>
>
>     typedef struct CFE_ES_HousekeepingTlm_Payload
>     {
>         uint32_t PerfFilterMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
>     /**< \cfetlmmnemonic \ES_PERFFLTRMASK
>     \brief Current Setting of Performance Analyzer Filter Masks */
>         uint32_t PerfTriggerMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
>     /**< \cfetlmmnemonic \ES_PERFTRIGMASK
>     \brief Current Setting of Performance Analyzer Trigger Masks */
>     } CFE_ES_HousekeepingTlm_Payload_t;
>
>
>
> After compiling with "gcc  -g3 -c -gdwarf-4  test_file1.cpp -o 
> test_file1_copy_dwarf4.o" and then running "dwarfdump 
> test_file1_dwarf4.o > dwarf4_test_file1.txt". The Macro doe NOT show 
> up in dwarf4_test_file1.txt. It does show up under the debug string 
> table but not under the "debug_macro" section.
>
>
>
>
>
> Scenario #2
>
>   test_file.h is defined as follows:
>
>
>         #define CFE_MISSION_ES_PERF_MAX_IDS 128
>
>     #include "stdint.h"
>
>
>
>     typedef struct CFE_ES_HousekeepingTlm_Payload
>     {
>         uint32_t PerfFilterMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
>     /**< \cfetlmmnemonic \ES_PERFFLTRMASK
>     \brief Current Setting of Performance Analyzer Filter Masks */
>         uint32_t PerfTriggerMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
>     /**< \cfetlmmnemonic \ES_PERFTRIGMASK
>     \brief Current Setting of Performance Analyzer Trigger Masks */
>     } CFE_ES_HousekeepingTlm_Payload_t;
>
>
>
> After compiling with "gcc  -g3 -c -gdwarf-4  test_file1.cpp -o 
> test_file1_dwarf4.o" and then running "dwarfdump test_file1_dwarf4.o 
> > dwarf4_test_file1.txt". The Macro DOES show up in 
> dwarf4_test_file1.txt. It does show up under the "debug_macro" section.
>
>
> Is there a reason why in order for macros to show up they have to be 
> declared /before /the #include macro(s)?
>
>
> Perhaps I'm missing something obvious?
>
> Some more info about my system(x86 Intel CPU):
>
> NAME="Pop!_OS"
> VERSION="20.04 LTS"
> ID=pop
> ID_LIKE="ubuntu debian"
> PRETTY_NAME="Pop!_OS 20.04 LTS"
> VERSION_ID="20.04"
> HOME_URL="https://pop.system76.com"
> SUPPORT_URL="https://support.system76.com"
> BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
> PRIVACY_POLICY_URL="https://system76.com/privacy"
> VERSION_CODENAME=focal
> UBUNTU_CODENAME=focal
> LOGO=distributor-logo-pop-os
>
>
>
>
> Thanks
>
> Lorenzo
>
>
>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20240911/cbca2a8c/attachment.htm>


More information about the Dwarf-discuss mailing list