]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Add .debug_macro parsing support.
authorMark Wielaard <mjw@redhat.com>
Fri, 29 Jun 2012 20:30:15 +0000 (22:30 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 11 Jul 2012 17:10:19 +0000 (19:10 +0200)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-macro.sh [new file with mode: 0755]
tests/testfilemacro.bz2 [new file with mode: 0755]

index 2928ab1f94ffb2e484ff994aaf3c0d5e6ccd79d1..fcb6534e53184ebfb7ecffc63efc541e4fd6246a 100644 (file)
@@ -1,3 +1,12 @@
+2012-07-11  Mark Wielaard  <mjw@redhat.com>
+
+       * readelf.c (options): Add macro to help of debug-dump.
+       (section_e): Add section_macro.
+       (section_all): Add section_macro.
+       (parse_opt): Handle macro.
+       (print_debug_macro_section): New function.
+       (print_debug): Add NEW_SECTION (macro).
+
 2012-06-26  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (dwarf_attr_string): Add DW_AT_GNU_macros.
index eb1d469d015685c5a35e8002ce5156e619a210d7..a4975f9e984ef6d2ff2a8c6074bdec9b1b0e91f3 100644 (file)
@@ -86,7 +86,7 @@ static const struct argp_option options[] =
   { "debug-dump", 'w', "SECTION", OPTION_ARG_OPTIONAL,
     N_("Display DWARF section content.  SECTION can be one of abbrev, "
        "aranges, frame, gdb_index, info, loc, line, ranges, pubnames, str, "
-       "macinfo, or exception"), 0 },
+       "macinfo, macro or exception"), 0 },
   { "hex-dump", 'x', "SECTION", 0,
     N_("Dump the uninterpreted contents of SECTION, by number or name"), 0 },
   { "strings", 'p', "SECTION", OPTION_ARG_OPTIONAL,
@@ -183,10 +183,12 @@ static enum section_e
   section_ranges = 512,        /* .debug_ranges  */
   section_exception = 1024,    /* .eh_frame & al.  */
   section_gdb_index = 2048,    /* .gdb_index  */
+  section_macro = 4096,                /* .debug_macro  */
   section_all = (section_abbrev | section_aranges | section_frame
                 | section_info | section_line | section_loc
                 | section_pubnames | section_str | section_macinfo
-                | section_ranges | section_exception | section_gdb_index)
+                | section_ranges | section_exception | section_gdb_index
+                | section_macro)
 } print_debug_sections, implicit_debug_sections;
 
 /* Select hex dumping of sections.  */
