[DebugInfo] Introduce GNU macro extension entry encodings

This is a preparatory patch for allowing the GNU .debug_macro extension,
which is a precursor to the DWARF 5 format, to be emitted by LLVM for
earlier DWARF versions.

The entries share the same encoding and behavior as in DWARF5; there are
just more entries in the DWARF 5 format. Therefore, we could have used
those existing DWARF 5 entries, but I think that explicitly referring to
the GNU macro variants makes the code more clear.

The defines that this patch introduces can be found in GCC in the dwarf2.h header:
  https://gcc.gnu.org/git/?p=gcc.git;a=blob;
  f=include/dwarf2.h;
  h=0b6facfd4cf4c02320c7328114231b128ab42d5e;
  hb=dccbf1e2a6e544f71b4a5795f0c79015db019fc3#l425

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D82972
This commit is contained in:
David Stenberg 2020-08-11 10:53:38 +02:00
parent a73008c1ae
commit 2892ed6d0f
2 changed files with 26 additions and 1 deletions

View File

@ -17,7 +17,7 @@
defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \
defined HANDLE_DW_CC || defined HANDLE_DW_LNS || defined HANDLE_DW_LNE || \
defined HANDLE_DW_LNCT || defined HANDLE_DW_MACRO || \
defined HANDLE_MACRO_FLAG || \
defined HANDLE_DW_MACRO_GNU || defined HANDLE_MACRO_FLAG || \
defined HANDLE_DW_RLE || defined HANDLE_DW_LLE || \
(defined HANDLE_DW_CFA && defined HANDLE_DW_CFA_PRED) || \
defined HANDLE_DW_APPLE_PROPERTY || defined HANDLE_DW_UT || \
@ -88,6 +88,10 @@
#define HANDLE_DW_MACRO(ID, NAME)
#endif
#ifndef HANDLE_DW_MACRO_GNU
#define HANDLE_DW_MACRO_GNU(ID, NAME)
#endif
#ifndef HANDLE_MACRO_FLAG
#define HANDLE_MACRO_FLAG(ID, NAME)
#endif
@ -837,6 +841,18 @@ HANDLE_DW_MACRO(0x0a, import_sup)
HANDLE_DW_MACRO(0x0b, define_strx)
HANDLE_DW_MACRO(0x0c, undef_strx)
// GNU .debug_macro extension.
HANDLE_DW_MACRO_GNU(0x01, define)
HANDLE_DW_MACRO_GNU(0x02, undef)
HANDLE_DW_MACRO_GNU(0x03, start_file)
HANDLE_DW_MACRO_GNU(0x04, end_file)
HANDLE_DW_MACRO_GNU(0x05, define_indirect)
HANDLE_DW_MACRO_GNU(0x06, undef_indirect)
HANDLE_DW_MACRO_GNU(0x07, transparent_include)
HANDLE_DW_MACRO_GNU(0x08, define_indirect_alt)
HANDLE_DW_MACRO_GNU(0x09, undef_indirect_alt)
HANDLE_DW_MACRO_GNU(0x0a, transparent_include_alt)
// DWARF v5 Macro header flags.
HANDLE_MACRO_FLAG(0x01, OFFSET_SIZE)
HANDLE_MACRO_FLAG(0x02, DEBUG_LINE_OFFSET)
@ -986,6 +1002,7 @@ HANDLE_DW_SECT(8, RNGLISTS)
#undef HANDLE_DW_LNE
#undef HANDLE_DW_LNCT
#undef HANDLE_DW_MACRO
#undef HANDLE_DW_MACRO_GNU
#undef HANDLE_MACRO_FLAG
#undef HANDLE_DW_RLE
#undef HANDLE_DW_LLE

View File

@ -309,6 +309,14 @@ enum MacroEntryType {
DW_MACRO_hi_user = 0xff
};
/// GNU .debug_macro macro information entry type encodings.
enum GnuMacroEntryType {
#define HANDLE_DW_MACRO_GNU(ID, NAME) DW_MACRO_GNU_##NAME = ID,
#include "llvm/BinaryFormat/Dwarf.def"
DW_MACRO_GNU_lo_user = 0xe0,
DW_MACRO_GNU_hi_user = 0xff
};
/// DWARF v5 range list entry encoding values.
enum RnglistEntries {
#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,