From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: cseo@linux.vnet.ibm.com (Carlos Eduardo Seo)
Cc: gdb-patches@sourceware.org (GDB Patches Mailing List)
Subject: Re: [RFC] Add support for PPC Altivec registers in gcore
Date: Thu, 27 Mar 2008 19:54:00 -0000 [thread overview]
Message-ID: <200803271954.m2RJsGg4029450@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <47EAFD9C.9090708@linux.vnet.ibm.com> from "Carlos Eduardo Seo" at Mar 26, 2008 10:51:24 PM
Carlos Eduardo Seo wrote:
> >> +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0'
> >
> > Not '0' -- just 0. (That *is* a difference!)
> >
>
> Yes, I know. But gcc 4.x will complain about reading through a null
> pointer if I use 0.
As Andreas pointed out, (char *) '0' is definitely broken -- this
will interpret the numerical value of '0' (i.e. 48 in ASCII) as
pointer value and try to dereference it, which will certainly crash.
I had suggested to use a null pointer as this will be caught at
run-time and printed as "(null)". However, re-thinking it, this is
not actually guaranteed by the standard -- which is probably why
you're seeing a warning ...
Unfortunately, I've noticed another, more serious problem:
> Index: src/gdb/arch-utils.c
> ===================================================================
> --- src.orig/gdb/arch-utils.c
> +++ src/gdb/arch-utils.c
> @@ -31,11 +31,19 @@
> #include "gdbcore.h"
> #include "osabi.h"
> #include "target-descriptions.h"
> -
> +#include <sys/procfs.h>
> +#include "gregset.h"
> #include "version.h"
> +#include "regset.h"
>
> #include "floatformat.h"
>
> +struct core_regset_section default_regset_sections[] =
> +{
> + { ".reg", sizeof (gdb_gregset_t) },
> + { ".reg2", sizeof (gdb_fpregset_t) },
> + { NULL, 0 }
> +};
This isn't really feasible: you cannot simply include the
platform-specific <sys/procfs.h> into a generic file -- it
may not even be available on some platforms; and on other
platforms it may not provide the required gregset_t type.
I'm sorry for all the back-and-forth on this, but it seems
we do have to implement a Linux-specific fallback to that;
I don't see how we can do a generic default. To do so,
you'll need to let the gdbarch variable default to NULL,
and in linux_nat_do_thread_registers perform the fpregset
fallback if that is the case. ppc and i386 would then be
the only architectures that install the new gdbarch variable;
over time, the remaining Linux platforms should follow suite
and we can remove the fallbacks.
> Index: src/gdb/ppc-linux-tdep.c
> ===================================================================
> --- src.orig/gdb/ppc-linux-tdep.c
> +++ src/gdb/ppc-linux-tdep.c
> @@ -37,6 +37,16 @@
> #include "trad-frame.h"
> #include "frame-unwind.h"
> #include "tramp-frame.h"
> +#include <sys/procfs.h>
You cannot include a platform-specific header into a -tdep file either,
this file is also used for cross-debugging from arbitrary hosts.
> +#include "gregset.h"
> +
> +static struct core_regset_section ppc_regset_sections[] =
> +{
> + { ".reg", sizeof (gdb_gregset_t) },
> + { ".reg2", sizeof (gdb_fpregset_t) },
However, you can simply use all numerical values here -- the sizes
of the register sections in PowerPC core files are constants.
> + { ".reg-ppc-vmx", 544 },
> + { NULL, 0 }
> +};
The same applies to the i386 changes:
> +++ src/gdb/i386-linux-tdep.c
> @@ -28,12 +28,24 @@
> #include "reggroups.h"
> #include "dwarf2-frame.h"
> #include "gdb_string.h"
> -
> +#include <sys/procfs.h>
> +#include "gregset.h"
> #include "i386-tdep.h"
> #include "i386-linux-tdep.h"
> #include "glibc-tdep.h"
> #include "solib-svr4.h"
> #include "symtab.h"
> +#include "regset.h"
> +
> +static struct core_regset_section i386_regset_sections[] =
> +{
> + { ".reg", sizeof (gdb_gregset_t) },
> + { ".reg2", sizeof (gdb_fpregset_t) },
> +#ifdef FILL_FPXREGSET
> + { ".reg-xfp", sizeof (gdb_fpxregset_t) },
> +#endif
> + { NULL, 0 }
> +};
One more issue in linux-nat.c:
> + if (core_regset_p)
> + while ((++sect_list)->sect_name != NULL)
The ++sect_list still skips the first entry unconditionally.
You should increment sect_list at the *end* of the loop.
Once again, sorry for leading you down a wrong track here.
Thanks for your continued work to fix this problem ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2008-03-27 19:54 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 22:14 Carlos Eduardo Seo
2007-10-29 19:24 ` Ulrich Weigand
2007-10-30 21:02 ` Carlos Eduardo Seo
2007-10-30 21:18 ` Ulrich Weigand
2007-10-30 21:30 ` Carlos Eduardo Seo
2007-10-30 21:31 ` Ulrich Weigand
2007-10-31 21:14 ` Carlos Eduardo Seo
2007-10-31 21:43 ` Ulrich Weigand
2008-02-08 21:42 ` Carlos Eduardo Seo
2008-02-18 18:42 ` Ulrich Weigand
2008-02-27 17:07 ` Carlos Eduardo Seo
2008-03-05 18:27 ` Ulrich Weigand
2008-03-10 14:22 ` Carlos Eduardo Seo
2008-03-17 19:07 ` Ulrich Weigand
2008-03-20 15:31 ` Carlos Eduardo Seo
2008-03-25 20:13 ` Ulrich Weigand
2008-03-25 21:31 ` Andreas Schwab
2008-03-25 21:54 ` Ulrich Weigand
2008-03-25 22:46 ` Carlos Eduardo Seo
2008-03-26 11:28 ` Ulrich Weigand
2008-03-27 1:52 ` Carlos Eduardo Seo
2008-03-27 9:00 ` Andreas Schwab
2008-03-27 19:54 ` Ulrich Weigand [this message]
2008-03-28 20:41 ` Carlos Eduardo Seo
2008-03-31 19:19 ` Ulrich Weigand
2008-05-09 19:27 ` Carlos Eduardo Seo
2008-05-09 20:30 ` Ulrich Weigand
2008-05-10 1:33 ` Carlos Eduardo Seo
2008-05-14 4:22 ` Ulrich Weigand
2008-05-20 18:41 ` Carlos Eduardo Seo
2008-05-21 18:46 ` Ulrich Weigand
2008-05-22 14:34 ` Carlos Eduardo Seo
2008-05-22 18:45 ` Ulrich Weigand
2008-05-26 16:26 ` Carlos Eduardo Seo
[not found] <OF67129E0D.852FADB2-ON4125738B.0050E74D-4125738B.005102FF@de.ibm.com>
2007-11-25 4:51 ` Carlos Eduardo Seo
2007-11-26 16:09 ` Ulrich Weigand
2007-11-26 16:12 ` Carlos Eduardo Seo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200803271954.m2RJsGg4029450@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=cseo@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox