* [patch] nto-procfs.c: Add to_xfer_partial
@ 2009-06-11 20:31 Aleksandar Ristovski
2009-06-11 21:36 ` Pierre Muller
0 siblings, 1 reply; 12+ messages in thread
From: Aleksandar Ristovski @ 2009-06-11 20:31 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 349 bytes --]
Hello,
This adds to_xfer_partial (auxv) capability to nto-procfs.
Thanks,
--
Aleksandar Ristovski
QNX Software Systems
ChangeLog:
* 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.
[-- Attachment #2: nto-procfs-xfer_partial-20090611.diff --]
[-- Type: text/x-patch, Size: 4520 bytes --]
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,62 @@ nto_initialize_signals (void)
#endif
}
+LONGEST
+nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf,
+ LONGEST len)
+{
+ int data_ofs = 0;
+ int anint32;
+ LONGEST len_read = 0;
+ gdb_byte *panint32 = (gdb_byte*)&anint32;
+ gdb_byte *buff;
+
+ /* Skip over argc, argv and envp... (see comment in ldd.c) */
+ if (target_read_memory (initial_stack + data_ofs, panint32, 4) != 0)
+ return 0;
+
+ anint32 = extract_unsigned_integer (panint32, sizeof (anint32));
+
+ /* Size of pointer is assumed to be 4 bytes (32 bit arch. ) */
+ data_ofs += (anint32 + 2) * 4; /* + 2 comes from argc itself and
+ NULL terminating pointer in argv */
+
+ /* Now loop over env table: */
+ while (target_read_memory (initial_stack + data_ofs, panint32, 4) == 0)
+ {
+ anint32 = extract_signed_integer (panint32, sizeof (anint32));
+ data_ofs += 4;
+ if (anint32 == 0)
+ break;
+ }
+ initial_stack += data_ofs;
+
+ memset (readbuf, 0, len);
+ buff = readbuf;
+ while (len_read <= len-8)
+ {
+ /* For 32-bit architecture, size of auxv_t is 8 bytes. */
+
+ /* 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, 8)
+ == 0)
+ {
+ int a_type = extract_signed_integer (buff, sizeof (a_type));
+ if (a_type != AT_NULL)
+ {
+ buff += 8;
+ len_read += 8;
+ }
+ if (a_type == AT_PHNUM) /* That's all we need. */
+ break;
+ initial_stack += 8;
+ }
+ else
+ break;
+ }
+ return len_read;
+}
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_nto_tdep;
^ permalink raw reply [flat|nested] 12+ messages in thread* RE: [patch] nto-procfs.c: Add to_xfer_partial 2009-06-11 20:31 [patch] nto-procfs.c: Add to_xfer_partial Aleksandar Ristovski @ 2009-06-11 21:36 ` Pierre Muller 2009-06-12 2:25 ` Aleksandar Ristovski 0 siblings, 1 reply; 12+ messages in thread From: Pierre Muller @ 2009-06-11 21:36 UTC (permalink / raw) To: 'Aleksandar Ristovski', gdb-patches Hi Aleksandar, I can't comment on the correctness of your code to nto_read_auxv_from_initial_stack, but I think that you should avoid using 'int' and assume that 'int' is 32-bit long in a tdep file. + int anint32; + LONGEST len_read = 0; + gdb_byte *panint32 = (gdb_byte*)&anint32; + gdb_byte *buff; + + /* Skip over argc, argv and envp... (see comment in ldd.c) */ + if (target_read_memory (initial_stack + data_ofs, panint32, 4) != 0) + return 0; + + anint32 = extract_unsigned_integer (panint32, sizeof (anint32)); if sizeof(int) is not 4 on the host machine, your code will not work correctly. Moreover, you are using an 'int' to store an 'unsigned int'... It would probably be better to use gdb_byte anint32[4]; and ULONGEST uint32value uint32value = extract_unsigned_integer (&anint32, sizeof (anint32)); Please remember that tdep files should be compilable by systems having different endianess, but also pointer and/or standard integer sizes. Pierre Muller Pascal language support maintainer for GDB > -----Message d'origine----- > De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Aleksandar Ristovski > Envoyé : Thursday, June 11, 2009 10:31 PM > À : gdb-patches@sources.redhat.com > Objet : [patch] nto-procfs.c: Add to_xfer_partial > > Hello, > > This adds to_xfer_partial (auxv) capability to nto-procfs. > > Thanks, > > -- > Aleksandar Ristovski > QNX Software Systems > > > ChangeLog: > * 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. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-06-11 21:36 ` Pierre Muller @ 2009-06-12 2:25 ` Aleksandar Ristovski 2009-06-12 6:55 ` Pierre Muller 0 siblings, 1 reply; 12+ messages in thread From: Aleksandar Ristovski @ 2009-06-12 2:25 UTC (permalink / raw) To: gdb-patches [-- Attachment #1: Type: text/plain, Size: 460 bytes --] 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. [-- Attachment #2: nto-procfs-xfer_partial-20090611-1.diff --] [-- Type: text/x-patch, Size: 4700 bytes --] 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; ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [patch] nto-procfs.c: Add to_xfer_partial 2009-06-12 2:25 ` Aleksandar Ristovski @ 2009-06-12 6:55 ` Pierre Muller 2009-06-18 15:16 ` Aleksandar Ristovski 0 siblings, 1 reply; 12+ messages in thread From: Pierre Muller @ 2009-06-12 6:55 UTC (permalink / raw) To: 'Aleksandar Ristovski', gdb-patches Hi Aleksandar, > -----Message d'origine----- > De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Aleksandar Ristovski > Envoyé : Friday, June 12, 2009 4:25 AM > À : gdb-patches@sources.redhat.com > Objet : Re: [patch] nto-procfs.c: Add to_xfer_partial > > 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, I agree that you addressed my concerns. As I said earlier, I am unable to evaluate the patch in its functionality. Thanks for your fast reply, Pierre Muller Pascal language support maintainer for GDB ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-06-12 6:55 ` Pierre Muller @ 2009-06-18 15:16 ` Aleksandar Ristovski 2009-07-07 16:23 ` Aleksandar Ristovski 0 siblings, 1 reply; 12+ messages in thread From: Aleksandar Ristovski @ 2009-06-18 15:16 UTC (permalink / raw) To: gdb-patches is this ok to commit? Pierre Muller wrote: > Hi Aleksandar, > > >> -----Message d'origine----- >> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- >> owner@sourceware.org] De la part de Aleksandar Ristovski >> Envoyé : Friday, June 12, 2009 4:25 AM >> à : gdb-patches@sources.redhat.com >> Objet : Re: [patch] nto-procfs.c: Add to_xfer_partial >> >> 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, > I agree that you addressed my concerns. > As I said earlier, I am unable to evaluate the patch > in its functionality. > > Thanks for your fast reply, > > > Pierre Muller > Pascal language support maintainer for GDB > > > > -- Aleksandar Ristovski QNX Software Systems ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-06-18 15:16 ` Aleksandar Ristovski @ 2009-07-07 16:23 ` Aleksandar Ristovski 2009-07-21 15:45 ` Aleksandar Ristovski 2009-07-24 14:16 ` Pedro Alves 0 siblings, 2 replies; 12+ messages in thread From: Aleksandar Ristovski @ 2009-07-07 16:23 UTC (permalink / raw) To: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1257 bytes --] ping? Attached patch is updated to reflect changes that went in meanwhile (passing byte order to extract_unsigned_integer). ChangeLog: * nto-procfs.c (procfs_xfer_partial): New function. (init_procfs_ops): Register to_xfer_partial. * nto-tdep.c (nto_read_auxv_from_initial_stack): Define. * nto-tdep.h (nto_read_auxv_from_initial_stack): Declare. Aleksandar Ristovski wrote: > is this ok to commit? > > Pierre Muller wrote: >> Hi Aleksandar, >> >>> -----Message d'origine----- >>> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- >>> owner@sourceware.org] De la part de Aleksandar Ristovski >>> Envoyé : Friday, June 12, 2009 4:25 AM >>> à : gdb-patches@sources.redhat.com >>> Objet : Re: [patch] nto-procfs.c: Add to_xfer_partial >>> >>> 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, >> I agree that you addressed my concerns. As I said earlier, I am >> unable to evaluate the patch >> in its functionality. >> >> Thanks for your fast reply, >> >> >> Pierre Muller >> Pascal language support maintainer for GDB >> >> >> >> > > Thanks, -- Aleksandar Ristovski QNX Software Systems [-- Attachment #2: nto-procfs-xfer_partial-20090707.diff --] [-- Type: text/x-patch, Size: 4834 bytes --] Index: gdb/nto-procfs.c =================================================================== RCS file: /cvs/src/src/gdb/nto-procfs.c,v retrieving revision 1.47 diff -u -p -r1.47 nto-procfs.c --- gdb/nto-procfs.c 2 Jul 2009 17:12:25 -0000 1.47 +++ gdb/nto-procfs.c 7 Jul 2009 16:16:23 -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 @@ -1307,6 +1340,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.c =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.c,v retrieving revision 1.34 diff -u -p -r1.34 nto-tdep.c --- gdb/nto-tdep.c 12 Jun 2009 02:32:10 -0000 1.34 +++ gdb/nto-tdep.c 7 Jul 2009 16:16:23 -0000 @@ -364,6 +364,70 @@ 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; + enum bfd_endian byte_order; + + /* 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; + + byte_order = gdbarch_byte_order (target_gdbarch); + + anint = extract_unsigned_integer (targ32, sizeof (targ32), byte_order); + + /* 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), byte_order); + 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), + byte_order); + 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; Index: gdb/nto-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.h,v retrieving revision 1.16 diff -u -p -r1.16 nto-tdep.h --- gdb/nto-tdep.h 12 Jun 2009 02:32:10 -0000 1.16 +++ gdb/nto-tdep.h 7 Jul 2009 16:16:23 -0000 @@ -162,4 +162,8 @@ void nto_dummy_supply_regset (struct reg 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-07 16:23 ` Aleksandar Ristovski @ 2009-07-21 15:45 ` Aleksandar Ristovski 2009-07-24 14:16 ` Pedro Alves 1 sibling, 0 replies; 12+ messages in thread From: Aleksandar Ristovski @ 2009-07-21 15:45 UTC (permalink / raw) To: gdb-patches ping again? Aleksandar Ristovski wrote: > ping? > > Attached patch is updated to reflect changes that went in meanwhile > (passing byte order to extract_unsigned_integer). > > ChangeLog: > > * nto-procfs.c (procfs_xfer_partial): New function. > (init_procfs_ops): Register to_xfer_partial. > * nto-tdep.c (nto_read_auxv_from_initial_stack): Define. > * nto-tdep.h (nto_read_auxv_from_initial_stack): Declare. > > > > Aleksandar Ristovski wrote: >> is this ok to commit? >> >> Pierre Muller wrote: >>> Hi Aleksandar, >>> >>>> -----Message d'origine----- >>>> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- >>>> owner@sourceware.org] De la part de Aleksandar Ristovski >>>> Envoyé : Friday, June 12, 2009 4:25 AM >>>> à : gdb-patches@sources.redhat.com >>>> Objet : Re: [patch] nto-procfs.c: Add to_xfer_partial >>>> >>>> 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, >>> I agree that you addressed my concerns. As I said earlier, I am >>> unable to evaluate the patch >>> in its functionality. >>> >>> Thanks for your fast reply, >>> >>> >>> Pierre Muller >>> Pascal language support maintainer for GDB >>> >>> >>> >>> >> >> > > > Thanks, > -- Aleksandar Ristovski QNX Software Systems ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-07 16:23 ` Aleksandar Ristovski 2009-07-21 15:45 ` Aleksandar Ristovski @ 2009-07-24 14:16 ` Pedro Alves 2009-07-27 20:17 ` Aleksandar Ristovski 1 sibling, 1 reply; 12+ messages in thread From: Pedro Alves @ 2009-07-24 14:16 UTC (permalink / raw) To: gdb-patches; +Cc: Aleksandar Ristovski On Tuesday 07 July 2009 17:22:39, Aleksandar Ristovski wrote: > Index: gdb/nto-procfs.c > =================================================================== > RCS file: /cvs/src/src/gdb/nto-procfs.c,v > retrieving revision 1.47 > diff -u -p -r1.47 nto-procfs.c > --- gdb/nto-procfs.c 2 Jul 2009 17:12:25 -0000 1.47 > +++ gdb/nto-procfs.c 7 Jul 2009 16:16:23 -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 (ops->beneath && ops->beneath->to_xfer_partial) > + return ops->beneath->to_xfer_partial (ops, object, annex, readbuf, > + writebuf, offset, len); (( Note: It isn't correct to defer to the target beneath for TARGET_OBJECT_MEMORY (and similars) objects, but, I see that nto-procfs.c is still implementing deprecated_xfer_memory. )) > + 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 > @@ -1307,6 +1340,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.c > =================================================================== > RCS file: /cvs/src/src/gdb/nto-tdep.c,v > retrieving revision 1.34 > diff -u -p -r1.34 nto-tdep.c > --- gdb/nto-tdep.c 12 Jun 2009 02:32:10 -0000 1.34 > +++ gdb/nto-tdep.c 7 Jul 2009 16:16:23 -0000 > @@ -364,6 +364,70 @@ 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; NTO doesn't support any 64-bit architecture? > + enum bfd_endian byte_order; > + > + /* 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; Can you paste here that ldd.c comment too? You had pasted it in the equivalent gdbserver bit. Otherwise, looks fine to me. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-24 14:16 ` Pedro Alves @ 2009-07-27 20:17 ` Aleksandar Ristovski 2009-07-28 12:01 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: Aleksandar Ristovski @ 2009-07-27 20:17 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 2060 bytes --] Hello Pedro, Thanks for reviewing. Pedro Alves wrote: > On Tuesday 07 July 2009 17:22:39, Aleksandar Ristovski wrote: > >> Index: gdb/nto-procfs.c >> =================================================================== >> RCS file: /cvs/src/src/gdb/nto-procfs.c,v >> retrieving revision 1.47 >> diff -u -p -r1.47 nto-procfs.c >> --- gdb/nto-procfs.c 2 Jul 2009 17:12:25 -0000 1.47 >> +++ gdb/nto-procfs.c 7 Jul 2009 16:16:23 -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 (ops->beneath && ops->beneath->to_xfer_partial) >> + return ops->beneath->to_xfer_partial (ops, object, annex, readbuf, >> + writebuf, offset, len); > > (( Note: It isn't correct to defer to the target beneath for > TARGET_OBJECT_MEMORY (and similars) objects, but, I see that nto-procfs.c > is still implementing deprecated_xfer_memory. )) Did you want me to make changes here? >> + /* For 32-bit architecture, size of auxv_t is 8 bytes. */ >> + const unsigned int sizeof_auxv_t = 8; > > NTO doesn't support any 64-bit architecture? No, not yet. > >> + enum bfd_endian byte_order; >> + >> + /* 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; > > Can you paste here that ldd.c comment too? You had pasted it in the > equivalent gdbserver bit. Done. > > Otherwise, looks fine to me. > Thanks, -- Aleksandar Ristovski QNX Software Systems ChangeLog: * nto-procfs.c (procfs_xfer_partial): New function. (init_procfs_ops): Register to_xfer_partial. * nto-tdep.c (nto_read_auxv_from_initial_stack): Define. * nto-tdep.h (nto_read_auxv_from_initial_stack): Declare. [-- Attachment #2: nto-procfs-xfer_partial-20090727.diff --] [-- Type: text/x-patch, Size: 5141 bytes --] Index: gdb/nto-procfs.c =================================================================== RCS file: /cvs/src/src/gdb/nto-procfs.c,v retrieving revision 1.47 diff -u -p -r1.47 nto-procfs.c --- gdb/nto-procfs.c 2 Jul 2009 17:12:25 -0000 1.47 +++ gdb/nto-procfs.c 27 Jul 2009 19:39:36 -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 @@ -1307,6 +1340,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.c =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.c,v retrieving revision 1.34 diff -u -p -r1.34 nto-tdep.c --- gdb/nto-tdep.c 12 Jun 2009 02:32:10 -0000 1.34 +++ gdb/nto-tdep.c 27 Jul 2009 19:39:37 -0000 @@ -364,6 +364,84 @@ 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; + enum bfd_endian byte_order; + + /* Skip over argc, argv and envp... Comment from ldd.c: + + The startup frame is set-up so that we have: + auxv + NULL + ... + envp2 + envp1 <----- void *frame + (argc + 2) * sizeof(char *) + NULL + ... + argv2 + argv1 + argc <------ void * frame + + On entry to ldd, frame gives the address of argc on the stack. */ + if (target_read_memory (initial_stack + data_ofs, targ32, sizeof (targ32)) + != 0) + return 0; + + byte_order = gdbarch_byte_order (target_gdbarch); + + anint = extract_unsigned_integer (targ32, sizeof (targ32), byte_order); + + /* 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), byte_order); + 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), + byte_order); + 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; Index: gdb/nto-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.h,v retrieving revision 1.16 diff -u -p -r1.16 nto-tdep.h --- gdb/nto-tdep.h 12 Jun 2009 02:32:10 -0000 1.16 +++ gdb/nto-tdep.h 27 Jul 2009 19:39:37 -0000 @@ -162,4 +162,8 @@ void nto_dummy_supply_regset (struct reg 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-27 20:17 ` Aleksandar Ristovski @ 2009-07-28 12:01 ` Pedro Alves 2009-07-28 22:17 ` Aleksandar Ristovski 0 siblings, 1 reply; 12+ messages in thread From: Pedro Alves @ 2009-07-28 12:01 UTC (permalink / raw) To: Aleksandar Ristovski; +Cc: gdb-patches On Monday 27 July 2009 20:44:51, Aleksandar Ristovski wrote: > Pedro Alves wrote: > > (( Note: It isn't correct to defer to the target beneath for > > TARGET_OBJECT_MEMORY (and similars) objects, but, I see that nto-procfs.c > > is still implementing deprecated_xfer_memory. )) > > Did you want me to make changes here? Nope, consider it an FYI. > > >> + /* For 32-bit architecture, size of auxv_t is 8 bytes. */ > >> + const unsigned int sizeof_auxv_t = 8; > > > > NTO doesn't support any 64-bit architecture? > > No, not yet. Okay. > > > > >> + enum bfd_endian byte_order; > >> + > >> + /* 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; > > > > Can you paste here that ldd.c comment too? You had pasted it in the > > equivalent gdbserver bit. > > Done. Thanks! On Monday 27 July 2009 20:44:51, Aleksandar Ristovski wrote: > +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; This offset > 0 check isn't really correct. Would it be hard to make this work with partial transfers? -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-28 12:01 ` Pedro Alves @ 2009-07-28 22:17 ` Aleksandar Ristovski 2009-08-24 11:34 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: Aleksandar Ristovski @ 2009-07-28 22:17 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1853 bytes --] Pedro Alves wrote: > On Monday 27 July 2009 20:44:51, Aleksandar Ristovski wrote: >> Pedro Alves wrote: >>> (( Note: It isn't correct to defer to the target beneath for >>> TARGET_OBJECT_MEMORY (and similars) objects, but, I see that nto-procfs.c >>> is still implementing deprecated_xfer_memory. )) >> Did you want me to make changes here? > > Nope, consider it an FYI. > >>>> + /* For 32-bit architecture, size of auxv_t is 8 bytes. */ >>>> + const unsigned int sizeof_auxv_t = 8; >>> NTO doesn't support any 64-bit architecture? >> No, not yet. > > Okay. > >>>> + enum bfd_endian byte_order; >>>> + >>>> + /* 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; >>> Can you paste here that ldd.c comment too? You had pasted it in the >>> equivalent gdbserver bit. >> Done. > > Thanks! > > On Monday 27 July 2009 20:44:51, Aleksandar Ristovski wrote: >> +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; > > This offset > 0 check isn't really correct. Would it be hard to > make this work with partial transfers? > Implemented. -- Aleksandar Ristovski QNX Software Systems ChangeLog: * nto-procfs.c (procfs_xfer_partial): New function. (init_procfs_ops): Register to_xfer_partial. * nto-tdep.c (nto_read_auxv_from_initial_stack): Define. * nto-tdep.h (nto_read_auxv_from_initial_stack): Declare. [-- Attachment #2: nto-procfs-xfer_partial-20090728.diff --] [-- Type: text/x-patch, Size: 5723 bytes --] Index: gdb/nto-procfs.c =================================================================== RCS file: /cvs/src/src/gdb/nto-procfs.c,v retrieving revision 1.48 diff -u -p -r1.48 nto-procfs.c --- gdb/nto-procfs.c 28 Jul 2009 13:20:26 -0000 1.48 +++ gdb/nto-procfs.c 28 Jul 2009 20:16:21 -0000 @@ -872,6 +872,56 @@ 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_MEMORY) + { + int nbytes = 0; + + if (readbuf) + return (*ops->deprecated_xfer_memory) (offset, readbuf, + len, 0, NULL, ops); + else if (writebuf) + return (*ops->deprecated_xfer_memory) (offset, (gdb_byte*) writebuf, + len, 1, NULL, ops); + else + return 0; + } + else if (object == TARGET_OBJECT_AUXV && readbuf) + { + int err; + CORE_ADDR initial_stack; + debug_process_t procinfo; + /* For 32-bit architecture, size of auxv_t is 8 bytes. */ + const unsigned int sizeof_auxv_t = 8; + const unsigned int sizeof_tempbuf = 20 * sizeof_auxv_t; + int tempread; + gdb_byte *tempbuf = alloca (sizeof_tempbuf); + + if (!tempbuf) + return -1; + + err = devctl (ctl_fd, DCMD_PROC_INFO, &procinfo, sizeof procinfo, 0); + if (err != EOK) + return 0; + + /* 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. */ + tempread = nto_read_auxv_from_initial_stack (initial_stack, tempbuf, + sizeof_tempbuf); + tempread = min (tempread, len) - offset; + memcpy (readbuf, tempbuf + offset, tempread); + return tempread; + } + 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 @@ -1405,6 +1455,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.c =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.c,v retrieving revision 1.35 diff -u -p -r1.35 nto-tdep.c --- gdb/nto-tdep.c 28 Jul 2009 13:20:26 -0000 1.35 +++ gdb/nto-tdep.c 28 Jul 2009 20:16:22 -0000 @@ -398,6 +398,84 @@ 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; + enum bfd_endian byte_order; + + /* Skip over argc, argv and envp... Comment from ldd.c: + + The startup frame is set-up so that we have: + auxv + NULL + ... + envp2 + envp1 <----- void *frame + (argc + 2) * sizeof(char *) + NULL + ... + argv2 + argv1 + argc <------ void * frame + + On entry to ldd, frame gives the address of argc on the stack. */ + if (target_read_memory (initial_stack + data_ofs, targ32, sizeof (targ32)) + != 0) + return 0; + + byte_order = gdbarch_byte_order (target_gdbarch); + + anint = extract_unsigned_integer (targ32, sizeof (targ32), byte_order); + + /* 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), byte_order); + 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), + byte_order); + 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; Index: gdb/nto-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/nto-tdep.h,v retrieving revision 1.17 diff -u -p -r1.17 nto-tdep.h --- gdb/nto-tdep.h 28 Jul 2009 13:20:26 -0000 1.17 +++ gdb/nto-tdep.h 28 Jul 2009 20:16:22 -0000 @@ -173,4 +173,8 @@ int nto_in_dynsym_resolve_code (CORE_ADD char *nto_extra_thread_info (struct thread_info *); +LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack, + gdb_byte *readbuf, + LONGEST len); + #endif ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] nto-procfs.c: Add to_xfer_partial 2009-07-28 22:17 ` Aleksandar Ristovski @ 2009-08-24 11:34 ` Pedro Alves 0 siblings, 0 replies; 12+ messages in thread From: Pedro Alves @ 2009-08-24 11:34 UTC (permalink / raw) To: Aleksandar Ristovski; +Cc: gdb-patches On Tuesday 28 July 2009 21:20:04, Aleksandar Ristovski wrote: > Pedro Alves wrote: > > On Monday 27 July 2009 20:44:51, Aleksandar Ristovski wrote: > >> Pedro Alves wrote: > >>> (( Note: It isn't correct to defer to the target beneath for > >>> TARGET_OBJECT_MEMORY (and similars) objects, but, I see that nto-procfs.c > >>> is still implementing deprecated_xfer_memory. )) > >> Did you want me to make changes here? > > > > Nope, consider it an FYI. > > > > This offset > 0 check isn't really correct. Would it be hard to > > make this work with partial transfers? > > > > Implemented. > Thanks! On Tuesday 28 July 2009 21:20:04, Aleksandar Ristovski wrote: > ndex: gdb/nto-procfs.c > =================================================================== > RCS file: /cvs/src/src/gdb/nto-procfs.c,v > retrieving revision 1.48 > diff -u -p -r1.48 nto-procfs.c > --- gdb/nto-procfs.c 28 Jul 2009 13:20:26 -0000 1.48 > +++ gdb/nto-procfs.c 28 Jul 2009 20:16:21 -0000 > @@ -872,6 +872,56 @@ 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_MEMORY) > + { > + int nbytes = 0; > + > + if (readbuf) > + return (*ops->deprecated_xfer_memory) (offset, readbuf, > + len, 0, NULL, ops); > + else if (writebuf) > + return (*ops->deprecated_xfer_memory) (offset, (gdb_byte*) writebuf, > + len, 1, NULL, ops); > + else > + return 0; > + } Hmmm, copying from procfs.c, are we? If you're going as far as implementing TARGET_OBJECT_MEMORY, then why stop there and still defer to ops->deprecated_xfer_memory? You could just ... > @@ -1405,6 +1455,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; ... not install this ^^^^ and have procfs_xfer_partial call procfs_xfer_memory directly (might as well adjust its arguments/interface on the way). > + procfs_ops.to_xfer_partial = procfs_xfer_partial; Anyway, the patch looks fine to me as is. Feel free to go ahead and check it in. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-08-24 11:27 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-06-11 20:31 [patch] nto-procfs.c: Add to_xfer_partial Aleksandar Ristovski 2009-06-11 21:36 ` Pierre Muller 2009-06-12 2:25 ` Aleksandar Ristovski 2009-06-12 6:55 ` Pierre Muller 2009-06-18 15:16 ` Aleksandar Ristovski 2009-07-07 16:23 ` Aleksandar Ristovski 2009-07-21 15:45 ` Aleksandar Ristovski 2009-07-24 14:16 ` Pedro Alves 2009-07-27 20:17 ` Aleksandar Ristovski 2009-07-28 12:01 ` Pedro Alves 2009-07-28 22:17 ` Aleksandar Ristovski 2009-08-24 11:34 ` Pedro Alves
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox