From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25329 invoked by alias); 24 Feb 2011 08:37:28 -0000 Received: (qmail 25318 invoked by uid 22791); 24 Feb 2011 08:37:27 -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-yi0-f41.google.com (HELO mail-yi0-f41.google.com) (209.85.218.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Feb 2011 08:37:21 +0000 Received: by yib2 with SMTP id 2so214396yib.0 for ; Thu, 24 Feb 2011 00:37:19 -0800 (PST) Received: by 10.151.45.10 with SMTP id x10mr1578665ybj.71.1298536639253; Thu, 24 Feb 2011 00:37:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.147.125.2 with HTTP; Thu, 24 Feb 2011 00:36:59 -0800 (PST) From: Hui Zhu Date: Thu, 24 Feb 2011 08:51:00 -0000 Message-ID: Subject: [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 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-02/txt/msg00684.txt.bz2 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. But 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. It 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. Sometimes, 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. And sometime, it will disconnect. But if through tracepoint, I will not have this trouble. I can "set disconnected-tracing on" to handle the network disconnect issue. I still need to get the value from inferior through tfind and other commands. It is still be affect by the low speed network. So I make the tracepoint "printf" to handle it. 2. KGTP(https://code.google.com/p/kgtp/) just support the gdb tracepoint rsp commands. For not stop the Linux the Kernel. It 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, we can dump the gdbrsp package to a file and send to Kernel. Then kernel can be debug without a local gdb or a remote connect. But user still need copy the trace file to pc that have GDB. But 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 this 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. It will only be 1 (one argument) or 0 (no argument). I 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. It 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=$c+1,$rax,argc >end (gdb) target remote localhost:1234 (gdb) tstart (gdb) c gdbserver/gdbserver localhost:1234 ./a.out Process ./a.out created; pid = 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