From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17091 invoked by alias); 21 Mar 2011 15:39:36 -0000 Received: (qmail 16952 invoked by uid 22791); 21 Mar 2011 15:39:32 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_05,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_KG X-Spam-Check-By: sourceware.org Received: from mail-yx0-f169.google.com (HELO mail-yx0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Mar 2011 15:39:01 +0000 Received: by yxt33 with SMTP id 33so3099612yxt.0 for ; Mon, 21 Mar 2011 08:38:59 -0700 (PDT) Received: by 10.236.95.135 with SMTP id p7mr5527659yhf.184.1300721939177; Mon, 21 Mar 2011 08:38:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.83.8 with HTTP; Mon, 21 Mar 2011 08:38:39 -0700 (PDT) In-Reply-To: <4D804122.406@codesourcery.com> References: <4D804122.406@codesourcery.com> From: Hui Zhu Date: Mon, 21 Mar 2011 15:44:00 -0000 Message-ID: Subject: Re: [PATCH v2] tracepoint: add new trace command "printf" and agent expression "printf" [0] To: Stan Shebs Cc: gdb-patches@sourceware.org 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/msg00956.txt.bz2 Hi Stan, Thanks for your reply. On Wed, Mar 16, 2011 at 12:48, Stan Shebs wrote: > On 2/24/11 12:36 AM, 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 one is a tough choice. =A0As Doug said a while back, it doesn't real= ly > fit into the overall tracepoint structure - the basic idea of tracepoints= is > to accumulate data into a buffer, while this change adds a tracepoint act= ion > that prints back to the host, and doesn't save anything at all. =A0This c= an > actually lose massively, because in the absence of GDB roundtrips, a > tracepoint can easily rack up a million hits in a second (I've done it) - > but a million printfs coming back to the host is going to choke both the > network and GDB. =A0In fact it reduces debugging performance considerably; > while still faster than a breakpoint with a command list, most of the > tracepoint performance win is lost to the I/O back-and-forth. > "but a million printfs coming back to the host is going to choke both the > network and GDB." The printf will not send back to GDB. the server (gdbserver or kgtp) will handle it with itself. So it will not have the IO trouble or something else. And it will very fast and low cost. Thanks, Hui > The flip side is that it does seem like a useful pragmatic addition. =A0W= hen a > tracepoint experiment runs, there is a bit of guessing at how it's going. > =A0You can do tstatus commands, and maybe tfind will work, but neither ha= s the > live update advantage of the familiar printf. =A0So I like the ability for > users to have a sort of live monitoring of their trace run, even at the r= isk > of massive spew back up to GDB. > > Now if these are the only considerations, I would say to put this in, give > it a spin, see how it works for users. =A0But this is not an isolated > addition. > > The first other consideration is that new bytecodes amount to permanent > commitments. =A0We now have a handful of targets that think they know wha= t the > valid bytecodes are, but if we're adding new bytecodes to some but not > others, then we need to start doing some new infrastructure for the target > to tell the host about its supported bytecodes. > > The second consideration is that we have proposals for target-side > breakpoint handling on the table. =A0Mentor now has a contract to do some= work > on this, and we're going to be kicking off public design discussion within > the next few weeks. =A0So if we can do random breakpoint actions on the > target, with no GDB involvement, I think it removes a large part of the > motivation for this patch. > > So overall I think we should put this on the back burner for now, and foc= us > on target-side breakpoint handling instead. =A0There are some specific is= sues > that would have to addressed to make this particular patch acceptable (the > pervasive 100-byte limitation is hard to justify for instance), but I'd > rather put our brain power into achieving the real goal, rather than > piggybacking on tracepoints. > > Stan > >> 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 >> > >