From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13482 invoked by alias); 30 Sep 2009 04:45:50 -0000 Received: (qmail 13458 invoked by uid 22791); 30 Sep 2009 04:45:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,MIME_QP_LONG_LINE,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-gx0-f210.google.com (HELO mail-gx0-f210.google.com) (209.85.217.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Sep 2009 04:45:41 +0000 Received: by gxk2 with SMTP id 2so4042809gxk.4 for ; Tue, 29 Sep 2009 21:45:39 -0700 (PDT) Received: by 10.90.211.6 with SMTP id j6mr4154387agg.86.1254285939767; Tue, 29 Sep 2009 21:45:39 -0700 (PDT) Received: from xpjpn (pool-71-111-147-240.ptldor.dsl-w.verizon.net [71.111.147.240]) by mx.google.com with ESMTPS id 14sm192349gxk.10.2009.09.29.21.45.35 (version=SSLv3 cipher=RC4-MD5); Tue, 29 Sep 2009 21:45:37 -0700 (PDT) From: Caz Yokoyama To: "'Joel Brobecker'" Cc: "'Pedro Alves'" , References: <9ECED0F0DCF04CC185B027503876430D@xpjpn> <20090925160627.GB5077@adacore.com> <66E35EA6599040F894D040E4F50389D0@xpjpn> <535d47e30909260627n662135a1hf6d1a0bb33368b3a@mail.gmail.com> <20090929015830.GJ9003@adacore.com> <1724490614004CEB9EE1A091A151E05B@xpjpn> <20090929042226.GK9003@adacore.com> <2C14068798BA41219F3603CDD24C8BC0@xpjpn> <20090929051929.GL9003@adacore.com> <7063C3E99BE344B2B98EDC0318ED852A@xpjpn> <20090929163910.GO9003@adacore.com> Subject: RE: symbolic debug of loadable modules with kgdb light Date: Wed, 30 Sep 2009 04:45:00 -0000 Message-ID: <93F096FEF7ED4579B52B23D69DA91195@xpjpn> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_009F_01CA414E.351EB5A0" In-Reply-To: <20090929163910.GO9003@adacore.com> X-IsSubscribed: yes 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 X-SW-Source: 2009-09/txt/msg00944.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_009F_01CA414E.351EB5A0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-length: 2233 Hello Joel, Here is the patch for 1. Let me know if I forget something. Also any comments are welcome. Thank you. -caz -----Original Message----- From: Joel Brobecker [mailto:brobecker@adacore.com] Sent: Tuesday, September 29, 2009 9:39 AM To: Caz Yokoyama Cc: 'Pedro Alves'; gdb-patches@sourceware.org Subject: Re: symbolic debug of loadable modules with kgdb light > Do you think we have to check correctness of user input for > interrupt_sequence? Yes, if only for the vast majority of users who will be using either the default or using BREAK. > Setting-up debugging environment of Linux device driver by gdb is not > a trivial task I don't doubt that, and I do not doubt that users prefer flexibility. The current solution, which offers the user 3 choices for the interrupt sequence, has no kernel dependency. It's very clear what each choices does, and I do not understand how allowing free text instead of a defined set of choices helps make things easier, especially when only specific choices will actually be accepted in the end. You are arguing that we may need more choices in the future. I answered that we can worry about that later, *when/if* the situation actually arises. Adding more choices is a matter of seconds with a 10-line patch. But, again, I also repeat that, if you think this is unnacceptable, then perhaps we can accomodate extensibility while not needing code recompilation by using a technical solution based on XML. You can have a look at how "catch syscall" is implemented for an illustration. But this can be done as a second phase, after the patch on which you've been working on is approved and checked in. In other words: 1. Implement a patch that adds: set/show remote interrupt-sequence set/show remote interrupt-at-startup [on|off] Make the old set/show remotedebug deprecated (please take a look at my earlier reply on what I mean by that) 2. Look into adding extensibility through the use of an XML file If you prefer to do all the work in one patch, you are welcome to do so, but you are letting the best be the enemy of good, IMO, and only delaying the time when vanilla FSF GDB can debug Linux Kernel modules. -- Joel ------=_NextPart_000_009F_01CA414E.351EB5A0 Content-Type: application/octet-stream; name="remotebreak.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="remotebreak.patch" Content-length: 14873 Index: gdb/ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/ChangeLog,v=0A= retrieving revision 1.10923=0A= diff -u -r1.10923 ChangeLog=0A= --- gdb/ChangeLog 29 Sep 2009 16:27:05 -0000 1.10923=0A= +++ gdb/ChangeLog 30 Sep 2009 04:41:50 -0000=0A= @@ -1,3 +1,13 @@=0A= +2009-09-29 Kazuyoshi Caz Yokoyama =0A= +=0A= + * remote.c: Allow the user to select one of ^C, a break or=0A= + Magic SysRq g as the sequence to the remote in order to=0A= + interrupt the execution. The syntax is=0A= + set remote interrupt-sequence [control-c | break | sysrq-g]=0A= + control-c is a default. Some system prefers break which is high level of= =0A= + serial line for some certain time. Linux kernel prefers sysrq-g, a.k.a=0A= + Magic SysRq. It is break signal and character 'g'.=0A= +=0A= 2009-09-29 Jan Kratochvil =0A= =20=0A= * ia64-tdep.c (ia64_convert_from_func_ptr_addr): New variable buf.=0A= Index: gdb/NEWS=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/NEWS,v=0A= retrieving revision 1.331=0A= diff -u -r1.331 NEWS=0A= --- gdb/NEWS 15 Sep 2009 03:30:04 -0000 1.331=0A= +++ gdb/NEWS 30 Sep 2009 04:41:52 -0000=0A= @@ -3,6 +3,15 @@=0A= =20=0A= *** Changes since GDB 6.8=0A= =20=0A= +* "set/show remotebreak" command is deprecated. "set/show remote interrupt= -sequence"=0A= +is added. They add break signal followed by a character 'g' in addition to= control-c=0A= +and a break signal. break signal and g is also known as Magic SysRq and it= interrupts=0A= +Linux kernel.=0A= +=0A= +* "set/show remote interrupt-on-start" command is added. When this is ON,= =0A= +gdb sends interrupt-sequence to the remote target when gdb starts. This is= needed when=0A= +you debug Linux kernel.=0A= +=0A= * GDB now has an interface for JIT compilation. Applications that=0A= dynamically generate code can create symbol files in memory and register= =0A= them with GDB. For users, the feature should work transparently, and=0A= Index: gdb/remote.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/remote.c,v=0A= retrieving revision 1.372=0A= diff -u -r1.372 remote.c=0A= --- gdb/remote.c 10 Sep 2009 22:47:56 -0000 1.372=0A= +++ gdb/remote.c 30 Sep 2009 04:41:54 -0000=0A= @@ -546,14 +546,83 @@=0A= this can go away. */=0A= static int wait_forever_enabled_p =3D 1;=0A= =20=0A= +/* Allow the user to specify what sequence to send to the remote=0A= + when he requests a program interruption: Although ^C is usually=0A= + what remote systems expect (this is the default, here), it is=0A= + sometimes preferable to send a break. On other systems such=0A= + as the Linux kernel, a break followed by g, which is Magic SysRq g=0A= + is required in order to interrupt the execution. */=0A= +const char interrupt_sequence_control_c[] =3D "control-c";=0A= +const char interrupt_sequence_break[] =3D "break";=0A= +const char interrupt_sequence_sysrq_g[] =3D "sysrq-g";=0A= +static const char *interrupt_sequence_modes[] =3D=0A= + {=0A= + interrupt_sequence_control_c,=0A= + interrupt_sequence_break,=0A= + interrupt_sequence_sysrq_g,=0A= + NULL=0A= + };=0A= +const char *interrupt_sequence_mode =3D interrupt_sequence_control_c;=0A= +=0A= +static void show_interrupt_sequence (struct ui_file *file, int from_tty,= =0A= + struct cmd_list_element *c,=0A= + const char *value)=0A= +{=0A= + if (interrupt_sequence_mode =3D=3D interrupt_sequence_control_c)=0A= + fprintf_filtered (file,=0A= + _("Send the ASCII ETX character (Ctrl-c) "=0A= + "to the remote target to interrupt the "=0A= + "execution of the program.\n"));=0A= + else if (interrupt_sequence_mode =3D=3D interrupt_sequence_break)=0A= + fprintf_filtered (file,=0A= + _("send a break signal to the remote target "=0A= + "to interrupt the execution of the program.\n"));=0A= + else if (interrupt_sequence_mode =3D=3D interrupt_sequence_sysrq_g)=0A= + fprintf_filtered (file,=0A= + _("Send a break signal and 'g' a.k.a. sysrq-g and Magic SysRq to "= =0A= + "the remote target to interrupt the execution "=0A= + "of Linux kernel.\n"));=0A= + else=0A= + internal_error (__FILE__, __LINE__,=0A= + _("You are sending unexpected %s to the remote target."),=0A= + interrupt_sequence_mode);=0A= +}=0A= +=0A= +/* This boolean variable specifies whether interrupt_sequence is sent=0A= + to remote target when gdb starts. This is mostly needed when you debug= =0A= + Linux kernel. Linux kernel expects BREAK g which is Magic SysRq for=0A= + connecting gdb.=0A= + */=0A= +static int interrupt_on_start =3D 0;=0A= =20=0A= /* This variable chooses whether to send a ^C or a break when the user=0A= requests program interruption. Although ^C is usually what remote=0A= systems expect, and that is the default here, sometimes a break is=0A= preferable instead. */=0A= -=0A= static int remote_break;=0A= =20=0A= +static void set_remotebreak (char *args, int from_tty, struct cmd_list_ele= ment *c)=0A= +{=0A= + printf_filtered (_("%s\n"), c->doc);=0A= + if (interrupt_sequence_mode =3D=3D interrupt_sequence_control_c)=0A= + {=0A= + interrupt_sequence_mode =3D interrupt_sequence_break;=0A= + remote_break =3D 0;=0A= + }=0A= + else=0A= + {=0A= + interrupt_sequence_mode =3D interrupt_sequence_control_c;=0A= + remote_break =3D 1;=0A= + }=0A= +}=0A= +=0A= +static void show_remotebreak (struct ui_file *file, int from_tty,=0A= + struct cmd_list_element *c,=0A= + const char *value)=0A= +{=0A= + fprintf_filtered (file, _("%s\n"), c->doc);=0A= +}=0A= +=0A= /* Descriptor for I/O to remote machine. Initialize it to NULL so that=0A= remote_open knows that we don't have a file open when the program=0A= starts. */=0A= @@ -2585,6 +2654,23 @@=0A= int extended_p;=0A= };=0A= =20=0A= +/*=0A= + Send interrupt_sequence to remote target.=0A= +*/=0A= +static void=0A= +send_interrupt_sequence ()=0A= +{=0A= + if (interrupt_sequence_mode =3D=3D interrupt_sequence_control_c)=0A= + serial_write (remote_desc, "\x03", 1);=0A= + else if (interrupt_sequence_mode =3D=3D interrupt_sequence_break)=0A= + serial_send_break (remote_desc);=0A= + else if (interrupt_sequence_mode =3D=3D interrupt_sequence_sysrq_g)=0A= + {=0A= + serial_send_break (remote_desc);=0A= + serial_write (remote_desc, "g", 1);=0A= + }=0A= +}=0A= +=0A= static void=0A= remote_start_remote (struct ui_out *uiout, void *opaque)=0A= {=0A= @@ -2598,6 +2684,12 @@=0A= /* Ack any packet which the remote side has already sent. */=0A= serial_write (remote_desc, "+", 1);=0A= =20=0A= + /* Interrupt_sequence is sent to remote target when gdb starts.=0A= + This is mostly needed when you debug Linux kernel.=0A= + Linux kernel expects BREAK g which is Magic SysRq for connecting gdb.= */=0A= + if (interrupt_on_start)=0A= + send_interrupt_sequence ();=0A= +=0A= /* The first packet we send to the target is the optional "supported=0A= packets" request. If the target can answer this, it will tell us=0A= which later probes to skip. */=0A= @@ -4021,12 +4113,8 @@=0A= if (rs->cached_wait_status)=0A= return;=0A= =20=0A= - /* Send a break or a ^C, depending on user preference. */=0A= -=0A= - if (remote_break)=0A= - serial_send_break (remote_desc);=0A= - else=0A= - serial_write (remote_desc, "\003", 1);=0A= + /* Send interrupt_sequence to remote target. */=0A= + send_interrupt_sequence ();=0A= }=0A= =20=0A= /* This is the generic stop called via the target vector. When a target=0A= @@ -9056,13 +9144,30 @@=0A= terminating `#' character and checksum."),=0A= &maintenancelist);=0A= =20=0A= - add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break, _("\=0A= -Set whether to send break if interrupted."), _("\=0A= -Show whether to send break if interrupted."), _("\=0A= + add_setshow_boolean_cmd ("remotebreak", class_obscure, &remote_break, _(= "\=0A= +Deprecated. Use \"set remote interrupt-sequence [control-c|break]\" instea= d."), _("\=0A= +Deprecated. Use \"show remote interrupt-sequence\" instead."), _("\=0A= If set, a break, instead of a cntrl-c, is sent to the remote target."),=0A= - NULL, NULL, /* FIXME: i18n: Whether to send break if interrupted is = %s. */=0A= + set_remotebreak, show_remotebreak,=0A= &setlist, &showlist);=0A= =20=0A= + add_setshow_enum_cmd ("interrupt-sequence", class_support,=0A= + interrupt_sequence_modes, &interrupt_sequence_mode, _("\=0A= +Set interrupt sequence to remote target, control-c/break/sysrq-g."), _("\= =0A= +Show interrupt sequence to remote target."),=0A= + NULL,=0A= + NULL, show_interrupt_sequence,=0A= + &remote_set_cmdlist,=0A= + &remote_show_cmdlist);=0A= +=0A= + add_setshow_boolean_cmd ("interrupt-on-start", class_support,=0A= + &interrupt_on_start, _("\=0A= +Set whether to send interrupt sequence when gdb starts."), _(" \=0A= +Show whether to send interrupt sequence when gdb starts."), _(" \=0A= +If set, interrupt sequence is sent to the remote target."),=0A= + NULL, NULL,=0A= + &remote_set_cmdlist, &remote_show_cmdlist);=0A= +=0A= /* Install commands for configuring memory read/write packets. */=0A= =20=0A= add_cmd ("remotewritesize", no_class, set_memory_write_packet_size, _("\= =0A= Index: gdb/doc/ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/doc/ChangeLog,v=0A= retrieving revision 1.958=0A= diff -u -r1.958 ChangeLog=0A= --- gdb/doc/ChangeLog 26 Sep 2009 16:47:13 -0000 1.958=0A= +++ gdb/doc/ChangeLog 30 Sep 2009 04:41:58 -0000=0A= @@ -1,3 +1,9 @@=0A= +2009-09-29 Kazuyoshi Caz Yokoyama =0A= +=0A= + * gdb.texinfo: remove "set/show remotebreak" command.=0A= + Add "set/show remote interrupt-sequence" and=0A= + "set/show remote interrupt-on-start" command.=0A= +=0A= 2009-09-26 Pierre Muller =0A= =20=0A= * gdb.texinfo (Cygwin Native): Mention support for Ctrl-BREAK.=0A= Index: gdb/doc/gdb.texinfo=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v=0A= retrieving revision 1.629=0A= diff -u -r1.629 gdb.texinfo=0A= --- gdb/doc/gdb.texinfo 26 Sep 2009 16:47:13 -0000 1.629=0A= +++ gdb/doc/gdb.texinfo 30 Sep 2009 04:42:11 -0000=0A= @@ -14940,20 +14940,6 @@=0A= @item show remotebaud=0A= Show the current speed of the remote connection.=0A= =20=0A= -@item set remotebreak=0A= -@cindex interrupt remote programs=0A= -@cindex BREAK signal instead of Ctrl-C=0A= -@anchor{set remotebreak}=0A= -If set to on, @value{GDBN} sends a @code{BREAK} signal to the remote=0A= -when you type @kbd{Ctrl-c} to interrupt the program running=0A= -on the remote. If set to off, @value{GDBN} sends the @samp{Ctrl-C}=0A= -character instead. The default is off, since most remote systems=0A= -expect to see @samp{Ctrl-C} as the interrupt signal.=0A= -=0A= -@item show remotebreak=0A= -Show whether @value{GDBN} sends @code{BREAK} or @samp{Ctrl-C} to=0A= -interrupt the remote program.=0A= -=0A= @item set remoteflow on=0A= @itemx set remoteflow off=0A= @kindex set remoteflow=0A= @@ -15011,6 +14997,34 @@=0A= target system. If it is not set, the target will use a default=0A= filename (e.g.@: the last program run).=0A= =20=0A= +@item set interrupt-sequence=0A= +@cindex interrupt remote programs=0A= +@cindex select control-c, break or sysrq-g=0A= +@anchor{set interrupt-sequence}=0A= +Allow the user to specify what sequence to send to the remote target=0A= +when he requests a program interruption: Although @kbd{control-c} is usual= ly=0A= +what remote systems expect (this is the default, here), it is=0A= +sometimes preferable to send a @code{break}. On other systems such=0A= +as the Linux kernel, a @code{break} followed by @code{g}, which is=0A= +@code{Magic SysRq g}=0A= +is required in order to interrupt the execution.=0A= +=0A= +@item show interrupt-sequence=0A= +Show which of @samp{Ctrl-C}, @code{break} or @code{break} followed by @cod= e{g}=0A= +is sent by @value{GDBN} to interrupt the remote program.=0A= +=0A= +@item set interrupt-on-start=0A= +@cindex send interrupt-sequence on start=0A= +@anchor{set interrupt-on-start}=0A= +Specify whether interrupt_sequence is sent=0A= +to remote target when gdb starts. This is mostly needed when you debug=0A= +@code{Linux kernel}. Linux kernel expects @code{BREAK g} which is @code{Ma= gic SysRq}=0A= +in order to connect gdb.=0A= +=0A= +@item show interrupt-on-start=0A= +Show whether interrupt_sequence is sent=0A= +to remote target when gdb starts.=0A= +=0A= @kindex set tcp=0A= @kindex show tcp=0A= @item set tcp auto-retry on=0A= @@ -29817,9 +29831,9 @@=0A= @cindex interrupts (remote protocol)=0A= =20=0A= When a program on the remote target is running, @value{GDBN} may=0A= -attempt to interrupt it by sending a @samp{Ctrl-C} or a @code{BREAK},=0A= -control of which is specified via @value{GDBN}'s @samp{remotebreak}=0A= -setting (@pxref{set remotebreak}).=0A= +attempt to interrupt it by sending a @samp{Ctrl-C}, @samp{BREAK} or a @sam= p{BREAK g},=0A= +control of which is specified via @value{GDBN}'s @samp{interrupt-sequence}= =0A= +setting (@pxref{set remote interrupt-sequence}).=0A= =20=0A= The precise meaning of @code{BREAK} is defined by the transport=0A= mechanism and may, in fact, be undefined. @value{GDBN} does not=0A= @@ -29836,6 +29850,10 @@=0A= (@pxref{X packet}), used for binary downloads, may include an unescaped=0A= @code{0x03} as part of its packet.=0A= =20=0A= +@code{BREAK g} is also known as Magic SysRq and is @code{BREAK} and charac= ter 'g'.=0A= +When Linux kernel receives this sequence from serial port, it stops execut= ion and=0A= +connects to gdb.=0A= +=0A= Stubs are not required to recognize these interrupt mechanisms and the=0A= precise meaning associated with receipt of the interrupt is=0A= implementation defined. If the target supports debugging of multiple=0A= ------=_NextPart_000_009F_01CA414E.351EB5A0--