]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
pretty up tests
authorRoland McGrath <roland@redhat.com>
Thu, 2 Jul 2009 08:25:21 +0000 (01:25 -0700)
committerRoland McGrath <roland@redhat.com>
Thu, 2 Jul 2009 08:28:25 +0000 (01:28 -0700)
tests/ChangeLog
tests/Makefile.am
tests/dwarf-print.cc
tests/dwarf_edit.cc
tests/print-die.hh
tests/run-dwarf-attributes.sh

index cf956c612bb91a171110af7cde02a2075b0df9ca..d7c99a187b9ce74136876877a7d0ea4dac07ca18 100644 (file)
@@ -1,7 +1,8 @@
 2009-07-02  Roland McGrath  <roland@redhat.com>
 
+       * run-dwarf_edit.sh: New file.
        * dwarf_edit.cc: New file.
-       * Makefile.am (noinst_PROGRAMS, TESTS): Add it.
+       * Makefile.am (noinst_PROGRAMS, TESTS, EXTRA_DIST): Add them.
        (dwarf_edit_SOURCES, dwarf_edit_LDADD): New variables.
 
        * dwarf-print.cc (print_die): Templatify and move ...
index ddd5de7d0e4ff3bd9a9ff666f78973253a38c33e..41cd9f3288150432b127e9999bd9e8b3f8a53b3a 100644 (file)
@@ -91,7 +91,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-disasm-x86.sh run-disasm-x86-64.sh \
        run-early-offscn.sh run-dwarf-getmacros.sh \
        run-dwarfcmp-self.sh run-dwarflint-self.sh run-dwarf-attributes.sh \
-       dwarf_edit
+       run-dwarf_edit.sh
 # run-show-ciefde.sh
 
 if !STANDALONE
@@ -126,7 +126,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             run-dwfl-addr-sect.sh run-early-offscn.sh \
             run-dwarf-getmacros.sh \
             run-dwarfcmp-self.sh run-dwarflint-self.sh \
-            run-dwarf-attributes.sh \
+            run-dwarf-attributes.sh run-dwarf_edit.sh \
             testfile15.bz2 testfile15.debug.bz2 \
             testfile16.bz2 testfile16.debug.bz2 \
             testfile17.bz2 testfile17.debug.bz2 \
index 8d09ba1576432247d0c01e9117de427e2faaa528..36b9415beed324ea15793e6faf203f2328797fe7 100644 (file)
 #include <errno.h>
 #include <error.h>
 #include <fcntl.h>
-#include <clocale>
-#include <cstdio>
-#include <libintl.h>
-#include <ostream>
-#include <iomanip>
 
 #include "c++/dwarf"
 
index 35e6b1c205d86c99c7d143333424749a33fcaf0e..5510be1ceed2130af8e9f4813d35610eee006136 100644 (file)
 # include <config.h>
 #endif
 
-#include <errno.h>
-#include <error.h>
-#include <fcntl.h>
-#include <clocale>
-#include <cstdio>
-#include <libintl.h>
-#include <ostream>
-#include <iomanip>
-
 #include "c++/dwarf_edit"
 
 using namespace elfutils;
index c4ff8a25f1b799dddd444027a3c2b79592ec3d18..91d70c9979c06304ee367b5db23797654e09bfc2 100644 (file)
@@ -1,3 +1,36 @@
+/* Pseudo-XMLish printing for elfutils::dwarf* tests.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat 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 Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#include <cstring>
+#include <cstdio>
+#include <clocale>
+#include <libintl.h>
+#include <ostream>
+#include <iomanip>
+
+static bool print_offset;
 
 static void
 print_die_main (int &argc, char **&argv, unsigned int &depth)
@@ -13,6 +46,13 @@ print_die_main (int &argc, char **&argv, unsigned int &depth)
 
   cout << hex << setiosflags (ios::showbase);
 
+  if (argc > 1 && !strcmp (argv[1], "--offsets"))
+    {
+      print_offset = true;
+      --argc;
+      ++argv;
+    }
+
   depth = 0;
   if (argc > 1 && sscanf (argv[1], "--depth=%u", &depth) == 1)
     {
@@ -29,7 +69,9 @@ print_die (const typename file::debug_info_entry &die,
   string prefix (indent, ' ');
   const string tag = dwarf::tags::name (die.tag ());
 
-  cout << prefix << "<" << tag << " offset=[" << die.offset () << "]";
+  cout << prefix << "<" << tag;
+  if (print_offset)
+    cout << " offset=[" << die.offset () << "]";
 
   for (typename file::debug_info_entry::attributes_type::const_iterator i
         = die.attributes ().begin (); i != die.attributes ().end (); ++i)
index 22c7289d9ce9ada1600f1bfac76acba772265334..4aa170ba73f07bde9af6aca5873088c661ab635c 100755 (executable)
@@ -27,7 +27,7 @@
 
 testfiles testfile
 
-testrun_compare ./dwarf-print --depth=1 testfile <<\EOF
+testrun_compare ./dwarf-print --offsets --depth=1 testfile <<\EOF
 testfile:
  <compile_unit offset=[0xb] stmt_list=0 high_pc=0x804845a low_pc=0x804842c name="m.c" comp_dir="/home/drepper/gnu/new-bu/build/ttt" producer="GNU C 2.96 20000731 (Red Hat Linux 7.0)" language=C89>...
  <compile_unit offset=[0xca] stmt_list=0x4b high_pc=0x8048466 low_pc=0x804845c name="b.c" comp_dir="/home/drepper/gnu/new-bu/build/ttt" producer="GNU C 2.96 20000731 (Red Hat Linux 7.0)" language=C89>...