<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi,</p>
<p>Strictly speaking, this is not a DWARF question, but it relates to DWARF because on the Mac the Mach-O NLIST/STAB symbol table is used as an index into DWARF symbols table. It's kind-of like Split-DWARF, but was invented long before Split-DWARF was added
to DWARF 5.</p>
<p>On a Mac OS 14 Sonoma M2 system, I'm seeing gfortran and gcc puts control characters in N_SO STABS:</p>
<p><tt>dc3-mac-tvt3 36 02/16 9:20 ~ % gfortran-mp-13 -gdwarf-4 ~/src/totalview.develop/debugger/src/tests/src/tx_f90_1module.f90<br>
dc3-mac-tvt3 37 02/16 9:20 ~ % nm -ap a.out | cat -v | grep SO | grep -F '^'<br>
0000000000000000 - 00 0000 SO /nfs/homes/jdelsign/<b>^B</b>/nfs/homes/jdelsign/src/totalview.develop/debugger/src/tests/src/<br>
dc3-mac-tvt3 38 02/16 9:21 ~ % <br>
</tt></p>
<p><tt>dc3-mac-tvt3 43 02/16 9:41 ~ % g++-mp-13 -gdwarf-4 ~/src/totalview.develop/debugger/src/tests/src/tx_hello.cxx<br>
dc3-mac-tvt3 44 02/16 9:41 ~ % nm -ap a.out | cat -v | grep SO | grep -F '^' <br>
0000000000000000 - 00 0000 SO /nfs/homes/jdelsign/<b>^D</b>/nfs/homes/jdelsign/src/totalview.develop/debugger/src/tests/src/<br>
dc3-mac-tvt3 45 02/16 9:41 ~ % </tt></p>
<p>Above, notice the ^B and ^D. I have also seen ^A used. Apparently, the control character separates the current working directory from the directory path of the file passed to the compiler.</p>
<p>Does anyone know if this is a "feature" or a "bug"? Is it document somewhere?</p>
<p>Here are all of the STABS for the above g++ compile:<br>
</p>
<p><tt>0000000000000000 - 00 0000 SO /nfs/homes/jdelsign/<b>^D</b>/nfs/homes/jdelsign/src/totalview.develop/debugger/src/tests/src/<br>
0000000000000000 - 00 0000 SO tx_hello.cxx<br>
0000000065cf7425 - 00 0001 OSO /var/folders/sm/hl1mjmg569g9yh_x_6fm889w0017hg/T//ccapF4uA.o<br>
0000000100003f3c - 01 0000 BNSYM <br>
0000000100003f3c - 01 0000 FUN _main<br>
000000000000005c - 00 0000 FUN <br>
0000000100003f3c - 01 0000 ENSYM <br>
0000000000000000 - 01 0000 SO <br>
</tt></p>
<p>And here is the matching DWARF CU:<br>
</p>
<p><tt>0x0000000b: DW_TAG_compile_unit<br>
DW_AT_producer ("GNU C++17 13.2.0 -fPIC -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -gdwarf-4")<br>
DW_AT_language (DW_LANG_C_plus_plus)<br>
DW_AT_name ("/nfs/homes/jdelsign/src/totalview.develop/debugger/src/tests/src/tx_hello.cxx")<br>
DW_AT_comp_dir ("/nfs/homes/jdelsign")<br>
DW_AT_GNU_pubnames (true)<br>
DW_AT_low_pc (0x0000000100003f3c)<br>
DW_AT_high_pc (0x0000000100003f98)<br>
DW_AT_stmt_list (0x00000000)<br>
</tt></p>
<p>The first N_SO is supposed to be the directory and the second is the file name. Notice that the second N_SO has no directory path. Given that the second N_SO is just the base name, having the current working directory and the directory path of the file passed
to the compiler is actually helpful, because it provides the same level of detail in the DWARF CU.</p>
<p>I was thinking that the debugger could look for a control character in the first N_SO string split the current working directory from the directory path, but if it's a bug in the compiler maybe that's not a good idea.<br>
</p>
Thanks, John D.
<p><br>
</p>
<br>
<p><span style="font-size:8.0pt;color:#A6A6A6;font-style:italic">This e-mail may contain information that is privileged or confidential. If you are not the intended recipient, please delete the e-mail and any attachments and notify us immediately.</span></p>
<br>
</body>
</html>