From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31660 invoked by alias); 3 Feb 2009 19:51:55 -0000 Received: (qmail 31652 invoked by uid 22791); 3 Feb 2009 19:51:55 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Feb 2009 19:51:47 +0000 Received: (qmail 4897 invoked from network); 3 Feb 2009 19:51:44 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Feb 2009 19:51:44 -0000 From: Pedro Alves To: Daniel Jacobowitz Subject: Re: [0/2] Inspect extra signal information Date: Tue, 03 Feb 2009 19:51:00 -0000 User-Agent: KMail/1.9.10 Cc: Ulrich Weigand , gdb-patches@sourceware.org References: <200902031501.49657.pedro@codesourcery.com> <200902031824.22132.pedro@codesourcery.com> <20090203190432.GA11419@caradoc.them.org> In-Reply-To: <20090203190432.GA11419@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200902031951.44699.pedro@codesourcery.com> 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: 2009-02/txt/msg00077.txt.bz2 On Tuesday 03 February 2009 19:04:32, Daniel Jacobowitz wrote: > On Tue, Feb 03, 2009 at 06:24:21PM +0000, Pedro Alves wrote: > > On Tuesday 03 February 2009 18:06:17, Daniel Jacobowitz wrote: > > > I like this idea. =A0We'd just need a "native siginfo to gdb siginfo" > > > routine, which could probably live in one common native-only file. > >=20 > > Hmmm, what do you mean exactly by "gdb siginfo" here? >=20 > Whatever type you've constructed via the gdbarch. >=20 There are two points of information here. First, the raw data of the siginfo_t object, passed around with TARGET_OBJECT_SIGNAL_INFO, which is implemented by both native linux target, and gdbserver. This transfers a block of raw data. Then, there's the the gdbarch built type, which is used to interpret the data. So, we're talking about making sure the TARGET_OBJECT_SIGNAL_INFO object is converted to a a 32-bit layout before reaching the core of gdb, to match what the type contructed by gdbarch will expect. I'd like to come up with something that works equally well and is simple, in both native gdb and gdbserver implementation sides. I hacked the below into linux-nat.c, which works OK for i386/amd64 just to see it work. The siginfo layout is different depending on the architecture, so although this layout works for some archs, it doesn't for others, e.g, mips, has this: typedef struct siginfo { int si_signo; /* Signal number. */ int si_code; /* Signal code. */ int si_errno; /* If non-zero, an errno value associated w= ith this signal, as defined in . */ int __pad0[__SI_MAX_SIZE / sizeof (int) - __SI_PAD_SIZE - 3]; ^^^^^^ union { I was thinking on doing this in the arch specific native files, e.g, gdb/amd64-linux-nat.c, gdb/ppc-linux-nat.c, etc., and something similar in gdbserver too. Just to make sure, where you perhaps thinking of something entirely different? I don't see how to make this in a common native file. --- src.orig/gdb/linux-nat.c 2009-02-03 19:20:49.000000000 +0000 +++ src/gdb/linux-nat.c 2009-02-03 19:26:33.000000000 +0000 @@ -3214,6 +3214,26 @@ linux_nat_mourn_inferior (struct target_ linux_fork_mourn_inferior (); } +struct gdb_siginfo32 + { + int si_signo; + int si_errno; + int si_code; + + union + { + int _pad[29]; + struct + { + int _si_pid; + unsigned int _si_uid; + int _si_status; + int _si_utime; + int _si_stime; + } _sigchld; + } _sifields; + }; + static LONGEST linux_xfer_siginfo (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, @@ -3239,6 +3259,25 @@ linux_xfer_siginfo (struct target_ops *o if (errno !=3D 0) return -1; + if (gdbarch_addr_bit (current_gdbarch) =3D=3D 32) + { + struct gdb_siginfo32 siginfo32; + struct siginfo sigi; + + gdb_assert (sizeof (siginfo32) =3D=3D sizeof (siginfo)); + + siginfo32.si_signo =3D siginfo.si_signo; + siginfo32.si_errno =3D siginfo.si_errno; + siginfo32.si_code =3D siginfo.si_code; + siginfo32._sifields._sigchld._si_pid =3D siginfo.si_pid; + siginfo32._sifields._sigchld._si_uid =3D siginfo.si_uid; + siginfo32._sifields._sigchld._si_status =3D siginfo.si_status; + siginfo32._sifields._sigchld._si_utime =3D siginfo.si_utime; + siginfo32._sifields._sigchld._si_stime =3D siginfo.si_stime; + + memcpy (&siginfo, &siginfo32, sizeof (siginfo)); + } + --=20 Pedro Alves