From: Florian Krohm Date: Tue, 16 Dec 2014 20:55:58 +0000 (+0000) Subject: Simplify the VG_(get_filename_linenum) interface by removing X-Git-Tag: svn/VALGRIND_3_11_0~772 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=115f5cd39930e5b253db1581e950eb4fda475cc4;p=thirdparty%2Fvalgrind.git Simplify the VG_(get_filename_linenum) interface by removing the dirname_available parameter. It's redundant. The value of the returned directory name can be tested instead. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14814 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 559eea910a..685b973e71 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -210,10 +210,9 @@ static HChar* get_perm_string(const HChar* s) static void get_debug_info(Addr instr_addr, const HChar **dir, const HChar **file, const HChar **fn, UInt* line) { - Bool found_dirname; Bool found_file_line = VG_(get_filename_linenum)( instr_addr, - file, dir, &found_dirname, + file, dir, line ); Bool found_fn = VG_(get_fnname)(instr_addr, fn); diff --git a/callgrind/dump.c b/callgrind/dump.c index 687f4df1ea..687561431b 100644 --- a/callgrind/dump.c +++ b/callgrind/dump.c @@ -363,7 +363,7 @@ static /* __inline__ */ Bool get_debug_pos(BBCC* bbcc, Addr addr, AddrPos* p) { const HChar *file, *dir; - Bool found_file_line, found_dirname; + Bool found_file_line; int cachepos = addr % DEBUG_CACHE_SIZE; @@ -376,7 +376,6 @@ Bool get_debug_pos(BBCC* bbcc, Addr addr, AddrPos* p) found_file_line = VG_(get_filename_linenum)(addr, &file, &dir, - &found_dirname, &(p->line)); if (!found_file_line) { file = "???"; diff --git a/callgrind/fn.c b/callgrind/fn.c index b6dff08ded..c348fd77d1 100644 --- a/callgrind/fn.c +++ b/callgrind/fn.c @@ -429,7 +429,7 @@ Bool CLG_(get_debug_info)(Addr instr_addr, const HChar **fn_name, UInt* line_num, DebugInfo** pDebugInfo) { - Bool found_file_line, found_fn, found_dirname, result = True; + Bool found_file_line, found_fn, result = True; UInt line; CLG_DEBUG(6, " + get_debug_info(%#lx)\n", instr_addr); @@ -443,7 +443,6 @@ Bool CLG_(get_debug_info)(Addr instr_addr, found_file_line = VG_(get_filename_linenum)(instr_addr, file, dir, - &found_dirname, &line); found_fn = VG_(get_fnname)(instr_addr, fn_name); diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 8df866d492..e8df79c2d5 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -2067,21 +2067,15 @@ Bool VG_(get_linenum)( Addr a, UInt* lineno ) Bool VG_(get_filename_linenum) ( Addr a, /*OUT*/const HChar** filename, /*OUT*/const HChar** dirname, - /*OUT*/Bool* dirname_available, /*OUT*/UInt* lineno ) { DebugInfo* si; Word locno; UInt fndn_ix; - vg_assert( (dirname == NULL && dirname_available == NULL) - || - (dirname != NULL && dirname_available != NULL) ); - search_all_loctabs ( a, &si, &locno ); if (si == NULL) { - if (dirname_available) { - *dirname_available = False; + if (dirname) { *dirname = ""; } *filename = ""; // this used to be not initialised.... @@ -2095,7 +2089,6 @@ Bool VG_(get_filename_linenum) ( Addr a, if (dirname) { /* caller wants directory info too .. */ *dirname = ML_(fndn_ix2dirname) (si, fndn_ix); - *dirname_available = (*dirname)[0] != '\0'; } return True; @@ -2258,9 +2251,10 @@ const HChar* VG_(describe_IP)(Addr eip, const InlIPCursor *iipc) know_srcloc = VG_(get_filename_linenum)( eip, &buf_srcloc, - &buf_dirname, &know_dirinfo, + &buf_dirname, &lineno ); + know_dirinfo = buf_dirname[0] != '\0'; } else { const DiInlLoc *cur_inl = iipc && iipc->cur_inltab >= 0 ? & iipc->di->inltab[iipc->cur_inltab] diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 4ddf8a3504..c45b147bbd 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -2003,7 +2003,7 @@ void do_client_request ( ThreadId tid ) VG_(memset)(buf64, 0, 64); UInt linenum = 0; Bool ok = VG_(get_filename_linenum)( - ip, &buf, NULL, NULL, &linenum + ip, &buf, NULL, &linenum ); if (ok) { /* For backward compatibility truncate the filename to diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h index 95b203acdb..91f375178f 100644 --- a/include/pub_tool_debuginfo.h +++ b/include/pub_tool_debuginfo.h @@ -52,11 +52,10 @@ extern Bool VG_(get_fnname_w_offset) /* This one is the most general. It gives filename, line number and optionally directory name. filename and linenum may not be NULL. dirname may be NULL, meaning that the caller does not want - directory name info, in which case dirname_available must also be - NULL. If dirname is non-null, directory info is written to *dirname, if + directory name info. + If dirname is non-null, directory info is written to *dirname, if it is available; if not available, '\0' is written to the first - byte. In either case *dirname_available is set to indicate whether - or not directory information was available. + byte. The character strings returned in *filename and *dirname are not persistent. They will be freed when the DebugInfo they belong to @@ -68,7 +67,6 @@ extern Bool VG_(get_filename_linenum) ( Addr a, /*OUT*/const HChar** filename, /*OUT*/const HChar** dirname, - /*OUT*/Bool* dirname_available, /*OUT*/UInt* linenum ); /* Succeeds only if we find from debug info that 'a' is the address of the