From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53774 invoked by alias); 9 May 2016 07:47:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50726 invoked by uid 89); 9 May 2016 07:47:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Auto, Recording, Automatically, replay X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 May 2016 07:47:29 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 09 May 2016 00:47:28 -0700 X-ExtLoop1: 1 Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by orsmga003.jf.intel.com with ESMTP; 09 May 2016 00:47:24 -0700 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.226]) by IRSMSX108.ger.corp.intel.com ([169.254.11.241]) with mapi id 14.03.0248.002; Mon, 9 May 2016 08:47:23 +0100 From: "Metzger, Markus T" To: "gdb-patches@sourceware.org" CC: "palves@redhat.com" , "ak@linux.intel.com" , "jan.kratochvil@redhat.com" Subject: RE: [PATCH] record: automatically start recording Date: Mon, 09 May 2016 07:47:00 -0000 Message-ID: References: <1459866845-28423-1-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1459866845-28423-1-git-send-email-markus.t.metzger@intel.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00139.txt.bz2 ping. > -----Original Message----- > From: Metzger, Markus T > Sent: Tuesday, April 5, 2016 4:34 PM > To: gdb-patches@sourceware.org > Cc: palves@redhat.com; ak@linux.intel.com; jan.kratochvil@redhat.com > Subject: [PATCH] record: automatically start recording >=20 > When using process record and replay frequently, one sometimes forgets to= start > recording after re-run. This can be quite annoying. >=20 > I tried to automatically start recording for every new inferior with exis= ting > GDB commands. I came up with: >=20 > (gdb) b _start > Breakpoint 1 at 0x400560 > (gdb) command 1 > Type commands for breakpoint(s) 1, one per line. > End with a line saying just "end". > >record btrace > >cont > >end >=20 > This may not be completely obvious to everybody and you can't easily put = it into > your gdbinit. It also doesn't support the attach case (not sure that mat= ters). >=20 > This patch adds a new option "auto-record" to automatically start recordi= ng for > every new inferior using GDB's inferior-created observer. >=20 > Is the added convenience worth a new option or do we want to point users = to > the > breakpoint-command solution? >=20 > 2016-04-05 Markus Metzger > --- > gdb/NEWS | 3 ++ > gdb/doc/gdb.texinfo | 12 ++++++ > gdb/record.c | 64 ++++++++++++++++++++++++++= ++++++ > gdb/testsuite/gdb.btrace/auto-enable.exp | 48 ++++++++++++++++++++++++ > 4 files changed, 127 insertions(+) > create mode 100644 gdb/testsuite/gdb.btrace/auto-enable.exp >=20 > diff --git a/gdb/NEWS b/gdb/NEWS > index 39d99b7..79f27b0 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -37,6 +37,9 @@ skip -rfunction regular-expression > maint info line-table REGEXP > Display the contents of GDB's internal line table data struture. >=20 > +set|show auto-record > + Automatically record newly created processes. > + > * Support for tracepoints and fast tracepoints on s390-linux and s390x-l= inux > was added in GDBserver, including JIT compiling fast tracepoint's > conditional expression bytecode into native code. > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 7abd55e..7d46a95 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -6681,6 +6681,18 @@ the asynchronous execution mode > (@pxref{Background Execution}), not > all recording methods are available. The @code{full} recording method > does not support these two modes. >=20 > +@kindex set auto-record > +@item set auto-record @var{method} > +Automatically record newly created processes using the recording > +method @var{method}. If @var{method} is @code{off}, automatic > +recording is disabled. > + > +@kindex show auto-record > +@item show auto-record > +Show the recoding method used for automatically recording newly > +created processes. If automatic recording is disabled, the recording > +method is @code{off}. > + > @kindex record stop > @kindex rec s > @item record stop > diff --git a/gdb/record.c b/gdb/record.c > index 6190794..13a451a 100644 > --- a/gdb/record.c > +++ b/gdb/record.c > @@ -53,10 +53,37 @@ struct cmd_list_element *set_record_cmdlist =3D NULL; > struct cmd_list_element *show_record_cmdlist =3D NULL; > struct cmd_list_element *info_record_cmdlist =3D NULL; >=20 > +/* Supported names for the "set|show auto-record" command. */ > +static const char auto_record_off[] =3D "off"; > +static const char auto_record_full[] =3D "full"; > +static const char auto_record_btrace[] =3D "btrace"; > +static const char auto_record_bts[] =3D "bts"; > +static const char auto_record_pt[] =3D "pt"; > +static const char *const auto_record_names[] =3D > +{ > + auto_record_off, > + auto_record_full, > + auto_record_btrace, > + auto_record_bts, > + auto_record_pt, > + NULL, > +}; > + > +static const char *auto_record_string =3D auto_record_off; > + > #define DEBUG(msg, args...) \ > if (record_debug) \ > fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args) >=20 > +/* The "show auto-record" command. */ > + > +static void > +show_auto_record_string (struct ui_file *file, int from_tty, > + struct cmd_list_element *c, const char *value) > +{ > + fprintf_filtered (file, _("Auto record is \"%s\".\n"), value); > +} > + > /* See record.h. */ >=20 > struct target_ops * > @@ -733,6 +760,30 @@ set_record_call_history_size (char *args, int from_t= ty, > &record_call_history_size); > } >=20 > +/* The inferior-created observer implementing "set auto-record". */ > + > +static void > +record_inferior_created (struct target_ops *ops, int from_tty) > +{ > + if (auto_record_string =3D=3D auto_record_off) > + return; > + > + TRY > + { > + char command[64]; > + > + snprintf (command, sizeof(command), "record %s", auto_record_strin= g); > + > + execute_command (command, from_tty); > + } > + CATCH (exception, RETURN_MASK_ALL) > + { > + warning (_("Could not enable record %s: %s"), auto_record_string, > + exception.message); > + } > + END_CATCH > +} > + > /* Provide a prototype to silence -Wmissing-prototypes. */ > extern initialize_file_ftype _initialize_record; >=20 > @@ -856,7 +907,20 @@ The number of functions to print can be defined with > \"set record \ > function-call-history-size\"."), > &record_cmdlist); >=20 > + add_setshow_enum_cmd ("auto-record", class_support, auto_record_names, > + &auto_record_string, _("\ > +Set automatic recording mode."), _("\ > +Show automatic recording mode."), _("\ > +off =3D=3D no automatic recording.\n\ > +full =3D=3D automatically start record full.\n\ > +btrace =3D=3D automatically start record btrace.\n\ > +bts =3D=3D automatically start record bts.\n\ > +pt =3D=3D automatically start record pt."), > + NULL, show_auto_record_string, &setlist, &showlist); > + > /* Sync command control variables. */ > record_insn_history_size_setshow_var =3D record_insn_history_size; > record_call_history_size_setshow_var =3D record_call_history_size; > + > + observer_attach_inferior_created (record_inferior_created); > } > diff --git a/gdb/testsuite/gdb.btrace/auto-enable.exp > b/gdb/testsuite/gdb.btrace/auto-enable.exp > new file mode 100644 > index 0000000..1da0ca4 > --- /dev/null > +++ b/gdb/testsuite/gdb.btrace/auto-enable.exp > @@ -0,0 +1,48 @@ > +# This testcase is part of GDB, the GNU debugger. > +# > +# Copyright 2016 Free Software Foundation, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# check for btrace support > +if { [skip_btrace_tests] } { return -1 } > + > +# start inferior > +standard_testfile record_goto.c > +if [prepare_for_testing $testfile.exp $testfile $srcfile] { > + return -1 > +} > + > +gdb_test "show auto-record" "Auto record is \"off\"\." "show default" > + > +gdb_test_no_output "set auto-record btrace" "set btrace" > +gdb_test "show auto-record" "Auto record is \"btrace\"\." "show btrace" > + > +if ![runto_main] { > + return -1 > +} > + > +gdb_test "info record" [multi_line \ > + "Active record target: record-btrace" \ > + "Recording format: .*" \ > + ] "recording" > + > +gdb_test_no_output "set auto-record off" "set off" > +gdb_test "show auto-record" "Auto record is \"off\"\." "show off" > + > +if ![runto_main] { > + return -1 > +} > + > +gdb_test "info record" "No record target is currently active\." "not rec= ording" > -- > 1.8.3.1 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928