From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32423 invoked by alias); 12 Jun 2009 02:25:34 -0000 Received: (qmail 32380 invoked by uid 22791); 12 Jun 2009 02:25:31 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Jun 2009 02:25:25 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MEwSH-0005vK-Ry for gdb-patches@sources.redhat.com; Fri, 12 Jun 2009 02:25:21 +0000 Received: from cpe0019e26b2db7-cm001692f4e452.cpe.net.cable.rogers.com ([99.224.129.49]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Jun 2009 02:25:21 +0000 Received: from aristovski by cpe0019e26b2db7-cm001692f4e452.cpe.net.cable.rogers.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Jun 2009 02:25:21 +0000 To: gdb-patches@sources.redhat.com From: Aleksandar Ristovski Subject: Re: [patch] nto-procfs.c: Add to_xfer_partial Date: Fri, 12 Jun 2009 02:25:00 -0000 Message-ID: <4A31BC81.50702@qnx.com> References: <002201c9eadc$a58129e0$f0837da0$@u-strasbg.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080002010303050205010300" User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: <002201c9eadc$a58129e0$f0837da0$@u-strasbg.fr> 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-06/txt/msg00332.txt.bz2 This is a multi-part message in MIME format. --------------080002010303050205010300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 460 Pierre Muller wrote: > Hi Aleksandar, Hello Pierre, Thank you for your comments. I think I have addressed all issues you listed. Please see attached patch. Thanks, -- Aleksandar Ristovski QNX Software Systems ChangeLog (remains the same): * nto-procfs.c (procfs_xfer_partial): New function. (init_procfs_ops): Register to_xfer_partial. * nto-tdep.h (nto_read_auxv_from_initial_stack): Declare. * nto-tdep.c (nto_read_auxv_from_initial_stack): Define. --------------080002010303050205010300 Content-Type: text/x-patch; name="nto-procfs-xfer_partial-20090611-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nto-procfs-xfer_partial-20090611-1.diff" Content-length: 4700 Index: gdb/nto-procfs.c =================================================================== RCS file: /cvs/src/src/gdb/nto-procfs.c,v retrieving revision 1.45 diff -u -p -r1.45 nto-procfs.c --- gdb/nto-procfs.c 7 Jun 2009 16:46:48 -0000 1.45 +++ gdb/nto-procfs.c 11 Jun 2009 20:27:35 -0000 @@ -774,6 +774,39 @@ procfs_xfer_memory (CORE_ADDR memaddr, g return (nbytes); } +static LONGEST +procfs_xfer_partial (struct target_ops *ops, enum target_object object, + const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, LONGEST len) +{ + if (object == TARGET_OBJECT_AUXV + && readbuf) + { + int err; + CORE_ADDR initial_stack; + debug_process_t procinfo; + + if (offset > 0) + return 0; + + err = devctl (ctl_fd, DCMD_PROC_INFO, &procinfo, sizeof procinfo, 0); + if (err != EOK) + return -1; + + /* Similar as in the case of a core file, we read auxv from + initial_stack. */ + initial_stack = procinfo.initial_stack; + + /* procfs is always 'self-hosted', no byte-order manipulation. */ + return nto_read_auxv_from_initial_stack (initial_stack, readbuf, len); + } + + if (ops->beneath && ops->beneath->to_xfer_partial) + return ops->beneath->to_xfer_partial (ops, object, annex, readbuf, + writebuf, offset, len); + return -1; +} + /* Take a program previously attached to and detaches it. The program resumes execution and will no longer stop on signals, etc. We'd better not have left any breakpoints @@ -1303,6 +1336,7 @@ init_procfs_ops (void) procfs_ops.to_store_registers = procfs_store_registers; procfs_ops.to_prepare_to_store = procfs_prepare_to_store; procfs_ops.deprecated_xfer_memory = procfs_xfer_memory; + procfs_ops.to_xfer_partial = procfs_xfer_partial; procfs_ops.to_files_info = procfs_files_info; procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint; procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint; Index: gdb/nto-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.h,v retrieving revision 1.15 diff -u -p -r1.15 nto-tdep.h --- gdb/nto-tdep.h 11 Jun 2009 19:29:00 -0000 1.15 +++ gdb/nto-tdep.h 11 Jun 2009 20:27:35 -0000 @@ -156,3 +156,7 @@ enum gdb_osabi nto_elf_osabi_sniffer (bf int nto_in_dynsym_resolve_code (CORE_ADDR pc); +LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack, + gdb_byte *readbuf, + LONGEST len); + #endif Index: gdb/nto-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.c,v retrieving revision 1.33 diff -u -p -r1.33 nto-tdep.c --- gdb/nto-tdep.c 11 Jun 2009 19:29:00 -0000 1.33 +++ gdb/nto-tdep.c 11 Jun 2009 20:27:35 -0000 @@ -385,6 +364,66 @@ nto_initialize_signals (void) #endif } +LONGEST +nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf, + LONGEST len) +{ + gdb_byte targ32[4]; /* For 32 bit target values. */ + CORE_ADDR data_ofs = 0; + ULONGEST anint; + LONGEST len_read = 0; + gdb_byte *buff; + /* For 32-bit architecture, size of auxv_t is 8 bytes. */ + const unsigned int sizeof_auxv_t = 8; + + /* Skip over argc, argv and envp... (see comment in ldd.c) */ + if (target_read_memory (initial_stack + data_ofs, targ32, sizeof (targ32)) + != 0) + return 0; + + anint = extract_unsigned_integer (targ32, sizeof (targ32)); + + /* Size of pointer is assumed to be 4 bytes (32 bit arch.) */ + data_ofs += (anint + 2) * sizeof (targ32); /* + 2 comes from argc itself and + NULL terminating pointer in + argv. */ + + /* Now loop over env table: */ + while (target_read_memory (initial_stack + data_ofs, targ32, sizeof (targ32)) + == 0) + { + anint = extract_unsigned_integer (targ32, sizeof (targ32)); + data_ofs += sizeof (targ32); + if (anint == 0) + break; + } + initial_stack += data_ofs; + + memset (readbuf, 0, len); + buff = readbuf; + while (len_read <= len-sizeof_auxv_t) + { + /* Search backwards until we have read AT_PHDR (num. 3), + AT_PHENT (num 4), AT_PHNUM (num 5) */ + if (target_read_memory (initial_stack, buff, sizeof_auxv_t) + == 0) + { + ULONGEST a_type = extract_unsigned_integer (buff, sizeof (targ32)); + if (a_type != AT_NULL) + { + buff += sizeof_auxv_t; + len_read += sizeof_auxv_t; + } + if (a_type == AT_PHNUM) /* That's all we need. */ + break; + initial_stack += sizeof_auxv_t; + } + else + break; + } + return len_read; +} + /* Provide a prototype to silence -Wmissing-prototypes. */ extern initialize_file_ftype _initialize_nto_tdep; --------------080002010303050205010300--