summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2005-10-28 06:56:24 +0000
committerRoland McGrath <[email protected]>2005-10-28 06:56:24 +0000
commit07d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60 (patch)
tree0cd998a48772a7857dc187899cb5bb1f8decc35b /tests
parent89757447dbcd0ac946db345fa6aa1edc76a37a11 (diff)
libdw/
Fixes to last changes. tests/ 2005-10-27 Roland McGrath <[email protected]> * run-find-prologues.sh: New file. * Makefile.am (TESTS, EXTRA_DIST): Add it.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog13
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/find-prologues.c106
-rwxr-xr-xtests/run-find-prologues.sh65
4 files changed, 189 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ec47a31d..37da62c6 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,16 @@
+2005-10-27 Roland McGrath <[email protected]>
+
+ * run-find-prologues.sh: New file.
+ * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
+ * find-prologues.c (handle_function): Skip inlines.
+
+2005-10-25 Roland McGrath <[email protected]>
+
+ * find-prologues.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (find_prologues_LDADD): New variable.
+
2005-09-02 Ulrich Drepper <[email protected]>
* run-strings-test.sh: Remove strings.out in the end.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 119e11d7..01d7b6ad 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -33,7 +33,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
get-aranges allfcts line2addr addrscopes funcscopes \
show-abbrev hash asm-tst1 asm-tst2 asm-tst3 \
asm-tst4 asm-tst5 asm-tst6 asm-tst7 asm-tst8 asm-tst9 \
- msg_tst newscn ecp dwflmodtest
+ msg_tst newscn ecp dwflmodtest find-prologues
# get-ciefde
TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
@@ -47,7 +47,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \
run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
- run-addrscopes.sh run-strings-test.sh run-funcscopes.sh
+ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
+ run-find-prologues.sh
# run-show-ciefde.sh
EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
@@ -64,6 +65,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
+ run-find-prologues.sh \
testfile15.bz2 testfile15.debug.bz2 \
testfile16.bz2 testfile16.debug.bz2 \
testfile17.bz2 testfile17.debug.bz2 \
@@ -116,6 +118,7 @@ line2addr_no_Wformat = yes
line2addr_LDADD = $(libdw) $(libmudflap)
addrscopes_LDADD = $(libdw) $(libmudflap)
funcscopes_LDADD = $(libdw) $(libmudflap)
+find_prologues_LDADD = $(libdw) $(libmudflap)
#show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) $(libmudflap)
asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
diff --git a/tests/find-prologues.c b/tests/find-prologues.c
new file mode 100644
index 00000000..30404cda
--- /dev/null
+++ b/tests/find-prologues.c
@@ -0,0 +1,106 @@
+/* Test program for dwarf_entry_breakpoints.
+ Copyright (C) 2005 Red Hat, Inc.
+
+ This program is Open Source software; you can redistribute it and/or
+ modify it under the terms of the Open Software License version 1.0 as
+ published by the Open Source Initiative.
+
+ You should have received a copy of the Open Software License along
+ with this program; if not, you may obtain a copy of the Open Software
+ License version 1.0 from http://www.opensource.org/licenses/osl.php or
+ by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+ 3001 King Ranch Road, Ukiah, CA 95482. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <libdwfl.h>
+#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;
+};
+
+static int
+handle_function (Dwarf_Func *func, void *arg)
+{
+ struct args *a = arg;
+
+ const char *name = dwarf_func_name (func);
+ char **argv = a->argv;
+ if (argv[0] != NULL)
+ {
+ bool match;
+ do
+ match = fnmatch (*argv, name, 0) == 0;
+ while (!match && *++argv);
+ if (!match)
+ return 0;
+ }
+
+ Dwarf_Die funcdie_mem;
+ Dwarf_Die *funcdie = dwarf_func_die (func, &funcdie_mem);
+ assert (funcdie == &funcdie_mem);
+
+ if (dwarf_func_inline (func))
+ return 0;
+
+ Dwarf_Addr entrypc;
+ if (dwarf_entrypc (funcdie, &entrypc) != 0)
+ error (EXIT_FAILURE, 0, "dwarf_entrypc: %s: %s",
+ dwarf_diename (funcdie), dwarf_errmsg (-1));
+ entrypc += a->dwbias;
+
+ printf ("%-16s %#.16" PRIx64, dwarf_diename (funcdie), entrypc);
+
+ Dwarf_Addr *bkpts = NULL;
+ int result = dwarf_entry_breakpoints (funcdie, &bkpts);
+ if (result <= 0)
+ printf ("\t%s\n", dwarf_errmsg (-1));
+ else
+ {
+ for (int i = 0; i < result; ++i)
+ printf (" %#.16" PRIx64 "%s", bkpts[i] + a->dwbias,
+ i == result - 1 ? "\n" : "");
+ free (bkpts);
+ }
+
+ 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)
+ dwarf_getfuncs (a.cu, &handle_function, &a, 0);
+
+ return result;
+}
diff --git a/tests/run-find-prologues.sh b/tests/run-find-prologues.sh
new file mode 100755
index 00000000..3e43fc53
--- /dev/null
+++ b/tests/run-find-prologues.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+#
+# This program is Open Source software; you can redistribute it and/or
+# modify it under the terms of the Open Software License version 1.0 as
+# published by the Open Source Initiative.
+#
+# You should have received a copy of the Open Software License along
+# with this program; if not, you may obtain a copy of the Open Software
+# License version 1.0 from http://www.opensource.org/licenses/osl.php or
+# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+# 3001 King Ranch Road, Ukiah, CA 95482.
+set -e
+
+files="testfile testfile11 testfile22 testfile24 \
+testfile25 testfile3 testfile4 testfile5 testfile6"
+
+for file in $files; do
+ # Don't fail if we cannot decompress the file.
+ bunzip2 -c $srcdir/$file.bz2 > $file 2>/dev/null || exit 77
+done
+
+for file in $files; do
+ ./find-prologues -e $file || :
+done > find-prologues-test.out 2>&1
+
+diff -Bbu find-prologues-test.out - <<\EOF
+main 0x000000000804842c 0x0000000008048432
+bar 0x000000000804845c 0x000000000804845f
+foo 0x0000000008048468 0x000000000804846b
+main 0x00000000080489b8 0x00000000080489cd
+gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4
+gnu_obj_3 0x0000000008048cd8 0x0000000008048cde
+gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa
+~invalid_argument 0x0000000008048d2e 0x0000000008048d34
+gnu_obj_1 0x0000000008048d62 0x0000000008048d65
+gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d
+~invalid_argument 0x0000000008048db2 0x0000000008048db8
+function 0x0000000008048348 0x000000000804834e
+main 0x000000000804835b 0x0000000008048377
+incr 0x0000000008048348 0x000000000804834e
+main 0x0000000008048354 0x0000000008048360
+incr 0x0000000008048348 0x000000000804834c
+main 0x000000000804842c 0x0000000008048433
+bar 0x0000000008048458 0x000000000804845b
+foo 0x0000000008048464 0x0000000008048467
+get 0x00000000080493fc 0x0000000008049402
+main 0x0000000008049498 0x000000000804949e
+a 0x000000000804d85c 0x000000000804d85c
+__tfPCc 0x000000000804d86c 0x000000000804d872
+__tfCc 0x000000000804d8a4 0x000000000804d8a4
+bar 0x000000000804842c 0x000000000804842f
+foo 0x0000000008048438 0x000000000804843b
+main 0x0000000008048444 0x000000000804844a
+main 0x00000000080489b8 0x00000000080489cd
+gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4
+gnu_obj_3 0x0000000008048cd8 0x0000000008048cde
+gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa
+~invalid_argument 0x0000000008048d2e 0x0000000008048d34
+gnu_obj_1 0x0000000008048d62 0x0000000008048d65
+gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d
+~invalid_argument 0x0000000008048db2 0x0000000008048db8
+EOF
+
+rm -f find-prologues-test.out $files