This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/3] Include asm/ptrace.h in mips-linux-nat.c
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 14 Jun 2013 13:37:11 +0100
- Subject: Re: [PATCH 1/3] Include asm/ptrace.h in mips-linux-nat.c
- References: <1369881867-11372-1-git-send-email-yao at codesourcery dot com> <1369881867-11372-2-git-send-email-yao at codesourcery dot com> <alpine dot DEB dot 1 dot 10 dot 1306131752490 dot 16287 at tp dot orcam dot me dot uk> <51BA8252 dot 3010303 at codesourcery dot com>
On Fri, 14 Jun 2013, Yao Qi wrote:
> > ../../src/gdb/mips-linux-nat.c:599: error: storage size of 'dummy_regs'
> > isn't known
> >
> > etc. for the very reason the system I used for testing has old kernel
> > headers installed (2.6.19 it would seem, according to <linux/version.h>).
> >
> > Such a failure is not acceptable from the user's point of view; I think
> > there are three ways to deal with this:
> >
> > 1. Add an autoconf test that checks for the presence of a key
> > <asm/ptrace.h> definition; I think 'struct pt_watch_regs' is a good
> > candidate. If that test does not succeed, then the configure process
> > fails gracefully stating the minimum released version of kernel headers
> > required.
> >
> > 2. Add the same test, except in the failure case fall back to the internal
> > definitions we already have, wrapped into #ifndef
> > HAVE_STRUCT_PT_WATCH_REGS.
> >
> > 3. Add the same test and disable hardware watchpoint support in the
> > failure case.
>
> I prefer #3. If 'struct pt_watch_regs' is not defined, hardware watchpoint is
> not supported in the kernel. Because 'struct pt_watch_regs' was added in this
> commit in linux kernel,
>
> commit 0926bf953ee79b8f139741b442e5a18520f81705
> Author: David Daney <ddaney@avtrex.com>
> Date: Tue Sep 23 00:11:26 2008 -0700
>
> MIPS: Ptrace support for HARDWARE_WATCHPOINTS
>
> This is the final part of the watch register patch. Here we hook up
> ptrace so that the user space debugger (gdb), can set and read the
> registers.
>
> Signed-off-by: David Daney <ddaney@avtrex.com>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Well, kernel headers bundled with the C library installed on a system GDB
is being built on do not necessarily have to match the kernel binary the
system uses (as is the case with the system I'm using for this validation)
or GDB may be run on another system. So you cannot infer at the build
time whether the kernel used on a system GDB is going to run on supports
watchpoints until you actually query the kernel at the run time; you need
to do a run-time check anyway as hardware may not even if the kernel will.
Therefore I think my question here is a matter of policy in GDB rather
than limitations posed by a system in a given configuration. Which makes
your preference valid, although not for the reason you stated.
Maciej