|
From: <sv...@va...> - 2005-06-13 18:01:09
|
Author: sewardj
Date: 2005-06-13 18:39:06 +0100 (Mon, 13 Jun 2005)
New Revision: 3909
Log:
Updates to the rest of the debuginfo module to track directory names.
The only interesting part is a change of signature of
VG_(get_filename_linenum) so that callers can optionally request
directory info too.
Modified:
trunk/cachegrind/cg_main.c
trunk/coregrind/m_debuginfo/priv_symtab.h
trunk/coregrind/m_debuginfo/stabs.c
trunk/coregrind/m_debuginfo/symtab.c
trunk/coregrind/m_debuginfo/symtypes.c
trunk/helgrind/hg_main.c
trunk/include/pub_tool_debuginfo.h
Modified: trunk/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_main.c 2005-06-13 17:33:27 UTC (rev 3908)
+++ trunk/cachegrind/cg_main.c 2005-06-13 17:39:06 UTC (rev 3909)
@@ -165,8 +165,12 @@
static void get_debug_info(Addr instr_addr, Char file[FILE_LEN],
Char fn[FN_LEN], Int* line)
{
- Bool found_file_line =3D VG_(get_filename_linenum)(instr_addr, file,
- FILE_LEN, line);
+ Bool found_file_line =3D VG_(get_filename_linenum)(
+ instr_addr,=20
+ file, FILE_LEN,
+ NULL, 0, NULL,
+ line
+ );
Bool found_fn =3D VG_(get_fnname)(instr_addr, fn, FN_LEN);
=20
if (!found_file_line) {
Modified: trunk/coregrind/m_debuginfo/priv_symtab.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/priv_symtab.h 2005-06-13 17:33:27 UTC (re=
v 3908)
+++ trunk/coregrind/m_debuginfo/priv_symtab.h 2005-06-13 17:39:06 UTC (re=
v 3909)
@@ -69,7 +69,9 @@
UShort size:LOC_SIZE_BITS; /* byte size; we catch overflows of =
this */
UInt lineno:LINENO_BITS; /* source line number, or zero */
/* Word 3 */
- Char* filename; /* source filename */
+ Char* filename; /* source filename */
+ /* Word 4 */
+ Char* dirname; /* source directory name */
}
RiLoc;
=20
@@ -231,7 +233,10 @@
=20
Char *VG_(addStr) ( SegInfo* si, Char* str, Int len );
void VG_(addScopeInfo) ( SegInfo* si, Addr this, Addr next, Scope *scope=
);
-void VG_(addLineInfo) ( SegInfo* si, Char* filename, Addr this, Addr nex=
t, Int lineno, Int entry);
+void VG_(addLineInfo) ( SegInfo* si,=20
+ Char* filename,=20
+ Char* dirname, /* NULL is allowable */
+ Addr this, Addr next, Int lineno, Int entry);
void VG_(addCfiSI) ( SegInfo* si, CfiSI* cfisi );
=20
/* Non-fatal -- use vg_panic if terminal. */
Modified: trunk/coregrind/m_debuginfo/stabs.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/stabs.c 2005-06-13 17:33:27 UTC (rev 3908=
)
+++ trunk/coregrind/m_debuginfo/stabs.c 2005-06-13 17:39:06 UTC (rev 3909=
)
@@ -1414,7 +1414,7 @@
=20
if (line.addr !=3D 0) {
/* finish off previous line */
- VG_(addLineInfo)(si, file.name, line.addr,
+ VG_(addLineInfo)(si, file.name, NULL, line.addr,
addr, line.no + line.ovf * LINENO_OVERFLOW, i);
}
=20
@@ -1446,7 +1446,7 @@
=20
if (line.addr !=3D 0) {
/* there was a previous */
- VG_(addLineInfo)(si, file.name, line.addr,
+ VG_(addLineInfo)(si, file.name, NULL, line.addr,
addr, line.no + line.ovf * LINENO_OVERFLOW, i);
}
=20
@@ -1555,7 +1555,7 @@
}
=20
if (line.addr) {
- VG_(addLineInfo)(si, file.name, line.addr,
+ VG_(addLineInfo)(si, file.name, NULL, line.addr,
addr, line.no + line.ovf * LINENO_OVERFLOW, i);
line.addr =3D 0;
}
Modified: trunk/coregrind/m_debuginfo/symtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/symtab.c 2005-06-13 17:33:27 UTC (rev 390=
8)
+++ trunk/coregrind/m_debuginfo/symtab.c 2005-06-13 17:39:06 UTC (rev 390=
9)
@@ -248,11 +248,12 @@
=20
void VG_(addLineInfo) ( SegInfo* si,
Char* filename,
+ Char* dirname, /* NULL =3D=3D directory is unknown */
Addr this,
Addr next,
Int lineno,
Int entry /* only needed for debug printing */
- )
+ )
{
static const Bool debug =3D False;
RiLoc loc;
@@ -262,7 +263,9 @@
if (this =3D=3D next) return;
=20
if (debug)
- VG_(printf)(" src %s line %d %p-%p\n", filename, lineno, this, ne=
xt);
+ VG_(printf)( " src %s %s line %d %p-%p\n",
+ dirname ? dirname : (Char*)"(unknown)",
+ filename, lineno, this, next );
=20
/* Maximum sanity checking. Some versions of GNU as do a shabby
* job with stabs entries; if anything looks suspicious, revert to
@@ -314,6 +317,7 @@
loc.size =3D (UShort)size;
loc.lineno =3D lineno;
loc.filename =3D filename;
+ loc.dirname =3D dirname;
=20
if (0) VG_(message)(Vg_DebugMsg,=20
"addLoc: addr %p, size %d, line %d, file %s",
@@ -2242,21 +2246,43 @@
return True;
}
=20
-/* Map a code address to a (filename, line number) pair. =20
- Returns True if successful.
+/* Map a code address to a filename/line number/dir name info.
+ See prototype for detailed description of behaviour.
*/
-Bool VG_(get_filename_linenum)( Addr a,=20
- Char* filename, Int n_filename,=20
- UInt* lineno )
+Bool VG_(get_filename_linenum) ( Addr a,=20
+ /*OUT*/Char* filename, Int n_filename,
+ /*OUT*/Char* dirname, Int n_dirname,
+ /*OUT*/Bool* dirname_available,
+ /*OUT*/UInt* lineno )
{
SegInfo* si;
Int locno;
+
+ vg_assert( (dirname =3D=3D NULL && dirname_available =3D=3D NULL)
+ ||
+ (dirname !=3D NULL && dirname_available !=3D NULL) );
+
search_all_loctabs ( a, &si, &locno );
if (si =3D=3D NULL)=20
return False;
VG_(strncpy_safely)(filename, si->loctab[locno].filename, n_filename)=
;
*lineno =3D si->loctab[locno].lineno;
=20
+ if (dirname) {
+ /* caller wants directory info too .. */
+ vg_assert(n_dirname > 0);
+ if (si->loctab[locno].dirname) {
+ /* .. and we have some */
+ *dirname_available =3D True;
+ VG_(strncpy_safely)(dirname, si->loctab[locno].dirname,
+ n_dirname);
+ } else {
+ /* .. but we don't have any */
+ *dirname_available =3D False;
+ *dirname =3D 0;
+ }
+ }
+
return True;
}
=20
@@ -2267,7 +2293,7 @@
static Addr regaddr_from_tst(Int regno, ThreadArchState *arch)
{
#if defined(VGA_x86)
-/* This is the Intel register encoding -- integer regs. */
+ /* This is the Intel register encoding -- integer regs. */
# define R_STACK_PTR 4
# define R_FRAME_PTR 5
switch (regno) {
@@ -2282,7 +2308,7 @@
default: return 0;
}
#elif defined(VGA_amd64)
-/* This is the Intel register encoding -- integer regs. */
+ /* This is the AMD64 register encoding -- integer regs. */
# define R_STACK_PTR 7
# define R_FRAME_PTR 6
switch (regno) {
@@ -2358,7 +2384,8 @@
Char file[100];
Int line;
=20
- if (!VG_(get_filename_linenum)(sr->addr, file, sizeof(file), &line=
))
+ if (!VG_(get_filename_linenum)(sr->addr, file, sizeof(file),=20
+ NULL, 0, NULL, &lin=
e))
file[0] =3D 0;
=20
VG_(printf)("found scope range %p: eip=3D%p (%s:%d) size=3D%d scop=
e=3D%p\n",
@@ -2366,7 +2393,9 @@
}
=20
distance =3D 0;
- for(scope =3D si->scopetab[scopeidx].scope; scope !=3D NULL; scope =3D=
scope->outer, distance++) {
+ for (scope =3D si->scopetab[scopeidx].scope;=20
+ scope !=3D NULL;=20
+ scope =3D scope->outer, distance++) {
UInt i;
=20
for(i =3D 0; i < scope->nsyms; i++) {
@@ -2435,6 +2464,10 @@
=20
return list;
}
+
+# undef R_STACK_PTR
+# undef R_FRAME_PTR
+
#endif /* TEST */
=20
/* Print into buf info on code address, function name and filename */
@@ -2477,11 +2510,16 @@
static UChar buf_fn[BUF_LEN];
static UChar buf_obj[BUF_LEN];
static UChar buf_srcloc[BUF_LEN];
+ static UChar buf_dirname[BUF_LEN];
+ Bool know_dirinfo =3D False;
Bool know_fnname =3D VG_(get_fnname) (eip, buf_fn, BUF_LEN);
Bool know_objname =3D VG_(get_objname)(eip, buf_obj, BUF_LEN);
- Bool know_srcloc =3D VG_(get_filename_linenum)(eip, buf_srcloc,
- BUF_LEN, &lineno);
-
+ Bool know_srcloc =3D VG_(get_filename_linenum)(
+ eip,=20
+ buf_srcloc, BUF_LEN,=20
+ buf_dirname, BUF_LEN, &know_dirinfo,
+ &lineno=20
+ );
if (VG_(clo_xml)) {
=20
Bool human_readable =3D True;
@@ -2506,6 +2544,12 @@
APPEND("</fn>");
}
if (know_srcloc) {
+ if (know_dirinfo) {
+ APPEND(maybe_newline);
+ APPEND("<dir>");
+ APPEND(buf_dirname);
+ APPEND("</dir>");
+ }
APPEND(maybe_newline);
APPEND("<file>");
APPEND_ESC(buf_srcloc);
@@ -2552,6 +2596,7 @@
=20
# undef APPEND
# undef APPEND_ESC
+# undef BUF_LEN
}
=20
/* Returns True if OK. If not OK, *{ip,sp,fp}P are not changed. */
Modified: trunk/coregrind/m_debuginfo/symtypes.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/symtypes.c 2005-06-13 17:33:27 UTC (rev 3=
908)
+++ trunk/coregrind/m_debuginfo/symtypes.c 2005-06-13 17:39:06 UTC (rev 3=
909)
@@ -737,7 +737,8 @@
if (debug) {
Char file[100];
Int line;
- if (!VG_(get_filename_linenum)(eip, file, sizeof(file), &line))
+ if (!VG_(get_filename_linenum)(eip, file, sizeof(file),=20
+ NULL, 0, NULL, &line))
file[0] =3D 0;
VG_(printf)("describing address %p for tid=3D%d @ %s:%d\n", addr, =
tid, file, line);
}
@@ -1047,7 +1048,8 @@
if (addr !=3D found->valuep)
bprintf(describe_addr_addbuf, 0, "+%d", addr - found->valuep);
=20
- if (VG_(get_filename_linenum)(eip, file, sizeof(file), &line))
+ if (VG_(get_filename_linenum)(eip, file, sizeof(file),=20
+ NULL, 0, NULL, &line))
bprintf(describe_addr_addbuf, 0, " at %s:%d", file, line, addr);
}
}
Modified: trunk/helgrind/hg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/helgrind/hg_main.c 2005-06-13 17:33:27 UTC (rev 3908)
+++ trunk/helgrind/hg_main.c 2005-06-13 17:39:06 UTC (rev 3909)
@@ -2730,7 +2730,8 @@
pp_state(extra->lasttouched.state),
unpackTLS(extra->lasttouched.tls)->tid);
=20
- if (VG_(get_filename_linenum)(ip, file, sizeof(file), &line)) {
+ if (VG_(get_filename_linenum)(ip, file, sizeof(file),=20
+ NULL, 0, NULL, &line)) {
VG_(message)(Vg_UserMsg, " at %p: %y (%s:%u)",
ip, ip, file, line);
} else if (VG_(get_objname)(ip, file, sizeof(file))) {
Modified: trunk/include/pub_tool_debuginfo.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_debuginfo.h 2005-06-13 17:33:27 UTC (rev 3908)
+++ trunk/include/pub_tool_debuginfo.h 2005-06-13 17:39:06 UTC (rev 3909)
@@ -47,11 +47,23 @@
extern Bool VG_(get_fnname_w_offset)
( Addr a, Char* fnname, Int n_fnname )=
;
=20
-/* This one is more efficient if getting both filename and line number,
- because the two lookups are done together. */
+/* 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 it, 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.
+
+ Returned value indicates whether any filename/line info could be
+ found. */
extern Bool VG_(get_filename_linenum)
- ( Addr a, Char* filename, Int n_filename,
- UInt* linenum );
+ ( Addr a,=20
+ /*OUT*/Char* filename, Int n_filename,
+ /*OUT*/Char* dirname, Int n_dirname,
+ /*OUT*/Bool* dirname_available,
+ /*OUT*/UInt* linenum );
=20
/* Succeeds only if we find from debug info that 'a' is the address of t=
he
first instruction in a function -- as opposed to VG_(get_fnname) whic=
h
|