This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: RFA: revised implementation of permanent breakpoints
- To: Jim Blandy <jimb AT cygnus dot com>
- Subject: Re: RFA: revised implementation of permanent breakpoints
- From: Andrew Cagney <ac131313 AT cygnus dot com>
- Date: Tue, 14 Sep 1999 09:42:34 +1000
- CC: Michael Snyder <msnyder AT cygnus dot com>, Jim Ingham <jingham AT cygnus dot com>, Stan Shebs <shebs AT cygnus dot com>, gdb-patches AT sourceware.cygnus dot com
- Organization: Cygnus Solutions
- References: <199909131817.NAA03359@zwingli.cygnus.com>
Jim Blandy wrote:
> I added the SKIP_PERMANENT_BREAKPOINT macro in such a way that it
> should be easy to adapt it to the gdbarch framework. It is always
> used as a typed value, never in an #ifdef. So one should be able to
> add a line to gdbarch.sh, and change the #define to a proper
> gdbarch-style initialization, and everything will just work.
That is all I ask :-)
> + /* We can't step off a permanent breakpoint in the ordinary way, because we
> + can't remove it. Instead, we have to advance the PC to the next
> + instruction. This macro should expand to a pointer to a function that
> + does that, or zero if we have no such function. If we don't have a
> + definition for it, we have to report an error. */
> + #ifndef SKIP_PERMANENT_BREAKPOINT
> + #define SKIP_PERMANENT_BREAKPOINT ((void (*) (void)) 0)
> + #endif
> +
> +
Puzzled expression. Why is it being cast in that strange way.
> +
> + /* Normally, by the time we reach `resume', the breakpoints are either
> + removed or inserted, as appropriate. The exception is if we're sitting
> + at a permanent breakpoint; we need to step over it, but permanent
> + breakpoints can't be removed. So we have to test for it here. */
> + if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here)
> + {
> + if (SKIP_PERMANENT_BREAKPOINT)
> + SKIP_PERMANENT_BREAKPOINT ();
> + else
> + {
> + error_begin ();
> + fprintf_filtered (gdb_stderr, "\
> + The program is stopped at a permanent breakpoint, but GDB does not know\n\
> + how to step past a permanent breakpoint on this architecture. Try using\n\
> + a command like `return' or `jump' to continue execution.\n");
> + return_to_top_level (RETURN_ERROR);
> + }
> + }
Ah, no. You can't directly test a macro for NULL. The good old ``have
the macro name return a function pointer and then call that'' trick
won't work. This is because GDB arch is internally parameterized by the
current architecture.
Instead, either a predicate needs to be added:
if (SKIP_PERMENANT_BREAPOINT_P)
SKIP_PERMENANT_BREAPOINT (...);
or better, just turn the else clause from the above into a function and
default the macro to that:
SKIP_PERMENANT_BREAKPOINT (...)
Andrew