aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace/btest.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2013-11-16 18:20:33 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-11-16 18:20:33 +0000
commitcfa658e4f8da804086f3076f907fcc98604bbf0d (patch)
tree72f7254511f0fff93ad456661a8f4146957fca1f /libbacktrace/btest.c
parentb032ec0d5039e2dcd878ab82d74e3a79e94687d5 (diff)
downloadgcc-cfa658e4f8da804086f3076f907fcc98604bbf0d.zip
gcc-cfa658e4f8da804086f3076f907fcc98604bbf0d.tar.gz
gcc-cfa658e4f8da804086f3076f907fcc98604bbf0d.tar.bz2
backtrace.h (backtrace_syminfo): Update comment and parameter name to take any address, not just a PC value.
* backtrace.h (backtrace_syminfo): Update comment and parameter name to take any address, not just a PC value. * elf.c (STT_OBJECT): Define. (elf_nosyms): Rename parameter pc to addr. (elf_symbol_search): Rename local variable pc to addr. (elf_initialize_syminfo): Add STT_OBJECT symbols to elf_symbols. (elf_syminfo): Rename parameter pc to addr. * btest.c (global): New global variable. (test5): New test. (main): Call test5. From-SVN: r204904
Diffstat (limited to 'libbacktrace/btest.c')
-rw-r--r--libbacktrace/btest.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index cc647b8..c06493f 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -598,6 +598,53 @@ f33 (int f1line, int f2line)
return failures;
}
+int global = 1;
+
+static int
+test5 (void)
+{
+ struct symdata symdata;
+ int i;
+
+ symdata.name = NULL;
+ symdata.val = 0;
+ symdata.failed = 0;
+
+ i = backtrace_syminfo (state, (uintptr_t) &global, callback_three,
+ error_callback_three, &symdata);
+ if (i == 0)
+ {
+ fprintf (stderr,
+ "test5: unexpected return value from backtrace_syminfo %d\n",
+ i);
+ symdata.failed = 1;
+ }
+
+ if (!symdata.failed)
+ {
+ if (symdata.name == NULL)
+ {
+ fprintf (stderr, "test5: NULL syminfo name\n");
+ symdata.failed = 1;
+ }
+ else if (strcmp (symdata.name, "global") != 0)
+ {
+ fprintf (stderr,
+ "test5: unexpected syminfo name got %s expected %s\n",
+ symdata.name, "global");
+ symdata.failed = 1;
+ }
+ }
+
+ printf ("%s: backtrace_syminfo variable\n",
+ symdata.failed ? "FAIL" : "PASS");
+
+ if (symdata.failed)
+ ++failures;
+
+ return failures;
+}
+
static void
error_callback_create (void *data ATTRIBUTE_UNUSED, const char *msg,
int errnum)
@@ -622,6 +669,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
test2 ();
test3 ();
test4 ();
+ test5 ();
#endif
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);