From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96619 invoked by alias); 4 Jun 2019 12:35:53 -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 96611 invoked by uid 89); 4 Jun 2019 12:35:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mga17.intel.com Received: from mga17.intel.com (HELO mga17.intel.com) (192.55.52.151) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Jun 2019 12:35:51 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 05:35:49 -0700 Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga002.jf.intel.com with ESMTP; 04 Jun 2019 05:35:49 -0700 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by irsmsx105.ger.corp.intel.com (163.33.3.28) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 4 Jun 2019 13:35:48 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.93]) by irsmsx112.ger.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0415.000; Tue, 4 Jun 2019 13:35:48 +0100 From: "Metzger, Markus T" To: "Willgerodt, Felix" , "gdb-patches@sourceware.org" Subject: RE: [PATCH 04/10] btrace: Handle stepping and goto for auxiliary instructions. Date: Tue, 04 Jun 2019 12:35:00 -0000 Message-ID: References: <1559119673-30516-1-git-send-email-felix.willgerodt@intel.com> <1559119673-30516-5-git-send-email-felix.willgerodt@intel.com> In-Reply-To: <1559119673-30516-5-git-send-email-felix.willgerodt@intel.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Return-Path: markus.t.metzger@intel.com Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00054.txt.bz2 Hello Felix, > @@ -2378,13 +2380,26 @@ record_btrace_single_step_forward (struct thread_= info > *tp) > if (record_btrace_replay_at_breakpoint (tp)) > return btrace_step_stopped (); >=20 > - /* Skip gaps during replay. If we end up at a gap (at the end of the = trace), > - jump back to the instruction at which we started. */ > start =3D *replay; Please preserve the order of comment and code. > + > + /* Skip gaps during replay. If we end up at a gap (at the end of the = trace), > + jump back to the instruction at which we started. If we're steppin= g a > + BTRACE_INSN_AUX instruction, print the ptwrite string and skip the Should this say 'print the aux data'? > + instruction. */ > do > { > unsigned int steps; >=20 > + /* If we're stepping a BTRACE_INSN_AUX instruction, print the auxi= liary > + data and skip the instruction. If we are at the end of the trace, jump > + back to the instruction at which we started. */ > + bfun =3D &replay->btinfo->functions[replay->call_index]; > + next_insn =3D bfun->insn[replay->insn_index + 1]; The below btrace_insn_next () already advances REPLAY to the next instructi= on. You may use btrace_insn_next (replay) to get that instruction. > + > + if (next_insn.iclass =3D=3D BTRACE_INSN_AUX) > + printf_unfiltered ( > + "[%s]\n", btinfo->aux_data[next_insn.aux_data_index].c_str ()); > + > /* We will bail out here if we continue stepping after reaching th= e end > of the execution history. */ > steps =3D btrace_insn_next (replay, 1); > @@ -2394,7 +2409,8 @@ record_btrace_single_step_forward (struct thread_in= fo > *tp) > return btrace_step_no_history (); > } > } > - while (btrace_insn_get (replay) =3D=3D NULL); > + while (btrace_insn_get (replay) =3D=3D NULL > + || next_insn.iclass =3D=3D BTRACE_INSN_AUX); Since we now call btrace_insn_get (replay) inside the loop, we should rewri= te this. > @@ -2452,6 +2470,22 @@ record_btrace_single_step_backward (struct > thread_info *tp) > if (record_btrace_replay_at_breakpoint (tp)) > return btrace_step_stopped (); >=20 > + /* Check if we're stepping a BTRACE_INSN_AUX instruction and skip it. = */ > + bfun =3D &replay->btinfo->functions[replay->call_index]; > + prev_insn =3D bfun->insn[replay->insn_index]; Same here. > + > + if (prev_insn.iclass =3D=3D BTRACE_INSN_AUX) > + { > + printf_unfiltered ("[%s]\n", > + btinfo->aux_data[prev_insn.aux_data_index].c_str ()); > + unsigned int steps =3D btrace_insn_prev (replay, 1); > + if (steps =3D=3D 0) > + { > + *replay =3D start; > + return btrace_step_no_history (); > + } > + } > + > return btrace_step_spurious (); > } >=20 > @@ -2853,25 +2887,27 @@ record_btrace_target::goto_record_end () > /* The goto_record method of target record-btrace. */ >=20 > void > -record_btrace_target::goto_record (ULONGEST insn) > +record_btrace_target::goto_record (ULONGEST insn_number) > { > struct thread_info *tp; > struct btrace_insn_iterator it; > unsigned int number; > int found; >=20 > - number =3D insn; > + number =3D insn_number; >=20 > /* Check for wrap-arounds. */ > - if (number !=3D insn) > + if (number !=3D insn_number) > error (_("Instruction number out of range.")); >=20 > tp =3D require_btrace_thread (); >=20 > found =3D btrace_find_insn_by_number (&it, &tp->btrace, number); > + const struct btrace_insn *insn =3D btrace_insn_get (&it); You need to check FOUND before dereferencing IT. >=20 > - /* Check if the instruction could not be found or is a gap. */ > - if (found =3D=3D 0 || btrace_insn_get (&it) =3D=3D NULL) > + /* Check if the instruction could not be found or is a gap or an > + auxilliary instruction. */ > + if ((found =3D=3D 0) || (insn =3D=3D NULL) || (insn->iclass =3D=3D BTR= ACE_INSN_AUX)) > error (_("No such instruction.")); >=20 > record_btrace_set_replay (tp, &it); > -- > 2.20.1 Thanks, Markus. Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928