From: Roland McGrath Date: Thu, 2 Jul 2009 08:25:21 +0000 (-0700) Subject: pretty up tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=958163ed53b227c7dbbe210fc1ae7c28fc112a42;p=thirdparty%2Felfutils.git pretty up tests --- diff --git a/tests/ChangeLog b/tests/ChangeLog index cf956c612..d7c99a187 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,7 +1,8 @@ 2009-07-02 Roland McGrath + * 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 ... diff --git a/tests/Makefile.am b/tests/Makefile.am index ddd5de7d0..41cd9f328 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/dwarf-print.cc b/tests/dwarf-print.cc index 8d09ba157..36b9415be 100644 --- a/tests/dwarf-print.cc +++ b/tests/dwarf-print.cc @@ -30,11 +30,6 @@ #include #include #include -#include -#include -#include -#include -#include #include "c++/dwarf" diff --git a/tests/dwarf_edit.cc b/tests/dwarf_edit.cc index 35e6b1c20..5510be1ce 100644 --- a/tests/dwarf_edit.cc +++ b/tests/dwarf_edit.cc @@ -27,15 +27,6 @@ # include #endif -#include -#include -#include -#include -#include -#include -#include -#include - #include "c++/dwarf_edit" using namespace elfutils; diff --git a/tests/print-die.hh b/tests/print-die.hh index c4ff8a25f..91d70c997 100644 --- a/tests/print-die.hh +++ b/tests/print-die.hh @@ -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 + . */ + +#include +#include +#include +#include +#include +#include + +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) diff --git a/tests/run-dwarf-attributes.sh b/tests/run-dwarf-attributes.sh index 22c7289d9..4aa170ba7 100755 --- a/tests/run-dwarf-attributes.sh +++ b/tests/run-dwarf-attributes.sh @@ -27,7 +27,7 @@ testfiles testfile -testrun_compare ./dwarf-print --depth=1 testfile <<\EOF +testrun_compare ./dwarf-print --offsets --depth=1 testfile <<\EOF testfile: ... ...