libbacktrace: use ELF symbol table if no debug info available

PR libbacktrace/97080
	* fileline.c (backtrace_syminfo_to_full_callback): New function.
	(backtrace_syminfo_to_full_error_callback): New function.
	* elf.c (elf_nodebug): Call syminfo_fn if possible.
	* internal.h (struct backtrace_call_full): Define.
	(backtrace_syminfo_to_full_callback): Declare.
	(backtrace_syminfo_to_full_error_callback): Declare.
	* mtest.c (f3): Only check all[i] if data.index permits.
This commit is contained in:
Ian Lance Taylor
2020-09-16 17:03:52 -07:00
parent 753968c2e8
commit c8a81d4e3a
4 changed files with 115 additions and 39 deletions

63
mtest.c
View File

@@ -156,40 +156,49 @@ f3 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
}
}
if (all[0].function == NULL)
if (data.index > 0)
{
fprintf (stderr, "test1: [0]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[0].function, "f3") != 0)
{
fprintf (stderr, "test1: [0]: got %s expected %s\n",
all[0].function, "f3");
data.failed = 1;
if (all[0].function == NULL)
{
fprintf (stderr, "test1: [0]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[0].function, "f3") != 0)
{
fprintf (stderr, "test1: [0]: got %s expected %s\n",
all[0].function, "f3");
data.failed = 1;
}
}
if (all[1].function == NULL)
if (data.index > 1)
{
fprintf (stderr, "test1: [1]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[1].function, "f2") != 0)
{
fprintf (stderr, "test1: [1]: got %s expected %s\n",
all[0].function, "f2");
data.failed = 1;
if (all[1].function == NULL)
{
fprintf (stderr, "test1: [1]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[1].function, "f2") != 0)
{
fprintf (stderr, "test1: [1]: got %s expected %s\n",
all[0].function, "f2");
data.failed = 1;
}
}
if (all[2].function == NULL)
if (data.index > 2)
{
fprintf (stderr, "test1: [2]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[2].function, "test1") != 0)
{
fprintf (stderr, "test1: [2]: got %s expected %s\n",
all[0].function, "test1");
data.failed = 1;
if (all[2].function == NULL)
{
fprintf (stderr, "test1: [2]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[2].function, "test1") != 0)
{
fprintf (stderr, "test1: [2]: got %s expected %s\n",
all[0].function, "test1");
data.failed = 1;
}
}
printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");