From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6294 invoked by alias); 20 Nov 2008 01:58:25 -0000 Received: (qmail 6238 invoked by uid 22791); 20 Nov 2008 01:58:23 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Nov 2008 01:57:48 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 479273B091; Wed, 19 Nov 2008 17:57:45 -0800 (PST) Received: from [10.20.92.151] (promb-2s-dhcp151.eng.vmware.com [10.20.92.151]) by mailhost4.vmware.com (Postfix) with ESMTP id 35B03C9A1C; Wed, 19 Nov 2008 17:57:45 -0800 (PST) Message-ID: <4924C417.5070206@vmware.com> Date: Thu, 20 Nov 2008 05:12:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: teawater CC: "gdb-patches@sourceware.org" Subject: Re: [RFA] Resubmit process record and replay, 7/10 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2008-11/txt/msg00526.txt.bz2 teawater wrote: > This patch add code to make GNU/Linux native-dependent code can record > execute log with itself. > > 2008-11-16 Hui Zhu > > Record execute log in linux-nat. > > * linux-nat.c (my_waitpid_record): New function. This function > can resume and wait inferior and record execute log of it. > (linux_nat_wait): If process record and replay target is used > and this is not a step resume, call function > "my_waitpid_record" instead function "my_waitpid". Hui, another name change suggestion: Instead of "my_waitpid_record", how about "process_record_waitpid"? I don't think it needs to have "linux" in the name, since it is a static function and can only be invoked from linux-nat.c. > > linux-nat.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 121 insertions(+), 1 deletion(-) > > > ------------------------------------------------------------------------ > > --- a/linux-nat.c > +++ b/linux-nat.c > @@ -50,6 +50,8 @@ > #include "event-loop.h" > #include "event-top.h" > > +#include "record.h" > + > #ifdef HAVE_PERSONALITY > # include > # if !HAVE_DECL_ADDR_NO_RANDOMIZE > @@ -518,6 +520,115 @@ my_waitpid (int pid, int *status, int fl > return ret; > } > > +extern struct bp_location *bp_location_chain; > +static struct lwp_info * find_lwp_pid (ptid_t ptid); > +static int > +my_waitpid_record (int pid, int *status, int flags) > +{ > + int ret; > + struct bp_location *bl; > + struct breakpoint *b; > + CORE_ADDR pc; > + CORE_ADDR decr_pc_after_break; > + struct lwp_info *lp; > + int is_breakpoint = 1; > + > +wait_begin: > + ret = my_waitpid (pid, status, flags); > + if (ret == -1) > + { > + return ret; > + } > + > + if (ret == 0) > + { > + goto wait_begin; > + } > + > + if (WIFSTOPPED (*status) && WSTOPSIG (*status) == SIGTRAP) > + { > + /* Check if there is a breakpoint. */ > + pc = 0; > + registers_changed (); > + for (bl = bp_location_chain; bl; bl = bl->global_next) > + { > + b = bl->owner; > + gdb_assert (b); > + if (b->enable_state != bp_enabled > + && b->enable_state != bp_permanent) > + continue; > + if (!pc) > + { > + pc = regcache_read_pc (get_thread_regcache (pid_to_ptid (ret))); > + } > + switch (b->type) > + { > + default: > + if (bl->address == pc) > + { > + goto out; > + } > + break; > + > + case bp_watchpoint: > + /*XXX teawater: I still not very clear how to deal with it. */ > + goto out; > + break; > + > + case bp_catchpoint: > + gdb_assert (b->ops != NULL && b->ops->breakpoint_hit != NULL); > + if (b->ops->breakpoint_hit (b)) > + { > + goto out; > + } > + break; > + > + case bp_hardware_watchpoint: > + case bp_read_watchpoint: > + case bp_access_watchpoint: > + if (STOPPED_BY_WATCHPOINT (0)) > + { > + goto out; > + } > + break; > + } > + } > + > + lp = find_lwp_pid (pid_to_ptid (ret)); > + if (lp) > + lp->stopped = 1; > + > + /* record message */ > + record_message (current_gdbarch); > + > + /* resume program */ > + linux_ops->to_resume (pid_to_ptid (ret), 1, TARGET_SIGNAL_0); > + goto wait_begin; > + } > + > + is_breakpoint = 0; > + > +out: > + /* Add gdbarch_decr_pc_after_break to pc because pc will be break at address > + add gdbarch_decr_pc_after_break when inferior non-step execute. */ > + if (is_breakpoint) > + { > + decr_pc_after_break = gdbarch_decr_pc_after_break > + (get_regcache_arch (get_thread_regcache (pid_to_ptid (ret)))); > + if (decr_pc_after_break) > + { > + if (!pc) > + { > + pc = regcache_read_pc (get_thread_regcache (pid_to_ptid (ret))); > + } > + regcache_write_pc (get_thread_regcache (pid_to_ptid (ret)), > + pc + decr_pc_after_break); > + } > + } > + > + return ret; > +} > + > /* Determine if PTRACE_O_TRACEFORK can be used to follow fork events. > > First, we try to enable fork tracing on ORIGINAL_PID. If this fails, > @@ -2876,7 +2987,16 @@ retry: > queued events. */ > lwpid = queued_waitpid (pid, &status, options); > else > - lwpid = my_waitpid (pid, &status, options); > + { > + if (RECORD_IS_USED && !record_resume_step) > + { > + lwpid = my_waitpid_record (pid, &status, options); > + } > + else > + { > + lwpid = my_waitpid (pid, &status, options); > + } > + } > > if (lwpid > 0) > {