summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2007-04-16 23:13:37 +0000
committerRoland McGrath <[email protected]>2007-04-16 23:13:37 +0000
commit43da9895c6d828ceae65a47f2337e8ef24eb97c1 (patch)
tree4454878335a5a6f65083a04824b3968702bfcf6b /tests
parentbf2ee480165faec726d678f189acd2bd54e07573 (diff)
libdw/
2007-04-16 Roland McGrath <[email protected]> * libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section. libdwfl/ 2007-04-16 Roland McGrath <[email protected]> * derelocate.c (cache_sections): Apply bias to sh_addr. (compare_secrefs): Fix address comparison to avoid signed overflow. (find_section): New function, broken out of ... (dwfl_module_relocate_address): ... here, call it. (check_module): New function, broken out of ... (dwfl_module_relocate_address): ... here, call it. (dwfl_module_address_section): New function. * libdwfl.h: Declare it. tests/ 2007-04-16 Roland McGrath <[email protected]> * dwfl-addr-sect.c: New file. * Makefile.am (noinst_PROGRAMS): Add it. (dwfl_addr_sect_LDADD): New variable.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog11
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/dwfl-addr-sect.c85
-rw-r--r--tests/get-files.c18
-rwxr-xr-xtests/run-get-files.sh8
5 files changed, 123 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index f57c6e10..df78c086 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,14 @@
+2007-04-16 Roland McGrath <[email protected]>
+
+ * dwfl-addr-sect.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (dwfl_addr_sect_LDADD): New variable.
+
+2007-04-05 Roland McGrath <[email protected]>
+
+ * get-files.c: Test dwarf_getsrcdirs.
+ * run-get-files.sh: Update expected output.
+
2007-04-01 Roland McGrath <[email protected]>
* run-allregs.sh: Updated expected output for x86_64.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c72ea3ce..0715fff8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,7 +58,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
get-aranges allfcts line2addr addrscopes funcscopes \
show-abbrev hash newscn ecp dwflmodtest \
find-prologues funcretval allregs rdwrmmap \
- dwfl-bug-addr-overflow arls dwfl-bug-fd-leak
+ dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
+ dwfl-addr-sect
# get-ciefde
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -204,6 +205,7 @@ rdwrmmap_LDADD = $(libelf)
dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
arls_LDADD = $(libelf) $(libmudflap)
dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
+dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
CLEANFILES = xxx *.gcno *.gcda *gconv
diff --git a/tests/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
new file mode 100644
index 00000000..b1f29f7c
--- /dev/null
+++ b/tests/dwfl-addr-sect.c
@@ -0,0 +1,85 @@
+/* Test program for libdwfl ... foo
+ Copyright (C) 2007 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 <sys/types.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <locale.h>
+#include <argp.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+
+
+static void
+handle_address (Dwfl *dwfl, Dwarf_Addr address)
+{
+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, address);
+ Dwarf_Addr adjusted = address;
+ Dwarf_Addr bias;
+ Elf_Scn *scn = dwfl_module_address_section (mod, &adjusted, &bias);
+ if (scn == NULL)
+ error (EXIT_FAILURE, 0, "%#" PRIx64 ": dwfl_module_address_section: %s",
+ address, dwfl_errmsg (-1));
+ printf ("address %#" PRIx64 " => module \"%s\" section %zu + %#" PRIx64 "\n",
+ address,
+ dwfl_module_info (mod, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ elf_ndxscn (scn), adjusted);
+}
+
+int
+main (int argc, char **argv)
+{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Set locale. */
+ (void) setlocale (LC_ALL, "");
+
+ int remaining;
+ Dwfl *dwfl = NULL;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (dwfl != NULL);
+
+ int result = 0;
+ for (; remaining < argc; ++remaining)
+ {
+ char *endp;
+ uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
+ if (endp != argv[remaining])
+ handle_address (dwfl, addr);
+ else
+ result = 1;
+ }
+
+ dwfl_end (dwfl);
+
+ return result;
+}
diff --git a/tests/get-files.c b/tests/get-files.c
index 69dd77ee..81daea27 100644
--- a/tests/get-files.c
+++ b/tests/get-files.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
+/* Copyright (C) 2002, 2004, 2005, 2007 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <[email protected]>, 2002.
@@ -84,6 +84,22 @@ main (int argc, char *argv[])
break;
}
+ const char *const *dirs;
+ size_t ndirs;
+ if (dwarf_getsrcdirs (files, &dirs, &ndirs) != 0)
+ {
+ printf ("%s: cannot get include directories\n", argv[cnt]);
+ result = 1;
+ break;
+ }
+
+ if (dirs[0] == NULL)
+ puts (" dirs[0] = (null)");
+ else
+ printf (" dirs[0] = \"%s\"\n", dirs[0]);
+ for (size_t i = 1; i < ndirs; ++i)
+ printf (" dirs[%zu] = \"%s\"\n", i, dirs[i]);
+
for (size_t i = 0; i < nfiles; ++i)
printf (" file[%zu] = \"%s\"\n", i,
dwarf_filesrc (files, i, NULL, NULL));
diff --git a/tests/run-get-files.sh b/tests/run-get-files.sh
index e301f8d4..7d51f5fc 100755
--- a/tests/run-get-files.sh
+++ b/tests/run-get-files.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2000, 2002, 2004, 2005 Red Hat, Inc.
+# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2007 Red Hat, Inc.
# This file is part of Red Hat elfutils.
# Written by Ulrich Drepper <[email protected]>, 1999.
#
@@ -30,9 +30,11 @@ testfiles testfile testfile2
testrun_compare ./get-files testfile testfile2 <<\EOF
cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
file[0] = "???"
file[1] = "/home/drepper/gnu/new-bu/build/ttt/m.c"
cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
file[0] = "???"
file[1] = "/home/drepper/gnu/new-bu/build/ttt/b.c"
file[2] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h"
@@ -46,9 +48,11 @@ cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
file[10] = "/usr/include/_G_config.h"
file[11] = "/usr/include/gconv.h"
cuhl = 11, o = 412, asz = 4, osz = 4, ncu = 5752
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
file[0] = "???"
file[1] = "/home/drepper/gnu/new-bu/build/ttt/f.c"
cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
+ dirs[0] = "/shoggoth/drepper"
file[0] = "???"
file[1] = "/shoggoth/drepper/b.c"
file[2] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stddef.h"
@@ -59,9 +63,11 @@ cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
file[7] = "/usr/include/libio.h"
file[8] = "/usr/include/_G_config.h"
cuhl = 11, o = 213, asz = 4, osz = 4, ncu = 2521
+ dirs[0] = "/shoggoth/drepper"
file[0] = "???"
file[1] = "/shoggoth/drepper/f.c"
cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
+ dirs[0] = "/shoggoth/drepper"
file[0] = "???"
file[1] = "/shoggoth/drepper/m.c"
EOF