diff options
| author | Mark Wielaard <[email protected]> | 2012-04-27 13:00:50 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2012-04-28 15:02:28 +0200 |
| commit | 547972539ecbe8668e89d891d86cef10f0302fd5 (patch) | |
| tree | ac41ac0a8ba48e00038a9b8de5b252e33e841b9e /tests | |
| parent | bdad8e39aede889dbac95944a07eaebdebe4ad89 (diff) | |
dwarf_highpc: Handle DW_AT_high_pc being a constant offset from DW_AT_low_pc.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 8 | ||||
| -rw-r--r-- | tests/Makefile.am | 8 | ||||
| -rw-r--r-- | tests/low_high_pc.c | 114 | ||||
| -rwxr-xr-x | tests/run-low_high_pc.sh | 42 | ||||
| -rwxr-xr-x | tests/testfile_low_high_pc.bz2 | bin | 0 -> 2812 bytes |
5 files changed, 169 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index ffe61d54..abc73400 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2012-04-27 Mark Wielaard <[email protected]> + + * Makefile.am (TESTS): Add run-low_high_pc.sh + (EXTRA_DIST): Add run-low_high_pc.sh and testfile_low_high_pc.bz2 + (noinst_PROGRAMS): Add low_high_pc. + (low_high_pc_LDADD): New variable. + * low_high_pc.c: New test. + 2012-04-26 Mark Wielaard <[email protected]> * Makefile.am (EXTRA_DIST): Remove run-show-ciefde.sh. diff --git a/tests/Makefile.am b/tests/Makefile.am index 835cc7a7..61247e46 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -58,7 +58,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ dwfl-addr-sect dwfl-bug-report early-offscn \ dwfl-bug-getmodules dwarf-getmacros addrcfi \ test-flag-nobits dwarf-getstring rerequest_tag \ - alldts md5-sha1-test typeiter + alldts md5-sha1-test typeiter low_high_pc asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ asm-tst6 asm-tst7 asm-tst8 asm-tst9 @@ -87,7 +87,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-early-offscn.sh run-dwarf-getmacros.sh \ run-test-flag-nobits.sh run-prelink-addr-test.sh \ run-dwarf-getstring.sh run-rerequest_tag.sh run-typeiter.sh \ - run-readelf-d.sh run-unstrip-n.sh + run-readelf-d.sh run-unstrip-n.sh run-low_high_pc.sh if !STANDALONE noinst_PROGRAMS += msg_tst md5-sha1-test @@ -164,7 +164,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ testfile56.bz2 testfile57.bz2 testfile58.bz2 \ run-typeiter.sh testfile59.bz2 \ run-readelf-d.sh testlib_dynseg.so.bz2 \ - run-unstrip-n.sh testcore-rtlib.bz2 + run-unstrip-n.sh testcore-rtlib.bz2 \ + run-low_high_pc.sh testfile_low_high_pc.bz2 installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \ bindir=$(DESTDIR)$(bindir) \ @@ -262,6 +263,7 @@ rerequest_tag_LDADD = $(libdw) $(libmudflap) alldts_LDADD = $(libebl) $(libelf) $(libmudflap) md5_sha1_test_LDADD = $(libeu) typeiter_LDADD = $(libdw) $(libelf) $(libmudflap) +low_high_pc_LDADD = $(libdw) $(libelf) $(libmudflap) if GCOV check: check-am coverage diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c new file mode 100644 index 00000000..3054046b --- /dev/null +++ b/tests/low_high_pc.c @@ -0,0 +1,114 @@ +/* Test program for dwarf_lowpc and dwarf_highpc + Copyright (C) 2012 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 <config.h> +#include <assert.h> +#include <inttypes.h> +#include ELFUTILS_HEADER(dwfl) +#include <dwarf.h> +#include <argp.h> +#include <stdio.h> +#include <stdio_ext.h> +#include <locale.h> +#include <stdlib.h> +#include <error.h> +#include <string.h> +#include <fnmatch.h> + +struct args +{ + Dwfl *dwfl; + Dwarf_Die *cu; + Dwarf_Addr dwbias; + char **argv; + const char *file; +}; + +static struct args *args; + +static void +fail(Dwarf_Off off, const char *name, const char *msg) +{ + printf("%s: [%lx] '%s' %s\n", args->file, off, name, msg); + exit(-1); +} + +static int +handle_die (Dwarf_Die *die, void *arg) +{ + args = arg; + Dwarf_Off off = dwarf_dieoffset (die); + + const char *name = dwarf_diename (die); + if (name == NULL) + fail (off, "<no name>", "die without a name"); + + Dwarf_Addr lowpc = 0; + Dwarf_Addr highpc = 0; + if (dwarf_lowpc (die, &lowpc) != 0 && dwarf_hasattr (die, DW_AT_low_pc)) + fail (off, name, "has DW_AT_low_pc but dwarf_lowpc fails"); + if (dwarf_highpc (die, &highpc) != 0 && dwarf_hasattr (die, DW_AT_high_pc)) + fail (off, name, "has DW_AT_high_pc but dwarf_highpc fails"); + + if (dwarf_hasattr (die, DW_AT_low_pc) + && dwarf_hasattr (die, DW_AT_high_pc) + && highpc <= lowpc) + { + printf("lowpc: %lx, highpc: %lx\n", lowpc, highpc); + fail (off, name, "highpc <= lowpc"); + } + + return 0; +} + + +int +main (int argc, char *argv[]) +{ + int remaining; + + /* Set locale. */ + (void) setlocale (LC_ALL, ""); + + struct args a = { .dwfl = NULL, .cu = NULL }; + + (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, + &a.dwfl); + assert (a.dwfl != NULL); + a.argv = &argv[remaining]; + + int result = 0; + + while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL) + { + a.file = dwarf_diename (a.cu); + handle_die (a.cu, &a); + dwarf_getfuncs (a.cu, &handle_die, &a, 0); + } + + dwfl_end (a.dwfl); + + return result; +} diff --git a/tests/run-low_high_pc.sh b/tests/run-low_high_pc.sh new file mode 100755 index 00000000..8d891f1c --- /dev/null +++ b/tests/run-low_high_pc.sh @@ -0,0 +1,42 @@ +#! /bin/sh +# Copyright (C) 2005 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>. + +. $srcdir/test-subr.sh + +# int +# main (int argc, char **argv) +# { +# return 0; +# } +# gcc -g -o main main.c +testfiles testfile_low_high_pc + +testrun ./low_high_pc -e ./testfile_low_high_pc +testrun ./low_high_pc -e ./low_high_pc +testrun ./low_high_pc -e ../src/strip +testrun ./low_high_pc -e ../src/strip.o +testrun ./low_high_pc -e ../libelf/libelf.so + +exit 0 diff --git a/tests/testfile_low_high_pc.bz2 b/tests/testfile_low_high_pc.bz2 Binary files differnew file mode 100755 index 00000000..f20814aa --- /dev/null +++ b/tests/testfile_low_high_pc.bz2 |
