From f23cc89ec0466aa5a99a58eb4a3400056ad7f74c Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 22 Dec 2016 13:47:19 +0100 Subject: [PATCH] Fixes for CL output --- libr/bin/dbginfo.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libr/bin/dbginfo.c b/libr/bin/dbginfo.c index 43bda37c9a..98581068d5 100644 --- a/libr/bin/dbginfo.c +++ b/libr/bin/dbginfo.c @@ -23,7 +23,7 @@ R_API char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) { char file[4096]; int line; char *out = NULL, *out2 = NULL; - char *file_nopath; + char *file_nopath = NULL; { char *key = r_str_newf ("0x%"PFMT64x, addr); @@ -32,15 +32,28 @@ R_API char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) { char *token = strchr (file_line, '|'); if (token) { *token ++ = 0; - int line = atoi (token); + line = atoi (token); out = r_file_slurp_line (file_line, line, 0); + *token ++ = ':'; } - free (file_line); } free (key); if (out) { - return out; + if (origin > 1) { + file_nopath = file_line; + } else { + file_nopath = strrchr (file_line, '/'); + if (file_nopath) { + file_nopath ++; + } + } + char *res = r_str_newf ("%s:%d%s%s", + file_nopath, line, (file_nopath)? " ": "", + (out)? out: ""); + free (out); + return res; } + free (file_line); } file[0] = 0; if (r_bin_addr2line (bin, addr, file, sizeof (file), &line)) {