aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--ltrace-elf.c16
-rw-r--r--output.c23
-rw-r--r--testsuite/ltrace.main/parameters2.exp29
4 files changed, 56 insertions, 18 deletions
diff --git a/NEWS b/NEWS
index debcecf..2bd3cfc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,16 @@
-*-org-*-
* Version 0.7.2
+** Bugfixes
*** (Again) detect VDSO entry in r_debug linkmap with non-empty name
This bug caused messages like:
| Couldn't determine base address of linux-vdso32.so.1
| Couldn't load ELF object linux-vdso32.so.1: No such file or directory
*** Fix building with libunwind 1.1
+*** Fix prototype lookup for -x symbols from shared libraries
+ Ltrace was unable to find prototypes of static symbols in shared
+ libraries. It changed the symbol name internally to the form
+ name@libfoo.so. Thus mangled, symbols were not found in config
+ files.
* Version 0.7.1
** Bugfixes
diff --git a/ltrace-elf.c b/ltrace-elf.c
index f4a58a5..c571d2a 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -647,7 +647,6 @@ populate_this_symtab(struct Process *proc, const char *filename,
secflags[i] = shdr.sh_flags;
}
- size_t lib_len = strlen(lib->soname);
for (i = 0; i < size; ++i) {
GElf_Sym sym;
if (gelf_getsym(symtab, i, &sym) == NULL) {
@@ -717,20 +716,13 @@ populate_this_symtab(struct Process *proc, const char *filename,
char *full_name;
int own_full_name = 1;
- if (lib->type != LT_LIBTYPE_MAIN) {
- full_name = malloc(strlen(name) + 1 + lib_len + 1);
+ if (name_copy == NULL) {
+ full_name = strdup(name);
if (full_name == NULL)
goto fail;
- sprintf(full_name, "%s@%s", name, lib->soname);
} else {
- if (name_copy == NULL) {
- full_name = strdup(name);
- if (full_name == NULL)
- goto fail;
- } else {
- full_name = name_copy;
- own_full_name = 0;
- }
+ full_name = name_copy;
+ own_full_name = 0;
}
/* Look whether we already have a symbol for this
diff --git a/output.c b/output.c
index 9df8ae1..1d01d31 100644
--- a/output.c
+++ b/output.c
@@ -442,8 +442,10 @@ output_left(enum tof type, struct Process *proc,
begin_of_line(proc, type == LT_TOF_FUNCTION, 1);
if (!options.hide_caller && libsym->lib != NULL
&& libsym->plt_type != LS_TOPLT_NONE)
- current_column += fprintf(options.output, "%s->",
- libsym->lib->soname);
+ /* We don't terribly mind failing this. */
+ account_output(&current_column,
+ fprintf(options.output, "%s->",
+ libsym->lib->soname));
const char *name = function_name;
#ifdef USE_DEMANGLE
@@ -451,12 +453,25 @@ output_left(enum tof type, struct Process *proc,
name = my_demangle(function_name);
#endif
if (account_output(&current_column,
- fprintf(options.output, "%s(", name)) < 0)
+ fprintf(options.output, "%s", name)) < 0)
return;
+ if (libsym->lib != NULL
+ && libsym->lib->type != LT_LIBTYPE_MAIN
+ && libsym->plt_type == LS_TOPLT_NONE
+ && account_output(&current_column,
+ fprintf(options.output, "@%s",
+ libsym->lib->soname)) < 0)
+ /* We do mind failing this though. */
+ return;
+
+ account_output(&current_column, fprintf(options.output, "("));
+
func = name2func(function_name);
- if (func == NULL)
+ if (func == NULL) {
+ account_output(&current_column, fprintf(options.output, "???"));
return;
+ }
struct fetch_context *context = fetch_arg_init(type, proc,
func->return_info);
diff --git a/testsuite/ltrace.main/parameters2.exp b/testsuite/ltrace.main/parameters2.exp
index ca57f61..8443fb6 100644
--- a/testsuite/ltrace.main/parameters2.exp
+++ b/testsuite/ltrace.main/parameters2.exp
@@ -119,16 +119,19 @@ ltraceMatch1 [ltraceRun -F $conf -e ll -A 5 \
}
}]]] {->ll\({ 9, { 8, { 7, { 6, { 5, \.\.\. } } } } }\) *= <void>} == 1
-proc ltraceParamTest {conf cdecl libcode maincode match} {
+proc ltraceParamTest {conf cdecl libcode maincode match {params ""}} {
set conffile [ltraceSource conf $conf]
set lib [ltraceCompile liblib.so [ltraceSource c [concat $cdecl $libcode]]]
set bin [ltraceCompile {} $lib \
[ltraceSource c \
[concat $cdecl "int main(void) {" $maincode "}"]]]
- return [ltraceMatch [ltraceRun -F $conffile -- $bin] $match]
+ set command [concat "ltraceRun -F $conffile " $params "-- $bin"]
+ return [ltraceMatch [eval $command] $match]
}
+# Test using lens in typedef.
+
ltraceParamTest {
typedef hexptr = hex(uint*);
void fun(hexptr);
@@ -143,6 +146,8 @@ ltraceParamTest {
{{fun\(0x123\) *= <void>} == 1}
}
+# Test support for bitvec lens.
+
ltraceParamTest {
void fun(bitvec(uint));
void fun2(bitvec(array(char, 32)*));
@@ -170,6 +175,8 @@ ltraceParamTest {
{{fun2\(<8-15,255>\) *= <void>} == 1}
}
+# Test support for hex(float), hex(double).
+
ltraceParamTest {
hex(float) hex_float(hex(float));
hex(double) hex_double(hex(double));
@@ -187,4 +194,22 @@ ltraceParamTest {
{{hex_double\(0x1.8p\+0\) *= 0x1.4p\+1} == 1}
}
+# Test that -x fun can find "fun" prototype even if "fun" is in a
+# library.
+
+ltraceParamTest {
+ void fun();
+} {
+ void libfun(void);
+} {
+ void fun(void) {}
+ void libfun(void) { fun(); }
+} {
+ libfun();
+} {
+ {{fun@.*\(\)} == 1}
+} {
+ -L -x fun
+}
+
ltraceDone