From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21096 invoked by alias); 17 Dec 2012 15:43:46 -0000 Received: (qmail 20976 invoked by uid 22791); 17 Dec 2012 15:43:44 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-qa0-f48.google.com (HELO mail-qa0-f48.google.com) (209.85.216.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Dec 2012 15:43:38 +0000 Received: by mail-qa0-f48.google.com with SMTP id l8so2444737qaq.0 for ; Mon, 17 Dec 2012 07:43:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.18.136 with SMTP id w8mr6273931qaa.2.1355759017198; Mon, 17 Dec 2012 07:43:37 -0800 (PST) Received: by 10.49.12.210 with HTTP; Mon, 17 Dec 2012 07:43:36 -0800 (PST) In-Reply-To: References: Date: Mon, 17 Dec 2012 15:43:00 -0000 Message-ID: Subject: Re: [PATCH/RFC 01/02 v2] Refactor PRPSINFO handling on Binutils From: "H.J. Lu" To: Sergio Durigan Junior Cc: Binutils Development , GDB Patches , Pedro Alves Content-Type: text/plain; charset=ISO-8859-1 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: 2012-12/txt/msg00556.txt.bz2 On Sun, Dec 16, 2012 at 7:09 PM, Sergio Durigan Junior wrote: > Hi, > > This is a follow-up on: > > > Sorry for the delay on this. I addressed Pedro's and H.J.'s comments, > and took some time to test the patch on different architectures. > > It also took me some time to decide the best way to handle several > little issues that I was facing: different declarations for PPC needed, > different declarations for PRPSINFO structures, etc. > > Anyway, I hope I managed to solve these problems, but I would really > appreciate some comments (if you have, of course) about the code. The > idea was to simplify the handling of PRPSINFO, so: > > 1) I created elf_{internal,external}_prpsinfo* structures, organized > differently according to their purposes. > > 2) I created the new PRPSINFO*_COPY_FIELDS macros, which take care of > (duh) copying the fields from the internal to the external structures, > obeying bitness and such. > > 3) I also took the liberty to implement the i386 version of the > *_write_core_note. > > 4) I removed some dependency on the CORE_HEADER macro (suggested by > Pedro). Not sure if everything is correct, though. > > Anyway, I guess those are the main changes. Please let me know if you > have some question about the patch. Thanks. > > + > +static char * > +elf_i386_write_core_note (bfd *abfd, char *buf, int *bufsiz, > + int note_type, ...) > +{ > + const struct elf_backend_data *bed = get_elf_backend_data (abfd); > + va_list ap; > + const struct elf_internal_prpsinfo *prpsinfo; > + long pid; > + int cursig; > + const void *gregs; > + struct elf_external_prpsinfo32 data; > + > + switch (note_type) > + { > + default: > + return NULL; > + > + case NT_PRPSINFO: > + va_start (ap, note_type); > + prpsinfo = va_arg (ap, const struct elf_internal_prpsinfo *); > + va_end (ap); > + > + memset (&data, 0, sizeof (data)); > + PRPSINFO32_COPY_FIELDS (abfd, prpsinfo, data); > + > + return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, > + &data, sizeof (data)); > + /* NOTREACHED */ > + > + case NT_PRSTATUS: > + va_start (ap, note_type); > + pid = va_arg (ap, long); > + cursig = va_arg (ap, int); > + gregs = va_arg (ap, const void *); > + va_end (ap); > + > + if (bed->elf_machine_code == EM_X86_64) > + { > + prstatusx32_t prstat; > + memset (&prstat, 0, sizeof (prstat)); > + prstat.pr_pid = pid; > + prstat.pr_cursig = cursig; > + memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); > + return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, > + &prstat, sizeof (prstat)); > + } > + else When will elf_i386_write_core_note be called for x32 process? -- H.J.