From: Julian Seward Date: Sat, 18 Jun 2011 08:28:04 +0000 (+0000) Subject: Minor GDBserver source tidying. Also a small usability fix: if X-Git-Tag: svn/VALGRIND_3_7_0~415 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46d08c579dbf3c98682c52db0e15b5fd43c58912;p=thirdparty%2Fvalgrind.git Minor GDBserver source tidying. Also a small usability fix: if --vgdb-error=N is specified, print a bit of text telling the user the magic commands to give GDB in order to attach to the process. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11822 --- diff --git a/coregrind/m_gdbserver/m_gdbserver.c b/coregrind/m_gdbserver/m_gdbserver.c index 44669064fd..8171eefe2b 100644 --- a/coregrind/m_gdbserver/m_gdbserver.c +++ b/coregrind/m_gdbserver/m_gdbserver.c @@ -7,7 +7,7 @@ This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2011 Philippe Waroquiers + Copyright (C) 2011-2011 Philippe Waroquiers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index 36b891aadd..66e4337634 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -250,13 +250,30 @@ void remote_open (char *name) VG_(umsg)("embedded gdbserver: reading from %s\n", from_gdb); VG_(umsg)("embedded gdbserver: writing to %s\n", to_gdb); VG_(umsg)("embedded gdbserver: shared mem %s\n", shared_mem); - VG_(umsg)("CONTROL ME using: vgdb --pid=%d%s%s ...command...\n", + VG_(umsg)("\n"); + VG_(umsg)("TO CONTROL THIS PROCESS USING vgdb (which you probably\n" + "don't want to do, unless you know exactly what you're doing,\n" + "or are doing some strange experiment):\n" + " %s/../../bin/vgdb --pid=%d%s%s ...command...\n", + VG_LIBDIR, pid, (name_default ? "" : " --vgdb="), (name_default ? "" : name)); - VG_(umsg)("DEBUG ME using: (gdb) target remote | vgdb --pid=%d%s%s\n", - pid, (name_default ? "" : " --vgdb="), - (name_default ? "" : name)); - VG_(umsg)(" --pid optional if only one valgrind process is running\n"); + } + if (VG_(clo_verbosity) > 1 + || VG_(clo_vgdb_error) < 999999999) { + VG_(umsg)("\n"); + VG_(umsg)( + "TO DEBUG THIS PROCESS USING GDB: start GDB like this\n" + " /path/to/gdb %s\n" + "and then give GDB the following command\n" + " target remote | %s/../../bin/vgdb --pid=%d%s%s\n", + VG_(args_the_exename), + VG_LIBDIR, + pid, (name_default ? "" : " --vgdb="), + (name_default ? "" : name) + ); + VG_(umsg)("--pid is optional if only one valgrind process is running\n"); + VG_(umsg)("\n"); } if (!mknod_done) { diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 1bf66c6174..a3e791045b 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -132,7 +132,9 @@ static void usage_NORETURN ( Bool debug_help ) " --child-silent-after-fork=no|yes omit child output between fork & exec? [no]\n" " --vgdb=no|yes|full activate gdbserver? [yes]\n" " full is slower but provides precise watchpoint/step\n" -" --vgdb-error= invoke gdbserver after errors [%d] \n" +" --vgdb-error= invoke gdbserver after errors [%d]\n" +" to get started quickly, use --vgdb-error=0\n" +" and follow the on-screen directions\n" " --track-fds=no|yes track open file descriptors? [no]\n" " --time-stamp=no|yes add timestamps to log messages? [no]\n" " --log-fd= log messages to file descriptor [2=stderr]\n" diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 9b9e3dc10f..3104fdc055 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -901,11 +901,6 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid ) return retval; } -ULong VG_(bbs_done) (void) -{ - return bbs_done; -} - /* --------------------------------------------------------------------- The scheduler proper. diff --git a/coregrind/pub_core_gdbserver.h b/coregrind/pub_core_gdbserver.h index 202d89bc84..a001cc6c09 100644 --- a/coregrind/pub_core_gdbserver.h +++ b/coregrind/pub_core_gdbserver.h @@ -7,7 +7,7 @@ This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2011 Philippe Waroquiers + Copyright (C) 2011-2011 Philippe Waroquiers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/coregrind/pub_core_scheduler.h b/coregrind/pub_core_scheduler.h index 0458aaa67b..c2b22fce72 100644 --- a/coregrind/pub_core_scheduler.h +++ b/coregrind/pub_core_scheduler.h @@ -100,9 +100,6 @@ extern void VG_(scheduler_init_phase2) ( ThreadId main_tid, extern void VG_(disable_vgdb_poll) (void ); extern void VG_(force_vgdb_poll) ( void ); -/* nr of bbs done since startup. */ -extern ULong VG_(bbs_done) (void); - /* Stats ... */ extern void VG_(print_scheduler_stats) ( void ); diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c index cd315bfc2e..68e67970ab 100644 --- a/coregrind/vgdb.c +++ b/coregrind/vgdb.c @@ -6,7 +6,7 @@ This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2011 Philippe Waroquiers + Copyright (C) 2011-2011 Philippe Waroquiers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index a43398417f..1f9b95c378 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -295,6 +295,13 @@ under Memcheck and on-demand Massif snapshot production. xreflabel="gdbserver simple example"> Quick Start: debugging in 3 steps +The simplest way to get started is to run Valgrind with the +flag . Then follow the on-screen +directions, which give you the precise commands needed to start GDB +and connect it to your program. + +Otherwise, here's a slightly more verbose overview. + If you want to debug a program with GDB when using the Memcheck tool, start Valgrind the following way: invoke gdbserver after errors [999999999] + --vgdb-error= invoke gdbserver after errors [999999999] + to get started quickly, use --vgdb-error=0 + and follow the on-screen directions --track-fds=no|yes track open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd= log messages to file descriptor [2=stderr] diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index a65047e069..056c689084 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -18,7 +18,9 @@ usage: valgrind [options] prog-and-args --child-silent-after-fork=no|yes omit child output between fork & exec? [no] --vgdb=no|yes|full activate gdbserver? [yes] full is slower but provides precise watchpoint/step - --vgdb-error= invoke gdbserver after errors [999999999] + --vgdb-error= invoke gdbserver after errors [999999999] + to get started quickly, use --vgdb-error=0 + and follow the on-screen directions --track-fds=no|yes track open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd= log messages to file descriptor [2=stderr]