@@ -395,6 +397,8 @@ parse_opt (int key, char *arg,
        print_debug_sections |= section_str;
       else if (strcmp (arg, "macinfo") == 0)
        print_debug_sections |= section_macinfo;
+      else if (strcmp (arg, "macro") == 0)
+       print_debug_sections |= section_macro;
       else if (strcmp (arg, "exception") == 0)
        print_debug_sections |= section_exception;
       else if (strcmp (arg, "gdb_index") == 0)
@@ -6748,6 +6752,412 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 }
 
 
+static void
+print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
+                          Ebl *ebl, GElf_Ehdr *ehdr,
+                          Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
+{
+  printf (gettext ("\
+\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
+         elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+         (uint64_t) shdr->sh_offset);
+  putc_unlocked ('\n', stdout);
+
+  Elf_Data *data = elf_getdata (scn, NULL);
+  if (unlikely (data == NULL || data->d_buf == NULL))
+    {
+      error (0, 0, gettext ("cannot get macro information section data: %s"),
+            elf_errmsg (-1));
+      return;
+    }
+
+  /* Get the source file information for all CUs.  Uses same
+     datastructure as macinfo.  But uses offset field to directly
+     match .debug_line offset.  And just stored in a list.  */
+  Dwarf_Off offset;
+  Dwarf_Off ncu = 0;
+  size_t hsize;
+  struct mac_culist *culist = NULL;
+  size_t nculist = 0;
+  while (dwarf_nextcu (dbg, offset = ncu, &ncu, &hsize, NULL, NULL, NULL) == 0)
+    {
+      Dwarf_Die cudie;
+      if (dwarf_offdie (dbg, offset + hsize, &cudie) == NULL)
+       continue;
+
+      Dwarf_Attribute attr;
+      if (dwarf_attr (&cudie, DW_AT_stmt_list, &attr) == NULL)
+       continue;
+
+      Dwarf_Word lineoff;
+      if (dwarf_formudata (&attr, &lineoff) != 0)
+       continue;
+
+      struct mac_culist *newp = (struct mac_culist *) alloca (sizeof (*newp));
+      newp->die = cudie;
+      newp->offset = lineoff;
+      newp->files = NULL;
+      newp->next = culist;
+      culist = newp;
+      ++nculist;
+    }
+
+  const unsigned char *readp = (const unsigned char *) data->d_buf;
+  const unsigned char *readendp = readp + data->d_size;
+
+  while (readp < readendp)
+    {
+      printf (gettext (" Offset:             0x%" PRIx64 "\n"),
+             readp - (const unsigned char *) data->d_buf);
+
+      // Header, 2 byte version, 1 byte flag, optional .debug_line offset,
+      // optional vendor extension macro entry table.
+      if (readp + 2 > readendp)
+       {
+       invalid_data:
+         error (0, 0, gettext ("invalid data"));
+         return;
+       }
+      const uint16_t vers = read_2ubyte_unaligned_inc (dbg, readp);
+      printf (gettext (" Version:            %" PRIu16 "\n"), vers);
+
+      // Version 4 is the GNU extension for DWARF4.  DWARF5 will use version
+      // 5 when it gets standardized.
+      if (vers != 4)
+       {
+         printf (gettext ("  unknown version, cannot parse section\n"));
+         return;
+       }
+
+      if (readp + 1 > readendp)
+       goto invalid_data;
+      const unsigned char flag = *readp++;
+      printf (gettext (" Flag:               0x%" PRIx8 "\n"), flag);
+
+      unsigned int offset_len = (flag & 0x01) ? 8 : 4;
+      printf (gettext (" Offset length:      %" PRIu8 "\n"), offset_len);
+      Dwarf_Off line_offset = -1;
+      if (flag & 0x02)
+       {
+         if (offset_len == 8)
+           line_offset = read_8ubyte_unaligned_inc (dbg, readp);
+         else
+           line_offset = read_4ubyte_unaligned_inc (dbg, readp);
+         printf (gettext (" .debug_line offset: 0x%" PRIx64 "\n"),
+                 line_offset);
+       }
+
+      const unsigned char *vendor[DW_MACRO_GNU_hi_user - DW_MACRO_GNU_lo_user];
+      if (flag & 0x04)
+       {
+         // 1 byte length, for each item, 1 byte opcode, uleb128 number
+         // of arguments, for each argument 1 byte form code.
+         if (readp + 1 > readendp)
+           goto invalid_data;
+         unsigned int tlen = *readp++;
+         printf (gettext ("  extension opcode table, %" PRIu8 " items:\n"),
+                 tlen);
+         for (unsigned int i = 0; i < tlen; i++)
+           {
+             if (readp + 1 > readendp)
+               goto invalid_data;
+             unsigned int opcode = *readp++;
+             printf (gettext ("    [%" PRIx8 "]"), opcode);
+             if (opcode < DW_MACRO_GNU_lo_user
+                 || opcode > DW_MACRO_GNU_hi_user)
+               goto invalid_data;
+             // Record the start of description for this vendor opcode.
+             // uleb128 nr args, 1 byte per arg form.
+             vendor[opcode - DW_MACRO_GNU_lo_user] = readp;
+             if (readp + 1 > readendp)
+               goto invalid_data;
+             unsigned int args = *readp++;
+             if (args > 0)
+               {
+                 printf (gettext (" %" PRIu8 " arguments:"), args);
+                 while (args > 0)
+                   {
+                     if (readp + 1 > readendp)
+                       goto invalid_data;
+                     unsigned int form = *readp++;
+                     printf (" %s", dwarf_form_string (form));
+                     if (form != DW_FORM_data1
+                         && form != DW_FORM_data2
+                         && form != DW_FORM_data4
+                         && form != DW_FORM_data8
+                         && form != DW_FORM_sdata
+                         && form != DW_FORM_udata
+                         && form != DW_FORM_block
+                         && form != DW_FORM_block1
+                         && form != DW_FORM_block2
+                         && form != DW_FORM_block4
+                         && form != DW_FORM_flag
+                         && form != DW_FORM_string
+                         && form != DW_FORM_strp
+                         && form != DW_FORM_sec_offset)
+                       goto invalid_data;
+                     args--;
+                     if (args > 0)
+                       putchar_unlocked (',');
+                   }
+               }
+             else
+               printf (gettext (" no arguments."));
+             putchar_unlocked ('\n');
+           }
+       }
+      putchar_unlocked ('\n');
+
+      int level = 1;
+      if (readp + 1 > readendp)
+       goto invalid_data;
+      unsigned int opcode = *readp++;
+      while (opcode != 0)
+       {
+         unsigned int u128;
+         unsigned int u128_2;
+         const unsigned char *endp;
+         uint64_t off;
+
+          switch (opcode)
+            {
+            case DW_MACRO_GNU_start_file:
+             get_uleb128 (u128, readp);
+             get_uleb128 (u128_2, readp);
+
+             /* Find the CU DIE that matches this line offset.  */
+             const char *fname = "???";
+             if (line_offset != (Dwarf_Off) -1)
+               {
+                 struct mac_culist *cu = culist;
+                 while (cu != NULL && line_offset != cu->offset)
+                   cu = cu->next;
+                 if (cu != NULL)
+                   {
+                     if (cu->files == NULL
+                         && dwarf_getsrcfiles (&cu->die, &cu->files,
+                                               NULL) != 0)
+                       cu->files = (Dwarf_Files *) -1l;
+
+                     if (cu->files != (Dwarf_Files *) -1l)
+                       fname = (dwarf_filesrc (cu->files, u128_2,
+                                               NULL, NULL) ?: "???");
+                   }
+               }
+             printf ("%*sstart_file %u, [%u] %s\n",
+                     level, "", u128, u128_2, fname);
+             ++level;
+             break;
+
+           case DW_MACRO_GNU_end_file:
+             --level;
+             printf ("%*send_file\n", level, "");
+             break;
+
+           case DW_MACRO_GNU_define:
+             get_uleb128 (u128, readp);
+             endp = memchr (readp, '\0', readendp - readp);
+             if (endp == NULL)
+               goto invalid_data;
+             printf ("%*s#define %s, line %u\n",
+                     level, "", readp, u128);
+             readp = endp + 1;
+             break;
+
+           case DW_MACRO_GNU_undef:
+             get_uleb128 (u128, readp);
+             endp = memchr (readp, '\0', readendp - readp);
+             if (endp == NULL)
+               goto invalid_data;
+             printf ("%*s#undef %s, line %u\n",
+                     level, "", readp, u128);
+             readp = endp + 1;
+             break;
+
+           case DW_MACRO_GNU_define_indirect:
+             get_uleb128 (u128, readp);
+             if (readp + offset_len > readendp)
+               goto invalid_data;
+             if (offset_len == 8)
+               off = read_8ubyte_unaligned_inc (dbg, readp);
+             else
+               off = read_4ubyte_unaligned_inc (dbg, readp);
+             printf ("%*s#define %s, line %u (indirect)\n",
+                     level, "", dwarf_getstring (dbg, off, NULL), u128);
+             break;
+
+           case DW_MACRO_GNU_undef_indirect:
+             get_uleb128 (u128, readp);
+             if (readp + offset_len > readendp)
+               goto invalid_data;
+             if (offset_len == 8)
+               off = read_8ubyte_unaligned_inc (dbg, readp);
+             else
+               off = read_4ubyte_unaligned_inc (dbg, readp);
+             printf ("%*s#undef %s, line %u (indirect)\n",
+                     level, "", dwarf_getstring (dbg, off, NULL), u128);
+             break;
+
+           case DW_MACRO_GNU_transparent_include:
+             if (readp + offset_len > readendp)
+               goto invalid_data;
+             if (offset_len == 8)
+               off = read_8ubyte_unaligned_inc (dbg, readp);
+             else
+               off = read_4ubyte_unaligned_inc (dbg, readp);
+             printf ("%*s#include offset 0x%" PRIx64 "\n",
+                     level, "", off);
+             break;
+
+           default:
+             printf ("%*svendor opcode 0x%" PRIx8, level, "", opcode);
+             if (opcode < DW_MACRO_GNU_lo_user
+                 || opcode > DW_MACRO_GNU_lo_user
+                 || vendor[opcode - DW_MACRO_GNU_lo_user] == NULL)
+               goto invalid_data;
+
+             const unsigned char *op_desc;
+             op_desc = vendor[opcode - DW_MACRO_GNU_lo_user];
+
+             // Just skip the arguments, we cannot really interpret them,
+             // but print as much as we can.
+             unsigned int args = *op_desc++;
+             while (args > 0)
+               {
+                 unsigned int form = *op_desc++;
+                 Dwarf_Word val;
+                 switch (form)
+                   {
+                   case DW_FORM_data1:
+                     if (readp + 1 > readendp)
+                       goto invalid_data;
+                     val = *readp++;
+                     printf (" %" PRIx8, (unsigned int) val);
+                     break;
+
+                   case DW_FORM_data2:
+                     if (readp + 2 > readendp)
+                       goto invalid_data;
+                     val = read_2ubyte_unaligned_inc (dbg, readp);
+                     printf(" %" PRIx16, (unsigned int) val);
+                     break;
+
+                   case DW_FORM_data4:
+                     if (readp + 4 > readendp)
+                       goto invalid_data;
+                     val = read_4ubyte_unaligned_inc (dbg, readp);
+                     printf (" %" PRIx32, (unsigned int) val);
+                     break;
+
+                   case DW_FORM_data8:
+                     if (readp + 8 > readendp)
+                       goto invalid_data;
+                     val = read_8ubyte_unaligned_inc (dbg, readp);
+                     printf (" %" PRIx64, val);
+                     break;
+
+                   case DW_FORM_sdata:
+                     get_sleb128 (val, readp);
+                     printf (" %" PRIx64, val);
+                     break;
+
+                   case DW_FORM_udata:
+                     get_uleb128 (val, readp);
+                     printf (" %" PRIx64, val);
+                     break;
+
+                   case DW_FORM_block:
+                     get_uleb128 (val, readp);
+                     printf (" block[%" PRIu64 "]", val);
+                     if (readp + val > readendp)
+                       goto invalid_data;
+                     readp += val;
+                     break;
+
+                   case DW_FORM_block1:
+                     if (readp + 1 > readendp)
+                       goto invalid_data;
+                     val = *readp++;
+                     printf (" block[%" PRIu64 "]", val);
+                     if (readp + val > readendp)
+                       goto invalid_data;
+                     break;
+
+                   case DW_FORM_block2:
+                     if (readp + 2 > readendp)
+                       goto invalid_data;
+                     val = read_2ubyte_unaligned_inc (dbg, readp);
+                     printf (" block[%" PRIu64 "]", val);
+                     if (readp + val > readendp)
+                       goto invalid_data;
+                     break;
+
+                   case DW_FORM_block4:
+                     if (readp + 2 > readendp)
+                       goto invalid_data;
+                     val =read_4ubyte_unaligned_inc (dbg, readp);
+                     printf (" block[%" PRIu64 "]", val);
+                     if (readp + val > readendp)
+                       goto invalid_data;
+                     break;
+
+                   case DW_FORM_flag:
+                     if (readp + 1 > readendp)
+                       goto invalid_data;
+                     val = *readp++;
+                     printf (" %s", nl_langinfo (val != 0 ? YESSTR : NOSTR));
+                     break;
+
+                   case DW_FORM_string:
+                     endp = memchr (readp, '\0', readendp - readp);
+                     if (endp == NULL)
+                       goto invalid_data;
+                     printf (" %s", readp);
+                     readp = endp + 1;
+                     break;
+
+                   case DW_FORM_strp:
+                     if (readp + offset_len > readendp)
+                       goto invalid_data;
+                     if (offset_len == 8)
+                       val = read_8ubyte_unaligned_inc (dbg, readp);
+                     else
+                       val = read_4ubyte_unaligned_inc (dbg, readp);
+                     printf (" %s", dwarf_getstring (dbg, val, NULL));
+                     break;
+
+                   case DW_FORM_sec_offset:
+                     if (readp + offset_len > readendp)
+                       goto invalid_data;
+                     if (offset_len == 8)
+                       val = read_8ubyte_unaligned_inc (dbg, readp);
+                     else
+                       val = read_4ubyte_unaligned_inc (dbg, readp);
+                     printf (" %" PRIx64, val);
+                     break;
+
+                     default:
+                       error (0, 0, gettext ("vendor opcode not verified?"));
+                       return;
+                   }
+
+                 args--;
+                 if (args > 0)
+                   putchar_unlocked (',');
+               }
+             putchar_unlocked ('\n');
+           }
+
+         if (readp + 1 > readendp)
+           goto invalid_data;
+         opcode = *readp++;
+         if (opcode == 0)
+           putchar_unlocked ('\n');
+       }
+    }
+}
+
+
 /* Callback for printing global names.  */
 static int
 print_pubnames (Dwarf *dbg __attribute__ ((unused)), Dwarf_Global *global,
@@ -7339,6 +7749,7 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
              NEW_SECTION (pubnames),
              NEW_SECTION (str),
              NEW_SECTION (macinfo),
+             NEW_SECTION (macro),
              NEW_SECTION (ranges),
              { ".eh_frame", section_frame | section_exception,
                print_debug_frame_section },
index 9b649173e99aebdce323af30dae770b6c6905379..48337f6ac1f7f8bd39dd5826ba0f902c564d10b9 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-11  Mark Wielaard  <mjw@redhat.com>
+
+       * run-readelf-macro.sh: New test.
+       * testfilemacro.bz2: New testfile.
+       * Makefile.am (TESTS): Add run-readelf-macro.sh.
+       (EXTRA_DIST): Add run-readelf-macro.sh and testfilemacro.bz2.
+
 2012-06-26  Mark Wielaard  <mjw@redhat.com>
 
        * run-macro-test.sh: New test.
index 39e58ae8679bfb08fa9d60b9e264dcd6eb6bb2f6..9f876e7551ee84df7720a37a3e773dd903869efe 100644 (file)
@@ -71,6 +71,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-find-prologues.sh run-allregs.sh \
        run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
        run-readelf-test4.sh run-readelf-twofiles.sh \
+       run-readelf-macro.sh \
        run-native-test.sh run-bug1-test.sh \
        dwfl-bug-addr-overflow run-addrname-test.sh \
        dwfl-bug-fd-leak dwfl-bug-report \
@@ -139,6 +140,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             testfile45.S.bz2 testfile45.expect.bz2 run-disasm-x86-64.sh \
             testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 \
             testfile49.bz2 testfile50.bz2 testfile51.bz2 \
+            run-readelf-macro.sh testfilemacro.bz2 \
             run-prelink-addr-test.sh \
             testfile52-32.so.bz2 testfile52-32.so.debug.bz2 \
             testfile52-32.prelink.so.bz2 testfile52-32.noshdrs.so.bz2 \
diff --git a/tests/run-readelf-macro.sh b/tests/run-readelf-macro.sh
new file mode 100755 (executable)
index 0000000..c65992b
--- /dev/null
@@ -0,0 +1,345 @@
+#! /bin/sh
+# Copyright (C) 2012 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# common.h
+# #define ONE 1
+# #define TWO 2
+# #define THREE 3
+#
+# #define WORLD "World"
+#
+# int say (const char *prefix);
+#
+# #define A 'a'
+# #define B b
+# #define C "C"
+#
+# #ifdef THREE
+# #undef THREE
+# #define THREE(ARG1,ARG2,ARG3) ARG3
+# #endif
+
+# hello.c
+# #include "common.h"
+#
+# int
+# main (int argc, char **argv)
+# {
+#   return say (WORLD);
+# }
+
+# world.c
+# #include "common.h"
+#
+# int
+# say (const char *prefix)
+# {
+#   return prefix ? ONE : TWO;
+# }
+
+# gcc -g3 -c hello.c
+# gcc -g3 -c world.c
+# gcc -g3 -o testfilemacro hello.o world.o
+
+testfiles testfilemacro
+
+testrun_compare ../src/readelf --debug-dump=macro testfilemacro <<\EOF
+
+DWARF section [32] '.debug_macro' at offset 0x2480:
+
+ Offset:             0x0
+ Version:            4
+ Flag:               0x2
+ Offset length:      4
+ .debug_line offset: 0x0
+
+ #include offset 0x1a
+ start_file 0, [1] /home/mark/src/tests/hello.c
+  start_file 1, [2] /home/mark/src/tests/common.h
+   #include offset 0x582
+  end_file
+ end_file
+
+ Offset:             0x1a
+ Version:            4
+ Flag:               0x0
+ Offset length:      4
+
+ #define __STDC__ 1, line 1 (indirect)
+ #define __STDC_HOSTED__ 1, line 1 (indirect)
+ #define __GNUC__ 4, line 1 (indirect)
+ #define __GNUC_MINOR__ 7, line 1 (indirect)
+ #define __GNUC_PATCHLEVEL__ 1, line 1 (indirect)
+ #define __VERSION__ "4.7.1 20120629 (Red Hat 4.7.1-1)", line 1 (indirect)
+ #define __GNUC_RH_RELEASE__ 1, line 1 (indirect)
+ #define __ATOMIC_RELAXED 0, line 1 (indirect)
+ #define __ATOMIC_SEQ_CST 5, line 1 (indirect)
+ #define __ATOMIC_ACQUIRE 2, line 1 (indirect)
+ #define __ATOMIC_RELEASE 3, line 1 (indirect)
+ #define __ATOMIC_ACQ_REL 4, line 1 (indirect)
+ #define __ATOMIC_CONSUME 1, line 1 (indirect)
+ #define __FINITE_MATH_ONLY__ 0, line 1 (indirect)
+ #define _LP64 1, line 1 (indirect)
+ #define __LP64__ 1, line 1 (indirect)
+ #define __SIZEOF_INT__ 4, line 1 (indirect)
+ #define __SIZEOF_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_LONG__ 8, line 1 (indirect)
+ #define __SIZEOF_SHORT__ 2, line 1 (indirect)
+ #define __SIZEOF_FLOAT__ 4, line 1 (indirect)
+ #define __SIZEOF_DOUBLE__ 8, line 1 (indirect)
+ #define __SIZEOF_LONG_DOUBLE__ 16, line 1 (indirect)
+ #define __SIZEOF_SIZE_T__ 8, line 1 (indirect)
+ #define __CHAR_BIT__ 8, line 1 (indirect)
+ #define __BIGGEST_ALIGNMENT__ 16, line 1 (indirect)
+ #define __ORDER_LITTLE_ENDIAN__ 1234, line 1 (indirect)
+ #define __ORDER_BIG_ENDIAN__ 4321, line 1 (indirect)
+ #define __ORDER_PDP_ENDIAN__ 3412, line 1 (indirect)
+ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__, line 1 (indirect)
+ #define __SIZEOF_POINTER__ 8, line 1 (indirect)
+ #define __SIZE_TYPE__ long unsigned int, line 1 (indirect)
+ #define __PTRDIFF_TYPE__ long int, line 1 (indirect)
+ #define __WCHAR_TYPE__ int, line 1 (indirect)
+ #define __WINT_TYPE__ unsigned int, line 1 (indirect)
+ #define __INTMAX_TYPE__ long int, line 1 (indirect)
+ #define __UINTMAX_TYPE__ long unsigned int, line 1 (indirect)
+ #define __CHAR16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __CHAR32_TYPE__ unsigned int, line 1 (indirect)
+ #define __SIG_ATOMIC_TYPE__ int, line 1 (indirect)
+ #define __INT8_TYPE__ signed char, line 1 (indirect)
+ #define __INT16_TYPE__ short int, line 1 (indirect)
+ #define __INT32_TYPE__ int, line 1 (indirect)
+ #define __INT64_TYPE__ long int, line 1 (indirect)
+ #define __UINT8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_LEAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_LEAST16_TYPE__ short int, line 1 (indirect)
+ #define __INT_LEAST32_TYPE__ int, line 1 (indirect)
+ #define __INT_LEAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_LEAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_LEAST16_TYPE__ short unsigned int, line 1 (indirect)
+ #define __UINT_LEAST32_TYPE__ unsigned int, line 1 (indirect)
+ #define __UINT_LEAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INT_FAST8_TYPE__ signed char, line 1 (indirect)
+ #define __INT_FAST16_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST32_TYPE__ long int, line 1 (indirect)
+ #define __INT_FAST64_TYPE__ long int, line 1 (indirect)
+ #define __UINT_FAST8_TYPE__ unsigned char, line 1 (indirect)
+ #define __UINT_FAST16_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST32_TYPE__ long unsigned int, line 1 (indirect)
+ #define __UINT_FAST64_TYPE__ long unsigned int, line 1 (indirect)
+ #define __INTPTR_TYPE__ long int, line 1 (indirect)
+ #define __UINTPTR_TYPE__ long unsigned int, line 1 (indirect)
+ #define __GXX_ABI_VERSION 1002, line 1 (indirect)
+ #define __SCHAR_MAX__ 127, line 1 (indirect)
+ #define __SHRT_MAX__ 32767, line 1 (indirect)
+ #define __INT_MAX__ 2147483647, line 1 (indirect)
+ #define __LONG_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __LONG_LONG_MAX__ 9223372036854775807LL, line 1 (indirect)
+ #define __WCHAR_MAX__ 2147483647, line 1 (indirect)
+ #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1), line 1 (indirect)
+ #define __WINT_MAX__ 4294967295U, line 1 (indirect)
+ #define __WINT_MIN__ 0U, line 1 (indirect)
+ #define __PTRDIFF_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __SIZE_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTMAX_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INTMAX_C(c) c ## L, line 1 (indirect)
+ #define __UINTMAX_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINTMAX_C(c) c ## UL, line 1 (indirect)
+ #define __SIG_ATOMIC_MAX__ 2147483647, line 1 (indirect)
+ #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1), line 1 (indirect)
+ #define __INT8_MAX__ 127, line 1 (indirect)
+ #define __INT16_MAX__ 32767, line 1 (indirect)
+ #define __INT32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT8_MAX__ 255, line 1 (indirect)
+ #define __UINT16_MAX__ 65535, line 1 (indirect)
+ #define __UINT32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INT_LEAST8_MAX__ 127, line 1 (indirect)
+ #define __INT8_C(c) c, line 1 (indirect)
+ #define __INT_LEAST16_MAX__ 32767, line 1 (indirect)
+ #define __INT16_C(c) c, line 1 (indirect)
+ #define __INT_LEAST32_MAX__ 2147483647, line 1 (indirect)
+ #define __INT32_C(c) c, line 1 (indirect)
+ #define __INT_LEAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT64_C(c) c ## L, line 1 (indirect)
+ #define __UINT_LEAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT8_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST16_MAX__ 65535, line 1 (indirect)
+ #define __UINT16_C(c) c, line 1 (indirect)
+ #define __UINT_LEAST32_MAX__ 4294967295U, line 1 (indirect)
+ #define __UINT32_C(c) c ## U, line 1 (indirect)
+ #define __UINT_LEAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT64_C(c) c ## UL, line 1 (indirect)
+ #define __INT_FAST8_MAX__ 127, line 1 (indirect)
+ #define __INT_FAST16_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST32_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __INT_FAST64_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINT_FAST8_MAX__ 255, line 1 (indirect)
+ #define __UINT_FAST16_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST32_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __UINT_FAST64_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __INTPTR_MAX__ 9223372036854775807L, line 1 (indirect)
+ #define __UINTPTR_MAX__ 18446744073709551615UL, line 1 (indirect)
+ #define __FLT_EVAL_METHOD__ 0, line 1 (indirect)
+ #define __DEC_EVAL_METHOD__ 2, line 1 (indirect)
+ #define __FLT_RADIX__ 2, line 1 (indirect)
+ #define __FLT_MANT_DIG__ 24, line 1 (indirect)
+ #define __FLT_DIG__ 6, line 1 (indirect)
+ #define __FLT_MIN_EXP__ (-125), line 1 (indirect)
+ #define __FLT_MIN_10_EXP__ (-37), line 1 (indirect)
+ #define __FLT_MAX_EXP__ 128, line 1 (indirect)
+ #define __FLT_MAX_10_EXP__ 38, line 1 (indirect)
+ #define __FLT_DECIMAL_DIG__ 9, line 1 (indirect)
+ #define __FLT_MAX__ 3.40282346638528859812e+38F, line 1 (indirect)
+ #define __FLT_MIN__ 1.17549435082228750797e-38F, line 1 (indirect)
+ #define __FLT_EPSILON__ 1.19209289550781250000e-7F, line 1 (indirect)
+ #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F, line 1 (indirect)
+ #define __FLT_HAS_DENORM__ 1, line 1 (indirect)
+ #define __FLT_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __FLT_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DBL_MANT_DIG__ 53, line 1 (indirect)
+ #define __DBL_DIG__ 15, line 1 (indirect)
+ #define __DBL_MIN_EXP__ (-1021), line 1 (indirect)
+ #define __DBL_MIN_10_EXP__ (-307), line 1 (indirect)
+ #define __DBL_MAX_EXP__ 1024, line 1 (indirect)
+ #define __DBL_MAX_10_EXP__ 308, line 1 (indirect)
+ #define __DBL_DECIMAL_DIG__ 17, line 1 (indirect)
+ #define __DBL_MAX__ ((double)1.79769313486231570815e+308L), line 1 (indirect)
+ #define __DBL_MIN__ ((double)2.22507385850720138309e-308L), line 1 (indirect)
+ #define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L), line 1 (indirect)
+ #define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L), line 1 (indirect)
+ #define __DBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __DBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __DBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __LDBL_MANT_DIG__ 64, line 1 (indirect)
+ #define __LDBL_DIG__ 18, line 1 (indirect)
+ #define __LDBL_MIN_EXP__ (-16381), line 1 (indirect)
+ #define __LDBL_MIN_10_EXP__ (-4931), line 1 (indirect)
+ #define __LDBL_MAX_EXP__ 16384, line 1 (indirect)
+ #define __LDBL_MAX_10_EXP__ 4932, line 1 (indirect)
+ #define __DECIMAL_DIG__ 21, line 1 (indirect)
+ #define __LDBL_MAX__ 1.18973149535723176502e+4932L, line 1 (indirect)
+ #define __LDBL_MIN__ 3.36210314311209350626e-4932L, line 1 (indirect)
+ #define __LDBL_EPSILON__ 1.08420217248550443401e-19L, line 1 (indirect)
+ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L, line 1 (indirect)
+ #define __LDBL_HAS_DENORM__ 1, line 1 (indirect)
+ #define __LDBL_HAS_INFINITY__ 1, line 1 (indirect)
+ #define __LDBL_HAS_QUIET_NAN__ 1, line 1 (indirect)
+ #define __DEC32_MANT_DIG__ 7, line 1 (indirect)
+ #define __DEC32_MIN_EXP__ (-94), line 1 (indirect)
+ #define __DEC32_MAX_EXP__ 97, line 1 (indirect)
+ #define __DEC32_MIN__ 1E-95DF, line 1 (indirect)
+ #define __DEC32_MAX__ 9.999999E96DF, line 1 (indirect)
+ #define __DEC32_EPSILON__ 1E-6DF, line 1 (indirect)
+ #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF, line 1 (indirect)
+ #define __DEC64_MANT_DIG__ 16, line 1 (indirect)
+ #define __DEC64_MIN_EXP__ (-382), line 1 (indirect)
+ #define __DEC64_MAX_EXP__ 385, line 1 (indirect)
+ #define __DEC64_MIN__ 1E-383DD, line 1 (indirect)
+ #define __DEC64_MAX__ 9.999999999999999E384DD, line 1 (indirect)
+ #define __DEC64_EPSILON__ 1E-15DD, line 1 (indirect)
+ #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD, line 1 (indirect)
+ #define __DEC128_MANT_DIG__ 34, line 1 (indirect)
+ #define __DEC128_MIN_EXP__ (-6142), line 1 (indirect)
+ #define __DEC128_MAX_EXP__ 6145, line 1 (indirect)
+ #define __DEC128_MIN__ 1E-6143DL, line 1 (indirect)
+ #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL, line 1 (indirect)
+ #define __DEC128_EPSILON__ 1E-33DL, line 1 (indirect)
+ #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL, line 1 (indirect)
+ #define __REGISTER_PREFIX__ , line 1 (indirect)
+ #define __USER_LABEL_PREFIX__ , line 1 (indirect)
+ #define __GNUC_GNU_INLINE__ 1, line 1 (indirect)
+ #define __NO_INLINE__ 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1, line 1 (indirect)
+ #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1, line 1 (indirect)
+ #define __GCC_ATOMIC_BOOL_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_SHORT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_INT_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_LLONG_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1, line 1 (indirect)
+ #define __GCC_ATOMIC_POINTER_LOCK_FREE 2, line 1 (indirect)
+ #define __GCC_HAVE_DWARF2_CFI_ASM 1, line 1 (indirect)
+ #define __PRAGMA_REDEFINE_EXTNAME 1, line 1 (indirect)
+ #define __SIZEOF_INT128__ 16, line 1 (indirect)
+ #define __SIZEOF_WCHAR_T__ 4, line 1 (indirect)
+ #define __SIZEOF_WINT_T__ 4, line 1 (indirect)
+ #define __SIZEOF_PTRDIFF_T__ 8, line 1 (indirect)
+ #define __amd64 1, line 1 (indirect)
+ #define __amd64__ 1, line 1 (indirect)
+ #define __x86_64 1, line 1 (indirect)
+ #define __x86_64__ 1, line 1 (indirect)
+ #define __k8 1, line 1 (indirect)
+ #define __k8__ 1, line 1 (indirect)
+ #define __MMX__ 1, line 1 (indirect)
+ #define __SSE__ 1, line 1 (indirect)
+ #define __SSE2__ 1, line 1 (indirect)
+ #define __SSE_MATH__ 1, line 1 (indirect)
+ #define __SSE2_MATH__ 1, line 1 (indirect)
+ #define __gnu_linux__ 1, line 1 (indirect)
+ #define __linux 1, line 1 (indirect)
+ #define __linux__ 1, line 1 (indirect)
+ #define linux 1, line 1 (indirect)
+ #define __unix 1, line 1 (indirect)
+ #define __unix__ 1, line 1 (indirect)
+ #define unix 1, line 1 (indirect)
+ #define __ELF__ 1, line 1 (indirect)
+ #define __DECIMAL_BID_FORMAT__ 1, line 1 (indirect)
+
+ Offset:             0x582
+ Version:            4
+ Flag:               0x0
+ Offset length:      4
+
+ #define ONE 1, line 1 (indirect)
+ #define TWO 2, line 2 (indirect)
+ #define THREE 3, line 3 (indirect)
+ #define WORLD "World", line 5 (indirect)
+ #define A 'a', line 9 (indirect)
+ #define B b, line 10
+ #define C "C", line 11 (indirect)
+ #undef THREE, line 14 (indirect)
+ #define THREE(ARG1,ARG2,ARG3) ARG3, line 15 (indirect)
+
+ Offset:             0x5bc
+ Version:            4
+ Flag:               0x2
+ Offset length:      4
+ .debug_line offset: 0x47
+
+ #include offset 0x1a
+ start_file 0, [1] /home/mark/src/tests/world.c
+  start_file 1, [2] /home/mark/src/tests/common.h
+   #include offset 0x582
+  end_file
+ end_file
+
+EOF
+
+exit 0
diff --git a/tests/testfilemacro.bz2 b/tests/testfilemacro.bz2
new file mode 100755 (executable)
index 0000000..7db51ff
Binary files /dev/null and b/tests/testfilemacro.bz2 differ