This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [patch] nto-procfs.c: Add to_xfer_partial
- From: "Pierre Muller" <muller at ics dot u-strasbg dot fr>
- To: "'Aleksandar Ristovski'" <aristovski at qnx dot com>, <gdb-patches at sources dot redhat dot com>
- Date: Thu, 11 Jun 2009 23:36:13 +0200
- Subject: RE: [patch] nto-procfs.c: Add to_xfer_partial
- References: <h0rpib$7te$1@ger.gmane.org>
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.