<div dir="ltr">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))</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 11, 2024 at 11:51 AM Lorenzo Gomez via Dwarf-discuss <<a href="mailto:dwarf-discuss@lists.dwarfstd.org">dwarf-discuss@lists.dwarfstd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div>
    <p>Something else to note:</p>
    <p>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.<br>
    </p>
    <p><br>
    </p>
    <div>On 9/11/24 1:47 PM, Lorenzo Gomez
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <p>Hi there,</p>
      <p><br>
      </p>
      <p>I'm currently using dwarfdump "2020-01-14 10:13:32-08:00  
        Package Version "20200114"" to look at macros inside the DWARF.</p>
      <p><br>
      </p>
      <p>Imagine two files; test_file1.h and test_file1.cpp<br>
      </p>
      <p>test_file1.cpp is defined as follows:</p>
      <p><br>
      </p>
      <blockquote>
        <p>/*<br>
           * test_file.cpp<br>
           *<br>
           */<br>
          <br>
          #ifdef __cplusplus<br>
          extern "C" {<br>
          #endif<br>
          <br>
          #include "test_file1.h"<br>
          <br>
          #include <fcntl.h><br>
          #include <stdio.h><br>
          #include <sys/stat.h><br>
          #include <sys/types.h><br>
          #include <unistd.h><br>
          <br>
          Square                                         sq             
          = {};<br>
          Circle                                         ci             
          = {};<br>
          #ifdef __cplusplus<br>
          }<br>
          #endif</p>
        <p><br>
        </p>
        <p><br>
        </p>
      </blockquote>
      <p><br>
      </p>
      <p><br>
      </p>
      <p>Here are two scenarios for the definition of test_file1.h.</p>
      <p><br>
      </p>
      <p>Scenario #1</p>
      <p>  test_file.h is defined as follows:</p>
      <blockquote>#include "stdint.h"<br>
        <br>
        #define CFE_MISSION_ES_PERF_MAX_IDS 128<br>
        <br>
        <br>
        <br>
        typedef struct CFE_ES_HousekeepingTlm_Payload<br>
        {<br>
            uint32_t PerfFilterMask[CFE_MISSION_ES_PERF_MAX_IDS / 32]; 
        /**< \cfetlmmnemonic \ES_PERFFLTRMASK<br>
                                                                  
        \brief Current Setting of Performance Analyzer Filter Masks */<br>
            uint32_t PerfTriggerMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
        /**< \cfetlmmnemonic \ES_PERFTRIGMASK<br>
                                                                    
        \brief Current Setting of Performance Analyzer Trigger Masks */<br>
        } CFE_ES_HousekeepingTlm_Payload_t;<br>
        <br>
        <br>
        <br>
      </blockquote>
      <p>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.</p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p>Scenario #2</p>
      <p>  test_file.h is defined as follows:</p>
      <p>        <br>
                #define CFE_MISSION_ES_PERF_MAX_IDS 128</p>
      <blockquote>#include "stdint.h"<br>
        <br>
        <br>
        <br>
        typedef struct CFE_ES_HousekeepingTlm_Payload<br>
        {<br>
            uint32_t PerfFilterMask[CFE_MISSION_ES_PERF_MAX_IDS / 32]; 
        /**< \cfetlmmnemonic \ES_PERFFLTRMASK<br>
                                                                  
        \brief Current Setting of Performance Analyzer Filter Masks */<br>
            uint32_t PerfTriggerMask[CFE_MISSION_ES_PERF_MAX_IDS / 32];
        /**< \cfetlmmnemonic \ES_PERFTRIGMASK<br>
                                                                    
        \brief Current Setting of Performance Analyzer Trigger Masks */<br>
        } CFE_ES_HousekeepingTlm_Payload_t;<br>
        <br>
        <br>
        <br>
      </blockquote>
      <p>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.</p>
      <p><br>
      </p>
      <p>Is there a reason why in order for macros to show up they have
        to be declared <i>before </i>the #include macro(s)?</p>
      <p><br>
      </p>
      <p>Perhaps I'm missing something obvious?</p>
      <p>Some more info about my system(x86 Intel CPU):</p>
      <p>NAME="Pop!_OS"<br>
        VERSION="20.04 LTS"<br>
        ID=pop<br>
        ID_LIKE="ubuntu debian"<br>
        PRETTY_NAME="Pop!_OS 20.04 LTS"<br>
        VERSION_ID="20.04"<br>
        HOME_URL=<a href="https://pop.system76.com" target="_blank">"https://pop.system76.com"</a><br>
        SUPPORT_URL=<a href="https://support.system76.com" target="_blank">"https://support.system76.com"</a><br>
        BUG_REPORT_URL=<a href="https://github.com/pop-os/pop/issues" target="_blank">"https://github.com/pop-os/pop/issues"</a><br>
        PRIVACY_POLICY_URL=<a href="https://system76.com/privacy" target="_blank">"https://system76.com/privacy"</a><br>
        VERSION_CODENAME=focal<br>
        UBUNTU_CODENAME=focal<br>
        LOGO=distributor-logo-pop-os<br>
        <br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p>Thanks</p>
      <p>Lorenzo<br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p>    <br>
      </p>
      <p><br>
      </p>
      <p> <br>
      </p>
    </blockquote>
  </div>

-- <br>
Dwarf-discuss mailing list<br>
<a href="mailto:Dwarf-discuss@lists.dwarfstd.org" target="_blank">Dwarf-discuss@lists.dwarfstd.org</a><br>
<a href="https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss" rel="noreferrer" target="_blank">https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss</a><br>
</blockquote></div>