From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49438 invoked by alias); 7 Feb 2020 22:14:40 -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 49430 invoked by uid 89); 7 Feb 2020 22:14:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: sonic314-20.consmr.mail.ir2.yahoo.com Received: from sonic314-20.consmr.mail.ir2.yahoo.com (HELO sonic314-20.consmr.mail.ir2.yahoo.com) (77.238.177.146) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 22:14:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1581113674; bh=INHdL/LDp7kkC4bNtydFkOoqWSJAF6oqJ4pFuoylEpc=; h=Date:From:To:In-Reply-To:References:Subject:From:Subject; b=aAhPbgbG/CflueQ3qHV9zcIriRoYDQ6TMyCYMg8LMYVZpA7K4gtmAY7vhMu+U4nJX7gqwFP3N8DntHo3eyZvP04HfOF9n1qLH3CyzgiS46W/9JQhrdxPNECFfQjVeckXQoeTRuLpNvTgOu3QSQQmG0CyTII6tJAX1ucxEnvVe0tRow0bRzg/M/kxymh5AR4IZF1rgjcjijhBrq0fwVfSnlwfCDZ0vFfSx8/otJf57sIJEM+59Hh+0y1beyQLnJKV3LRnrSbnPEWo7oIuOOHsQVxMUmRtALlPVcxXEjRvMSDti8EOramuKyTxiVD4yNPcdR9hYI9uetQ1NQlBr/aWrQ== Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 7 Feb 2020 22:14:34 +0000 Date: Fri, 07 Feb 2020 22:14:00 -0000 From: "Hannes Domani via gdb-patches" Reply-To: Hannes Domani To: Gdb-patches Message-ID: <1996157205.1748192.1581113672621@mail.yahoo.com> In-Reply-To: <544d0a3a-bee9-1ac6-8f4b-611ccbcc39bb@simark.ca> References: <20200117153140.2231-1-ssbssa.ref@yahoo.de> <20200117153140.2231-1-ssbssa@yahoo.de> <544d0a3a-bee9-1ac6-8f4b-611ccbcc39bb@simark.ca> Subject: Re: [PATCH 1/2] Display ExceptionRecord for $_siginfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00195.txt.bz2 Am Freitag, 7. Februar 2020, 22:56:18 MEZ hat Simon Marchi Folgendes geschrieben: > On 2020-01-17 10:31 a.m., Hannes Domani via gdb-patches wrote: > > diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c > > index 901e64263c..824ff4b322 100644 > > --- a/gdb/windows-nat.c > > +++ b/gdb/windows-nat.c > > @@ -236,6 +236,7 @@ static DEBUG_EVENT current_event;=C2=A0=C2=A0=C2=A0= /* The current debug event from > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 WaitForD= ebugEvent */ > >=C2=A0 static HANDLE current_process_handle;=C2=A0=C2=A0=C2=A0 /* Curren= tly executing process */ > >=C2=A0 static windows_thread_info *current_thread;=C2=A0=C2=A0=C2=A0 /* = Info on currently selected thread */ > > +static EXCEPTION_RECORD siginfo_er;=C2=A0=C2=A0=C2=A0 /* Contents of $= _siginfo */ > > Huh... I was going to say that it shouldn't be a global variable, but a p= er-inferior > thing (or is it per-thread?), but pretty much all the state is already gl= obal...=C2=A0 so > I guess it's fine.=C2=A0 I gather that the windows-nat does not support d= ebugging multiple > inferiors?=C2=A0 Same for win32-low in gdbserver? > > > > >=C2=A0 /* Counts of things.=C2=A0 */ > >=C2=A0 static int exception_count =3D 0; > > @@ -1166,6 +1167,8 @@ handle_exception (struct target_waitstatus *ourst= atus) > >=C2=A0=C2=A0=C2=A0 DWORD code =3D rec->ExceptionCode; > >=C2=A0=C2=A0=C2=A0 handle_exception_result result =3D HANDLE_EXCEPTION_H= ANDLED; > > > > +=C2=A0 memcpy (&siginfo_er, rec, sizeof siginfo_er); > > + > >=C2=A0=C2=A0=C2=A0 ourstatus->kind =3D TARGET_WAITKIND_STOPPED; > > > >=C2=A0=C2=A0=C2=A0 /* Record the context of the current thread.=C2=A0 */ > > @@ -2862,6 +2865,7 @@ windows_nat_target::mourn_inferior () > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CHECK (CloseHandle (current_p= rocess_handle)); > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 open_process_used =3D 0; > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > > +=C2=A0 siginfo_er.ExceptionCode =3D 0; > >=C2=A0=C2=A0=C2=A0 inf_child_target::mourn_inferior (); > >=C2=A0 } > > > > @@ -2994,6 +2998,28 @@ windows_xfer_shared_libraries (struct target_ops= *ops, > >=C2=A0=C2=A0=C2=A0 return len !=3D 0 ? TARGET_XFER_OK : TARGET_XFER_EOF; > >=C2=A0 } > > > > +static enum target_xfer_status > > +windows_xfer_siginfo (gdb_byte *readbuf, ULONGEST offset, ULONGEST len, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 ULONGEST *xfered_len) > > +{ > > +=C2=A0 if (!siginfo_er.ExceptionCode) > > siginfo_er.ExceptionCode !=3D 0 > > > +=C2=A0=C2=A0=C2=A0 return TARGET_XFER_E_IO; > > + > > +=C2=A0 if (!readbuf) > > readbuf =3D=3D nullptr > > > +=C2=A0=C2=A0=C2=A0 return TARGET_XFER_E_IO; > > + > > +=C2=A0 if (offset > sizeof (siginfo_er)) > > +=C2=A0=C2=A0=C2=A0 return TARGET_XFER_E_IO; > > + > > +=C2=A0 if (offset + len > sizeof (siginfo_er)) > > +=C2=A0=C2=A0=C2=A0 len =3D sizeof (siginfo_er) - offset; > > + > > +=C2=A0 memcpy (readbuf, (char *) &siginfo_er + offset, len); > > +=C2=A0 *xfered_len =3D len; > > + > > +=C2=A0 return TARGET_XFER_OK; > > +} > > + > >=C2=A0 enum target_xfer_status > >=C2=A0 windows_nat_target::xfer_partial (enum target_object object, > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *annex, gdb_byte *rea= dbuf, > > @@ -3009,6 +3035,9 @@ windows_nat_target::xfer_partial (enum target_obj= ect object, > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return windows_xfer_shared_li= braries (this, object, annex, readbuf, > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 writebuf, offset, len, xfered_len); > > > > +=C2=A0=C2=A0=C2=A0 case TARGET_OBJECT_SIGNAL_INFO: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return windows_xfer_siginfo (readbuf, o= ffset, len, xfered_len); > > + > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 default: > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (beneath () =3D=3D NULL) > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > > diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c > > index 1fc2748581..50efa31709 100644 > > --- a/gdb/windows-tdep.c > > +++ b/gdb/windows-tdep.c > > @@ -153,6 +153,26 @@ static const int FULL_TIB_SIZE =3D 0x1000; > > > >=C2=A0 static bool maint_display_all_tib =3D false; > > > > +static struct gdbarch_data *windows_gdbarch_data_handle; > > + > > +struct windows_gdbarch_data > > +=C2=A0 { > > +=C2=A0=C2=A0=C2=A0 struct type *siginfo_type; > > +=C2=A0 }; > > Unindent the curly braces and the field: > > { >=C2=A0=C2=A0 struct type *siginfo_type; > } > > I know there are some structures formatted this way, but the new ones we = add are > aligned on column 0. OK, I fill fix all these coding style problems and try to remember them. > > + > > +static void * > > +init_windows_gdbarch_data (struct gdbarch *gdbarch) > > +{ > > +=C2=A0 return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct windows_gdbarch_= data); > > +} > > + > > +static struct windows_gdbarch_data * > > +get_windows_gdbarch_data (struct gdbarch *gdbarch) > > +{ > > +=C2=A0 return ((struct windows_gdbarch_data *) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gdbarch_data (gdbarch, windows_gdbarch_= data_handle)); > > +} > > + > >=C2=A0 /* Define Thread Local Base pointer type.=C2=A0 */ > > > >=C2=A0 static struct type * > > @@ -648,6 +668,43 @@ windows_gdb_signal_to_target (struct gdbarch *gdba= rch, enum gdb_signal signal) > >=C2=A0=C2=A0=C2=A0 return -1; > >=C2=A0 } > > > > +static struct type * > > +windows_get_siginfo_type (struct gdbarch *gdbarch) > > +{ > > +=C2=A0 struct windows_gdbarch_data *windows_gdbarch_data; > > +=C2=A0 struct type *uint_type, *void_ptr_type; > > +=C2=A0 struct type *siginfo_ptr_type, *siginfo_type; > > + > > +=C2=A0 windows_gdbarch_data =3D get_windows_gdbarch_data (gdbarch); > > +=C2=A0 if (windows_gdbarch_data->siginfo_type !=3D NULL) > > +=C2=A0=C2=A0=C2=A0 return windows_gdbarch_data->siginfo_type; > > + > > +=C2=A0 uint_type =3D arch_integer_type (gdbarch, gdbarch_int_bit (gdba= rch), > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 1, "unsigned int"); > > You should be able to get this one from builtin_type (gdbarch)->builtin_u= nsigned_int. Good to know. > > +=C2=A0 void_ptr_type =3D lookup_pointer_type (builtin_type (gdbarch)->= builtin_void); > > + > > +=C2=A0 siginfo_type =3D arch_composite_type (gdbarch, "EXCEPTION_RECOR= D", > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TYPE_CODE_STRUCT); > > +=C2=A0 siginfo_ptr_type =3D arch_pointer_type (gdbarch, gdbarch_ptr_bi= t (gdbarch), > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NULL, siginfo_type); > > + > > +=C2=A0 append_composite_type_field (siginfo_type, "ExceptionCode", uin= t_type); > > +=C2=A0 append_composite_type_field (siginfo_type, "ExceptionFlags", ui= nt_type); > > +=C2=A0 append_composite_type_field (siginfo_type, "ExceptionRecord", > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 siginfo_ptr_type); > > +=C2=A0 append_composite_type_field (siginfo_type, "ExceptionAddress", > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void_ptr_type); > > +=C2=A0 append_composite_type_field (siginfo_type, "NumberParameters", = uint_type); > > +=C2=A0 append_composite_type_field_aligned (siginfo_type, "ExceptionIn= formation", > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 lookup_array_rang= e_type (void_ptr_type, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0, 14), > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TYPE_LENGTH (void= _ptr_type)); > > > Shouldn't you use "DWORD" and other types named like what is found in the > real structure, instead of plain "unsigned int"?=C2=A0 Like what is done = in > windows_get_tlb_type? > > As a user, I would expect that "ptype $_siginfo" shows me "DWORD" and not > "unsigned int", don't you think? Personally I didn't really care what the name of the type is, but you are right, it probably is what users expect, so I will change the type names accordingly. Regards Hannes Domani