From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17114 invoked by alias); 15 Mar 2011 07:13:55 -0000 Received: (qmail 17105 invoked by uid 22791); 15 Mar 2011 07:13:53 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_KG X-Spam-Check-By: sourceware.org Received: from mail-gy0-f169.google.com (HELO mail-gy0-f169.google.com) (209.85.160.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Mar 2011 07:13:49 +0000 Received: by gyg10 with SMTP id 10so157929gyg.0 for ; Tue, 15 Mar 2011 00:13:47 -0700 (PDT) Received: by 10.147.100.20 with SMTP id c20mr19101976yam.5.1300173227172; Tue, 15 Mar 2011 00:13:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.125.2 with HTTP; Tue, 15 Mar 2011 00:13:27 -0700 (PDT) In-Reply-To: References: From: Hui Zhu Date: Tue, 15 Mar 2011 10:50:00 -0000 Message-ID: Subject: Re: [PATCH v2] tracepoint: add new trace command "printf" and agent expression "printf" [0] To: gdb-patches ml Cc: Doug Evans , Michael Snyder , Stan Shebs , Tom Tromey , Eli Zaretskii Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2011-03/txt/msg00765.txt.bz2 Hi guys, Does anyone want review or reviewing this patches? If not, I will begin to make KGTP support printk with itself. Thanks, Hui On Thu, Feb 24, 2011 at 16:36, Hui Zhu wrote: > Hi guys, > > The prev version patches were reverted because I misunderstood the > Tom's comments and checked in the patch. > > So I send a new mail for review. > > I add a new patch add new trace command "printf" and agent expression > "printf" in gdb, gdbserver and doc. > > This printf is same with the simple gdb command, it can do formatted > output. =A0But it will happen in gdbserver part when it break by a > tracepoint. > Then the user can get the format value that he want in tracepint. =A0It > will be more easy and clear to handle the bug sometimes. > > About why I add printf to the tracepoint, I have 2 reasons: > 1. The gdb and gdbserver connect through a low speed net. =A0Sometimes, > the debug target that I use is in the other side of the earth. > The breakpoint commands "printf" is too slow for that issue, because > each time the inferior is break by the breakpoint, gdbserver need send > the rsp package to gdb, and gdb will get the data that "printf" need > though low speed net from gdbsever. =A0And sometime, it will disconnect. > But if through tracepoint, I will not have this trouble. =A0I can "set > disconnected-tracing on" to handle the network disconnect issue. =A0I > still need to get the value from inferior through tfind and other > commands. =A0It is still be affect by the low speed network. =A0So I make > the tracepoint "printf" to handle it. > > 2. =A0KGTP(https://code.google.com/p/kgtp/) just support the gdb > tracepoint rsp commands. =A0For not stop the Linux the Kernel. =A0It > doesn't support the breakpoint. > So if it want directly show the Kernel val value, it need "printf". > This printf will be very powerful that can set most part of Kernel and > we can set condition for it. > And in https://code.google.com/p/kgtp/wiki/HOWTO#Offline_debug, =A0we > can dump the gdbrsp package to a file and send to Kernel. =A0Then kernel > can be debug without a local gdb or a remote connect. =A0 But user still > need copy the trace file to pc that have GDB. =A0But if support > tracepoint "printf", we will not need do that. > BTW, the kgtp have supported the agent expression "printf". > > About the command part, I use the "printf" instead add a new commands > because the behavior of =A0this command is same with printf. They will > use the same function string_printf(update from ui_printf) to parse > the command arg. > > To support the printf command, I add a new agent expression 0x31 > printf, the format for it is: > 0x31(op_printf) + arg(1/0) + format string with end by 0x0. > The arg is the number of argument of printf. =A0It will only be 1 (one > argument) or 0 (no argument). =A0I make it cannot have more than one > argument because I cannot found a good way to handle va_list that send > arguments to vprintf. > The format string with end by 0x0 is the simple format string. =A0It end > by 0x0 then the gdbserver can use it directly. > > Example: > (gdb) trace 16 > During symbol reading, DW_AT_name missing from DW_TAG_base_type. > Tracepoint 1 at 0x4004c3: file 1.c, line 16. > (gdb) tvariable $c > Trace state variable $c created, with initial value 0. > (gdb) actions > Enter actions for tracepoint 1, one per line. > End with a line saying just "end". >>printf "%d 0x%lx %d\n",$c=3D$c+1,$rax,argc >>end > (gdb) target remote localhost:1234 > (gdb) tstart > (gdb) c > > gdbserver/gdbserver =A0localhost:1234 ./a.out > Process ./a.out created; pid =3D 25804 > Listening on port 1234 > Remote debugging from host 127.0.0.1 > 1 0x7f2cb8711ec8 1 > 2 0x7f2cb8711ec8 2 > 3 0x7f2cb8711ec8 3 > 4 0x7f2cb8711ec8 4 > 5 0x7f2cb8711ec8 5 > 6 0x7f2cb8711ec8 6 > 7 0x7f2cb8711ec8 7 > > Please help me review the patches. > > Thanks, > Hui >