From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1012 invoked by alias); 7 Nov 2013 15:41:54 -0000 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 Received: (qmail 998 invoked by uid 89); 7 Nov 2013 15:41:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPAM_SUBJECT,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga09.intel.com Received: from Unknown (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Nov 2013 15:41:51 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 07 Nov 2013 07:38:15 -0800 X-ExtLoop1: 1 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga001.jf.intel.com with ESMTP; 07 Nov 2013 07:41:42 -0800 Received: from irsmsx151.ger.corp.intel.com (163.33.192.59) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 7 Nov 2013 15:41:41 +0000 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.89]) by IRSMSX151.ger.corp.intel.com ([169.254.4.252]) with mapi id 14.03.0123.003; Thu, 7 Nov 2013 15:41:41 +0000 From: "Metzger, Markus T" To: Jan Kratochvil CC: "gdb-patches@sourceware.org" Subject: RE: [+rfc] Re: [patch v6 00/21] record-btrace: reverse Date: Thu, 07 Nov 2013 15:44:00 -0000 Message-ID: References: <1379676639-31802-1-git-send-email-markus.t.metzger@intel.com> <20131006195913.GA2518@host2.jankratochvil.net> In-Reply-To: <20131006195913.GA2518@host2.jankratochvil.net> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00184.txt.bz2 > -----Original Message----- > From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com] > Sent: Sunday, October 06, 2013 9:59 PM Hello Jan, > Besides some nitpicks there remains the larger request > Re: [patch v4 23/24] record-btrace: add (reverse-)stepping support > https://sourceware.org/ml/gdb-patches/2013-09/msg01004.html > Message-ID: <20130930102533.GA29665@host2.jankratochvil.net> >=20 >=20 > to always use to_resume + to_wait for any change of history position. Th= is > also means the "hacks" like > +record_btrace_goto_end (void) > + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, > 1); > can be removed as normal GDB inferior stop will print the frame. >=20 > Other comments are welcome if it is not a too strict requirement from me > but > I think we could face some forgotten resetting of future caches avoiding = the > normal resume+wait path this way. Or ... we would not face them but it > would > violate localized of cache resets in to_resume+to_wait code path. I hacked a first prototype of this (see below). It passes most tests but results in three fails in the record_goto suite. One thing that it shows, though, is that it only removes the 'mostly harmle= ss' hack in the various goto functions shown above. The more serious hacks in record_btrace_start_replaying /* Make sure we're not using any stale registers. */ registers_changed_ptid (tp->ptid); /* We just started replaying. The frame id cached for stepping is based on unwinding, not on branch tracing. Recompute it. */ frame =3D get_current_frame_nocheck (); insn =3D btrace_insn_get (replay); sal =3D find_pc_line (insn->pc, 0); set_step_info (frame, sal); and record_btrace_stop_replaying /* Make sure we're not leaving any stale registers. */ registers_changed_ptid (tp->ptid); however, are not removed by this. They are required when reverse-stepping the first time or when stepping past the end of the execution trace. I don't think that there's a big benefit in pursuing this. Plus the patch = has the potential of messing things up pretty badly if somehow (maybe due to some unexpected error () somewhere in proceed ()) the record goto command does not complete and BTHR_GOTO remains set. Regards, Markus. diff --git a/gdb/btrace.h b/gdb/btrace.h index 5b52ec6..c1a5d14 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -169,7 +169,10 @@ enum btrace_thread_flag BTHR_RCONT =3D (1 << 3), =20 /* The thread is to be moved. */ - BTHR_MOVE =3D (BTHR_STEP | BTHR_RSTEP | BTHR_CONT | BTHR_RCONT) + BTHR_MOVE =3D (BTHR_STEP | BTHR_RSTEP | BTHR_CONT | BTHR_RCONT), + + /* The thread is to go to GOTO_TARGET in its BTINFO. */ + BTHR_GOTO =3D (1 << 4) }; =20 /* Branch trace information per thread. @@ -212,6 +215,9 @@ struct btrace_thread_info =20 /* The current replay position. NULL if not replaying. */ struct btrace_insn_iterator *replay; + + /* The goto target replay position. NULL if not active. */ + struct btrace_insn_iterator *goto_target; }; =20 /* Enable branch tracing for a thread. */ diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index f32f1fd..c559327 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1459,6 +1459,17 @@ record_btrace_step_thread (struct thread_info *tp) =20 DEBUG ("stepping %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), fl= ags); =20 + if ((btinfo->flags & BTHR_GOTO) !=3D 0) + { + btinfo->replay =3D btinfo->goto_target; + btinfo->goto_target =3D NULL; + btinfo->flags &=3D ~BTHR_GOTO; + + xfree (replay); + + return btrace_step_stopped (); + } + switch (flags) { default: @@ -1635,32 +1646,57 @@ record_btrace_find_new_threads (struct target_ops *= ops) } } =20 -/* Set the replay branch trace instruction iterator. If IT is NULL, replay +/* Move to the IT in the branch trace of TP. If IT is NULL, replay is stopped. */ =20 static void -record_btrace_set_replay (struct thread_info *tp, - const struct btrace_insn_iterator *it) +record_btrace_goto_target (struct thread_info *tp, + const struct btrace_insn_iterator *it) { + struct btrace_insn_iterator *goto_target; struct btrace_thread_info *btinfo; + struct target_waitstatus ws; =20 btinfo =3D &tp->btrace; =20 - if (it =3D=3D NULL || it->function =3D=3D NULL) - record_btrace_stop_replaying (tp); + if (btinfo->goto_target !=3D NULL || (btinfo->flags & BTHR_GOTO) !=3D 0) + error (_("Record goto already in progress.")); + + if ((btinfo->flags & BTHR_MOVE) !=3D 0) + error (_("Thread is already moving.")); + + /* If we're not replaying, to_resume might misinterpret our request. */ + if (btinfo->replay =3D=3D NULL) + record_btrace_start_replaying (tp); + + if (it =3D=3D NULL) + goto_target =3D NULL; else { - if (btinfo->replay =3D=3D NULL) - record_btrace_start_replaying (tp); - else if (btrace_insn_cmp (btinfo->replay, it) =3D=3D 0) - return; - - *btinfo->replay =3D *it; - registers_changed_ptid (tp->ptid); + goto_target =3D xmalloc (sizeof(*goto_target)); + *goto_target =3D *it; } =20 - /* Start anew from the new replay position. */ - record_btrace_clear_histories (btinfo); + btinfo->flags |=3D BTHR_GOTO; + btinfo->goto_target =3D goto_target; + +#if 0 + if (goto_target !=3D NULL) + tp->control.exception_resume_breakpoint =3D + set_momentary_breakpoint_at_pc (target_gdbarch (), + btrace_insn_get (goto_target)->pc, + bp_until); +#endif +#if 0 + target_resume (tp->ptid, 0, GDB_SIGNAL_0); + target_wait (tp->ptid, &ws, 0); +#else + clear_proceed_status (); + proceed ((CORE_ADDR) -1, GDB_SIGNAL_0, 0); +#endif + + if (btinfo->goto_target !=3D NULL || (btinfo->flags & BTHR_GOTO) !=3D 0) + error (_("Record goto failed.")); } =20 /* The to_goto_record_begin method of target record-btrace. */ @@ -1674,9 +1710,8 @@ record_btrace_goto_begin (void) tp =3D require_btrace_thread (); =20 btrace_insn_begin (&begin, &tp->btrace); - record_btrace_set_replay (tp, &begin); =20 - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); + record_btrace_goto_target (tp, &begin); } =20 /* The to_goto_record_end method of target record-btrace. */ @@ -1688,9 +1723,7 @@ record_btrace_goto_end (void) =20 tp =3D require_btrace_thread (); =20 - record_btrace_set_replay (tp, NULL); - - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); + record_btrace_goto_target (tp, NULL); } =20 /* The to_goto_record method of target record-btrace. */ @@ -1715,9 +1748,7 @@ record_btrace_goto (ULONGEST insn) if (found =3D=3D 0) error (_("No such instruction.")); =20 - record_btrace_set_replay (tp, &it); - - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); + record_btrace_goto_target (tp, &it); } =20 /* Initialize the record-btrace target ops. */ Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052