|
From: <sv...@va...> - 2009-07-27 12:03:22
|
Author: bart
Date: 2009-07-27 13:03:03 +0100 (Mon, 27 Jul 2009)
New Revision: 10632
Log:
Fixed a bug in the code for reading suppression files: the line numbers
reported in error messages were not correct. As an example, the following
output was produced before this patch (not correct):
$ ./vg-in-place --tool=helgrind --num-callers=1 /bin/true
...
FATAL: in suppressions file ".in_place/default.supp" near line 893:
suppression must contain at least one location line which is not "..."
exiting now.
$ ./vg-in-place --tool=drd --num-callers=1 /bin/true
FATAL: in suppressions file ".in_place/default.supp" near line 475:
suppression must contain at least one location line which is not "..."
exiting now.
After having applied this patch the above commands display line numbers
1104 and 619, referring to the first suppression pattern containing
three dots for the topmost stack frame, as expected.
Modified:
trunk/coregrind/m_errormgr.c
trunk/exp-ptrcheck/pc_common.c
trunk/include/pub_tool_errormgr.h
trunk/memcheck/mc_errors.c
Modified: trunk/coregrind/m_errormgr.c
===================================================================
--- trunk/coregrind/m_errormgr.c 2009-07-27 08:30:52 UTC (rev 10631)
+++ trunk/coregrind/m_errormgr.c 2009-07-27 12:03:03 UTC (rev 10632)
@@ -964,7 +964,7 @@
return 1;
}
-Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp )
+Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno )
{
Char* buf = *bufpp;
SizeT nBuf = *nBufp;
@@ -975,6 +975,8 @@
while (True) {
n = get_char(fd, &ch);
if (n == 1 && !VG_(isspace)(ch)) break;
+ if (n == 1 && ch == '\n' && lineno)
+ (*lineno)++;
if (n <= 0) return True;
}
@@ -984,6 +986,8 @@
while (True) {
n = get_char(fd, &ch);
if (n <= 0) return False; /* the next call will return True */
+ if (ch == '\n' && lineno)
+ (*lineno)++;
if (ch == '\n') break;
if (i > 0 && i == nBuf-1) {
*nBufp = nBuf = nBuf * 2;
@@ -1103,21 +1107,18 @@
supp->string = supp->extra = NULL;
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) break;
if (!VG_STREQ(buf, "{")) BOMB("expected '{' or end-of-file");
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) BOMB("unexpected end-of-file");
@@ -1155,8 +1156,7 @@
else {
// Ignore rest of suppression
while (True) {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) BOMB("unexpected end-of-file");
if (VG_STREQ(buf, "}"))
break;
@@ -1174,8 +1174,7 @@
/* the main frame-descriptor reading loop */
i = 0;
while (True) {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof)
BOMB("unexpected end-of-file");
if (VG_STREQ(buf, "}")) {
@@ -1201,8 +1200,7 @@
// lines and grab the '}'.
if (!VG_STREQ(buf, "}")) {
do {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
} while (!eof && !VG_STREQ(buf, "}"));
}
Modified: trunk/exp-ptrcheck/pc_common.c
===================================================================
--- trunk/exp-ptrcheck/pc_common.c 2009-07-27 08:30:52 UTC (rev 10631)
+++ trunk/exp-ptrcheck/pc_common.c 2009-07-27 12:03:03 UTC (rev 10632)
@@ -741,7 +741,7 @@
{
Bool eof;
if (VG_(get_supp_kind)(su) == XS_SysParam) {
- eof = VG_(get_line) ( fd, bufpp, nBufp );
+ eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
if (eof) return False;
VG_(set_supp_string)(su, VG_(strdup)("pc.common.presi.1", *bufpp));
}
Modified: trunk/include/pub_tool_errormgr.h
===================================================================
--- trunk/include/pub_tool_errormgr.h 2009-07-27 08:30:52 UTC (rev 10631)
+++ trunk/include/pub_tool_errormgr.h 2009-07-27 12:03:03 UTC (rev 10632)
@@ -92,8 +92,9 @@
pointer to size_t holding its size; if the buffer is too small for the
line, it will be realloc'd until big enough (updating *bufpp and *nBufp in
the process). (It will bomb out if the size gets ridiculous). Skips
- leading spaces on the line. Returns True if EOF was hit instead. */
-extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp );
+ leading spaces on the line. Increments lineno with the number of lines
+ read if lineno is non-NULL. Returns True if EOF was hit. */
+extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno );
/* ------------------------------------------------------------------ */
Modified: trunk/memcheck/mc_errors.c
===================================================================
--- trunk/memcheck/mc_errors.c 2009-07-27 08:30:52 UTC (rev 10631)
+++ trunk/memcheck/mc_errors.c 2009-07-27 12:03:03 UTC (rev 10632)
@@ -1390,7 +1390,7 @@
Bool eof;
if (VG_(get_supp_kind)(su) == ParamSupp) {
- eof = VG_(get_line) ( fd, bufpp, nBufp );
+ eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
if (eof) return False;
VG_(set_supp_string)(su, VG_(strdup)("mc.resi.1", *bufpp));
}
|
|
From: Julian S. <js...@ac...> - 2009-07-27 13:20:55
|
> Fixed a bug in the code for reading suppression files: the line numbers > reported in error messages were not correct. [...] Great stuff. I'm not surprised the line numbers were wrong; I remember hacking up the line number logic in a hurry. J |