[Dwarf-Discuss] File name encoding in DWARF

Robinson, Paul paul.robinson@sony.com
Wed Nov 27 14:11:55 GMT 2019


> I am trying to consume the file name of a compile unit. Fortunately
> DW_TAG_compile_unit has a member DW_AT_name and DW_AT_comp_dir.
> Unfortunately it is not clear which kind of encoding is used to
> store these strings. I tried around with GCC and clang. GCC under
> Windows produces latin1 encoding and clang produces UTF-8. I have
> not found any information inside the DWARF debug info on the type
> of encoding used. Is there a way to determine which encoding was
> used? Otherwise, searching for the file on disk can become a
> problem.

DWARF version 3 added the DW_AT_use_UTF8 flag on the compilation
unit to indicate that strings are encoded with UTF-8.  If the flag
is present, you can assume all strings are UTF-8.  Unfortunately,
in the absence of that flag, there is no specified encoding.
DWARF version 5 strongly recommends UTF-8 but does not require it.
--paulr




More information about the Dwarf-discuss mailing list