From: Nicholas Nethercote Date: Thu, 13 Nov 2003 17:35:04 +0000 (+0000) Subject: Changed error messages: now don't print anything below main() unless the new X-Git-Tag: svn/VALGRIND_2_1_0~70 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d7bfd760a8bb16ec3fabe89249a9bf5a88f34919;p=thirdparty%2Fvalgrind.git Changed error messages: now don't print anything below main() unless the new option --show-below-main is on. It's on by default. It also affects suppressions generated with --gen-suppressions=yes. Updated reg tests accordingly. Also updated docs for this. And added some missing command-line args to docs. Also compartmentalised the options a little in the docs, and rearranged the order of options in the usage message, in anticipation of a bigger rearrangement that will be necessary soon -- to distinguish options used by all skins from those used by error-checking skins, to skin-specific ones. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2020 --- diff --git a/addrcheck/tests/badrw.stderr.exp b/addrcheck/tests/badrw.stderr.exp index c231c5d689..4ac32de3cb 100644 --- a/addrcheck/tests/badrw.stderr.exp +++ b/addrcheck/tests/badrw.stderr.exp @@ -1,59 +1,35 @@ Invalid read of size 4 at 0x........: main (badrw.c:12) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 4 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid write of size 4 at 0x........: main (badrw.c:12) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 4 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid read of size 2 at 0x........: main (badrw.c:13) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 4 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid write of size 2 at 0x........: main (badrw.c:13) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 4 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid read of size 1 at 0x........: main (badrw.c:14) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 1 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid write of size 1 at 0x........: main (badrw.c:14) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 1 bytes before a block of size 10 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (badrw.c:5) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... diff --git a/addrcheck/tests/fprw.stderr.exp b/addrcheck/tests/fprw.stderr.exp index 41f8ada241..43d29c7040 100644 --- a/addrcheck/tests/fprw.stderr.exp +++ b/addrcheck/tests/fprw.stderr.exp @@ -1,56 +1,34 @@ Invalid read of size 8 at 0x........: main (fprw.c:20) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 0 bytes inside a block of size 8 free'd at 0x........: free (vg_replace_malloc.c:...) by 0x........: main (fprw.c:18) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid write of size 8 at 0x........: main (fprw.c:20) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 0 bytes inside a block of size 8 free'd at 0x........: free (vg_replace_malloc.c:...) by 0x........: main (fprw.c:18) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid read of size 4 at 0x........: main (fprw.c:21) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 0 bytes inside a block of size 4 free'd at 0x........: free (vg_replace_malloc.c:...) by 0x........: main (fprw.c:19) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid write of size 4 at 0x........: main (fprw.c:21) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 0 bytes inside a block of size 4 free'd at 0x........: free (vg_replace_malloc.c:...) by 0x........: main (fprw.c:19) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Invalid free() / delete / delete[] at 0x........: free (vg_replace_malloc.c:...) by 0x........: main (fprw.c:22) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is not stack'd, malloc'd or free'd Invalid write of size 8 at 0x........: main (fprw.c:24) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... Address 0x........ is 0 bytes inside a block of size 4 alloc'd at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (fprw.c:23) - by 0x........: __libc_start_main (...libc...) - by 0x........: ... diff --git a/coregrind/docs/coregrind_core.html b/coregrind/docs/coregrind_core.html index f801ebc739..cbf624568d 100644 --- a/coregrind/docs/coregrind_core.html +++ b/coregrind/docs/coregrind_core.html @@ -493,12 +493,24 @@ options. Options for the valgrind core may be freely mixed with those for the selected skin.

Valgrind's default settings succeed in giving reasonable behaviour -in most cases. Available options, in no particular order, are as -follows: +in most cases. We group the available options by rough categories. + +

Skin-selection option

+The single most important option. + + +

Basic Options

+These options work with all skins. + + +

Error-related options

