This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/8] Add new gdbarch method, unconditional_branch_address
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: Kevin Buettner <kevinb at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 18 Sep 2015 13:01:57 +0100
- Subject: Re: [PATCH 2/8] Add new gdbarch method, unconditional_branch_address
- Authentication-results: sourceware.org; auth=none
- References: <20150818235334 dot 1afb0c85 at pinnacle dot lan> <20150819000002 dot 06f6a2cf at pinnacle dot lan>
* Kevin Buettner <kevinb@redhat.com> [2015-08-19 00:00:02 -0700]:
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index c1e2c1a..1770960 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -924,7 +924,7 @@ extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_i
> If your architecture doesn't need to adjust instructions before
> single-stepping them, consider using simple_displaced_step_copy_insn
> here.
> -
> +
> If the instruction cannot execute out of line, return NULL. The
> core falls back to stepping past the instruction in-line instead in
> that case. */
> @@ -1478,6 +1478,16 @@ typedef int (gdbarch_addressable_memory_unit_size_ftype) (struct gdbarch *gdbarc
> extern int gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch);
> extern void set_gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch, gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size);
>
> +/* Examine instruction at PC. If instruction at PC is an unconditional
> + branch, return the address to which control is transferred when the
> + branch is taken. Return 0 when this method is not implemented by
> + architecture, PC refers to an invalid address, or instruction at PC
> + is not an unconditional branch. */
> +
> +typedef CORE_ADDR (gdbarch_unconditional_branch_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc);
> +extern CORE_ADDR gdbarch_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc);
> +extern void set_gdbarch_unconditional_branch_address (struct gdbarch *gdbarch, gdbarch_unconditional_branch_address_ftype *unconditional_branch_address);
Personally I'm not a fan of overloading the return values on these
functions, especially when the return value is an address, on some
targets 0 is a valid address. I know there are lots of other places
where we use 0 as a special address in gdb, so this would be just one
more... but...
How would you feel about changing the function so that it returned a
bool and placed the address into a CORE_ADDRESS passed by pointer?
Just a thought,
thanks
Andrew