From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15512 invoked by alias); 1 Apr 2010 22:15:45 -0000 Received: (qmail 15221 invoked by uid 22791); 1 Apr 2010 22:15:38 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Apr 2010 22:15:32 +0000 Received: (qmail 2226 invoked from network); 1 Apr 2010 22:15:30 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Apr 2010 22:15:30 -0000 Message-ID: <4BB51AFC.1010303@codesourcery.com> Date: Thu, 01 Apr 2010 22:15:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Infer $pc in a file's trace frame Content-Type: multipart/mixed; boundary="------------040406050507010807050502" 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: 2010-04/txt/msg00029.txt.bz2 This is a multi-part message in MIME format. --------------040406050507010807050502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 590 This patch is a small usability enhancement from trace frames coming from a trace file; if registers have not been collected, then clear them all, and guess that $pc must be the same as the tracepoint's address. This isn't a good idea for either multi-location tracepoints or stepping frames though, and we want to warn the user about those cases. Stan 2010-04-01 Stan Shebs * tracepoint.c (tfile_fetch_registers): Add fallback case. * gdb.texinfo (Tracepoint Restrictions): Document PC inference. * gdb.trace/tfile.exp: Sharpen tfind test. --------------040406050507010807050502 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="pcinfer-patch-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pcinfer-patch-1" Content-length: 4514 Index: tracepoint.c =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.c,v retrieving revision 1.167 diff -p -r1.167 tracepoint.c *** tracepoint.c 1 Apr 2010 20:30:56 -0000 1.167 --- tracepoint.c 1 Apr 2010 22:03:06 -0000 *************** tfile_fetch_registers (struct target_ops *** 3664,3670 **** { struct gdbarch *gdbarch = get_regcache_arch (regcache); char block_type; ! int i, pos, offset, regn, regsize, gotten; unsigned short mlen; char *regs; --- 3664,3670 ---- { struct gdbarch *gdbarch = get_regcache_arch (regcache); char block_type; ! int i, pos, offset, regn, regsize, gotten, pc_regno; unsigned short mlen; char *regs; *************** tfile_fetch_registers (struct target_ops *** 3739,3744 **** --- 3739,3782 ---- break; } } + + /* We get here if no register data has been found. Although we + don't like making up numbers, GDB has all manner of troubles when + the target says some register is not available. Filling in with + zeroes is a reasonable fallback. */ + for (regn = 0; regn < gdbarch_num_regs (gdbarch); regn++) + regcache_raw_supply (regcache, regn, NULL); + + /* We can often usefully guess that the PC is going to be the same + as the address of the tracepoint. */ + pc_regno = gdbarch_pc_regnum (gdbarch); + if (pc_regno >= 0 && (regno == -1 || regno == pc_regno)) + { + struct breakpoint *tp = get_tracepoint (tracepoint_number); + + if (tp && tp->loc) + { + /* But don't try to guess if tracepoint is multi-location... */ + if (tp->loc->next) + { + warning ("Tracepoint %d has multiple locations, cannot infer $pc", + tp->number); + return; + } + /* ... or does while-stepping. */ + if (tp->step_count > 0) + { + warning ("Tracepoint %d does while-stepping, cannot infer $pc", + tp->number); + return; + } + + store_unsigned_integer (regs, register_size (gdbarch, pc_regno), + gdbarch_byte_order (gdbarch), + tp->loc->address); + regcache_raw_supply (regcache, pc_regno, regs); + } + } } static LONGEST Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.693 diff -p -r1.693 gdb.texinfo *** doc/gdb.texinfo 1 Apr 2010 14:11:23 -0000 1.693 --- doc/gdb.texinfo 1 Apr 2010 22:03:07 -0000 *************** using the @code{finish} command. This i *** 9032,9037 **** --- 9032,9050 ---- debugging information; after @code{finish}, you can step to the next line and print a variable where your program stored the return value. + @item + If you do not collect registers at a tracepoint, @value{GDBN} can + infer that the value of the PC is the address of the tracepoint and + display that when you are looking at a trace frame for that + tracepoint. However, this cannot work if the tracepoint has multiple + locations (for instance if it was set in a function that was inlined), + or if it has a @code{while-stepping} loop. In those cases + @value{GDBN} will warn you that it can't infer the PC, and default it + to zero. Also, @code{tdump} will use the list of collections for the + tracepoint proper, and not its stepping list, although the values + displayed will be correct for the stepping frame. Explicit print + commands will always work correctly. + @end itemize Index: testsuite/gdb.trace/tfile.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.trace/tfile.exp,v retrieving revision 1.4 diff -p -r1.4 tfile.exp *** testsuite/gdb.trace/tfile.exp 26 Mar 2010 01:46:29 -0000 1.4 --- testsuite/gdb.trace/tfile.exp 1 Apr 2010 22:03:07 -0000 *************** gdb_test "target tfile basic.tf" "Create *** 69,75 **** gdb_test "info trace" ".*tracepoint.*in write_basic_trace_file.*" \ "info tracepoints on trace file" ! gdb_test "tfind 0" "Found trace frame 0.*" "tfind 0 on trace file" gdb_test "print testglob" " = 31415" "print testglob on trace file" --- 69,78 ---- gdb_test "info trace" ".*tracepoint.*in write_basic_trace_file.*" \ "info tracepoints on trace file" ! gdb_test "tfind 0" \ ! "Found trace frame 0, tracepoint \[0-9\]+. ! \#0 write_basic_trace_file ().*" \ ! "tfind 0 on trace file" gdb_test "print testglob" " = 31415" "print testglob on trace file" --------------040406050507010807050502--