+These options are used by all skins that can report errors, e.g. Memcheck, but +not Cachegrind. + -
  • --gen-suppressions=no [the default]
    - --gen-suppressions=yes -

    When enabled, Valgrind will pause after every error shown, - and print the line -
    - ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ---- -

    - The prompt's behaviour is the same as for the --gdb-attach - option. -

    - If you choose to, Valgrind will print out a suppression for this error. - You can then cut and paste it into a suppression file if you don't want - to hear about the error in the future. -

    - This option is particularly useful with C++ programs, as it prints out - the suppressions with mangled names, as required. -

    - Note that the suppressions printed are as specific as possible. You - may want to common up similar ones, eg. by adding wildcards to function - names. Also, sometimes two different errors are suppressed by the same - suppression, in which case Valgrind will output the suppression more than - once, but you only need to have one copy in your suppression file (but - having more than one won't cause problems). Also, the suppression - name is given as <insert a suppression name here>; - the name doesn't really matter, it's only used with the - -v option which prints out all used suppression records. -


  • - -

  • --alignment=<number> [default: 4]

    By +

    malloc()-related options

    +For skins that use their own version of malloc() (e.g. Memcheck +and Addrcheck), the following options apply. + -
  • --trace-children=no [the default]
    - --trace-children=yes -

    When enabled, Valgrind will trace into child processes. This - is confusing and usually not what you want, so is disabled by - default. -


  • - -

  • --logfile-fd=<number> [default: 2, stderr] -

    Specifies that Valgrind should send all of its - messages to the specified file descriptor. The default, 2, is - the standard error channel (stderr). Note that this may - interfere with the client's own use of stderr. -


  • - -

  • --logfile=<filename> -

    Specifies that Valgrind should send all of its - messages to the specified file. In fact, the file name used - is created by concatenating the text filename, - ".pid" and the process ID, so as to create a file per process. - The specified file name may not be the empty string. -


  • - -

  • --logsocket=<ip-address:port-number> -

    Specifies that Valgrind should send all of its messages to - the specified port at the specified IP address. The port may be - omitted, in which case port 1500 is used. If a connection - cannot be made to the specified socket, valgrind falls back to - writing output to the standard error (stderr). This option is - intended to be used in conjunction with the - valgrind-listener program. For further details, - see section 2.3. -


  • - -

  • --suppressions=<filename> - [default: $PREFIX/lib/valgrind/default.supp] -

    Specifies an extra - file from which to read descriptions of errors to suppress. You - may use as many extra suppressions files as you - like. -


  • - -

  • --error-limit=yes [default]
    - --error-limit=no

    When enabled, valgrind stops - reporting errors after 30000 in total, or 300 different ones, - have been seen. This is to stop the error tracking machinery - from becoming a huge performance overhead in programs with many - errors. -


  • - -

  • --run-libc-freeres=yes [the default]
    +

    Rare options

    +These options apply to all skins, as they affect certain obscure workings of +the Valgrind core. Most people won't need to use these. +

  • + +

  • --signal-polltime=<time> [default=50]
    +

    How often to poll for signals (in milliseconds). Only applies for + older kernels that need signal routing. +


  • + +

  • --lowlat-signals=no [default]
    + --lowlat-signals=yes
    +

    Improve wake-up latency when a thread receives a signal. +


  • + +

  • --lowlat-syscalls=no [default]
    + --lowlat-syscalls=yes
    +

    Improve wake-up latency when a thread's syscall completes. +


  • + +

  • --assume-2.4=no [default]
    + --assume-2.4=yes
    +

    Assume we're running on a 2.4 kernel. Only needed for some + distributions that are broken in obscure ways. +


  • There are also some options for debugging Valgrind itself. You diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index 3c76f05cbc..7f4f72947e 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -195,6 +195,7 @@ void VG_(gen_suppression)(Error* err) { Int i; UChar buf[M_VG_ERRTXT]; + Bool main_done = False; ExeContext* ec = VG_(get_error_where)(err); Int stop_at = VG_(clo_backtrace_size); @@ -222,10 +223,16 @@ void VG_(gen_suppression)(Error* err) i = 0; do { Addr eip = ec->eips[i]; - if (i > 0) - eip--; /* point to calling line */ - + if (i > 0) eip--; /* point to calling line */ if ( VG_(get_fnname_nodemangle) (eip, buf, M_VG_ERRTXT) ) { + // Stop after "main"; if main() is recursive, stop after last main(). + + if ( ! VG_(clo_show_below_main)) { + if (VG_STREQ(buf, "main")) + main_done = True; + else if (main_done) + break; + } VG_(printf)(" fun:%s\n", buf); } else if ( VG_(get_objname)(eip, buf, M_VG_ERRTXT) ) { VG_(printf)(" obj:%s\n", buf); diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 9eea7b5081..ecc0506d3b 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -265,6 +265,8 @@ extern Bool VG_(clo_lowlat_signals); extern Bool VG_(clo_run_libc_freeres); /* Use the basic-block chaining optimisation? Default: YES */ extern Bool VG_(clo_chain_bb); +/* Continue stack traces below main()? Default: NO */ +extern Bool VG_(clo_show_below_main); /* --------------------------------------------------------------------- diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 91baec20ae..de67610f33 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -558,6 +558,7 @@ Int VG_(clo_backtrace_size) = 4; Char* VG_(clo_weird_hacks) = NULL; Bool VG_(clo_run_libc_freeres) = True; Bool VG_(clo_chain_bb) = True; +Bool VG_(clo_show_below_main) = False; static Bool VG_(clo_wait_for_gdb) = False; @@ -636,26 +637,33 @@ static void usage ( void ) "usage: valgrind [options] prog-and-args\n" "\n" " core user options, with defaults in [ ], are:\n" +" --skin= main task (skin to use) [Valgrind]\n" + " --help show this message\n" " --version show version\n" -" --skin= main task (skin to use) [Valgrind]\n" + " -q --quiet run silently; only print error msgs\n" " -v --verbose be more verbose, incl counts of errors\n" -" --gdb-attach=no|yes start GDB when errors detected? [no]\n" -" --gdb-path=/path/to/gdb path to the GDB to use [/usr/bin/gdb]\n" -" --gen-suppressions=no|yes print suppressions for errors detected [no]\n" -" --demangle=no|yes automatically demangle C++ names? [yes]\n" -" --num-callers= show callers in stack traces [4]\n" -" --error-limit=no|yes stop showing new errors if too many? [yes]\n" + " --trace-children=no|yes Valgrind-ise child processes? [no]\n" -" --run-libc-freeres=no|yes Free up glibc memory at exit? [yes]\n" + " --logfile-fd= file descriptor for messages [2=stderr]\n" " --logfile= log messages to .pid\n" -" --input-fd= file descriptor for (gdb) input [0=stdin]\n" " --logsocket=ipaddr:port log messages to socket ipaddr:port\n" -" --suppressions= suppress errors described in\n" -" suppressions file \n" -" --weird-hacks=hack1,hack2,... [no hacks selected]\n" + +" --demangle=no|yes automatically demangle C++ names? [yes]\n" +" --num-callers= show callers in stack traces [4]\n" +" --error-limit=no|yes stop showing new errors if too many? [yes]\n" +" --show-below-main=no|yes continue stack traces below main() [no]\n" +" --suppressions= suppress errors described in \n" +" --gen-suppressions=no|yes print suppressions for errors detected [no]\n" + +" --gdb-attach=no|yes start GDB when errors detected? [no]\n" +" --gdb-path=/path/to/gdb path to the GDB to use [/usr/bin/gdb]\n" +" --input-fd= file descriptor for (gdb) input [0=stdin]\n" + +" --run-libc-freeres=no|yes Free up glibc memory at exit? [yes]\n" +" --weird-hacks=hack1,hack2,... [none]\n" " recognised hacks are: ioctl-VTIME truncate-writes lax-ioctls\n" " --signal-polltime=