This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 07/14] add infcall_mmap and gcc_target_options gdbarch methods
- From: Yao Qi <yao at codesourcery dot com>
- To: Tom Tromey <tromey at redhat dot com>, <gdb-patches at sourceware dot org>
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Mon, 19 May 2014 14:10:25 +0800
- Subject: Re: [PATCH 07/14] add infcall_mmap and gcc_target_options gdbarch methods
- Authentication-results: sourceware.org; auth=none
- References: <1400253995-12333-1-git-send-email-tromey at redhat dot com> <1400253995-12333-8-git-send-email-tromey at redhat dot com>
On 05/16/2014 11:26 PM, Tom Tromey wrote:
> The compiler needed two new gdbarch methods.
>
> The infcall_mmap method allocates memory in the inferior.
> This is used when inserting the object code.
IMO, "infcall_mmap" is confusing....
> diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
> index 9f357b6..6b2bc12 100755
> --- a/gdb/gdbarch.sh
> +++ b/gdb/gdbarch.sh
> @@ -1029,6 +1029,18 @@ m:int:insn_is_jump:CORE_ADDR addr:addr::default_insn_is_jump::0
> # Return -1 if there is insufficient buffer for a whole entry.
> # Return 1 if an entry was read into *TYPEP and *VALP.
> M:int:auxv_parse:gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp:readptr, endptr, typep, valp
> +
> +# Allocate SIZE bytes of PROT protected page aligned memory in inferior.
> +# PROT has rwx bitmask format - bit 2 (value 4) is for readable memory, bit 1
> +# (value 2) is for writable memory and bit 0 (value 1) is for executable memory.
> +# Throw an error if it is not possible. Returned address is always valid.
> +f:CORE_ADDR:infcall_mmap:CORE_ADDR size, unsigned prot:size, prot::default_infcall_mmap::0
> +
.... looks this hook is to allocate some target memory pages with
certain required permissions. Probably, we can use "allocate_memory"
or "mmap".
> +# Return string (caller has to use xfree for it) with options for GCC
> +# to produce code for this target, typically "-m64", "-m32" or "-m31".
> +# These options are put before CU's DW_AT_producer compilation options so that
> +# they can override it. Method may also return NULL.
> +m:char *:gcc_target_options:void:::default_gcc_target_options::0
> EOF
> }
I doubt the interface like this is sufficient for other archs, like
arm and mips, which have multiple multilibs, such as -marm/thumb,
-mfloat-abi={hard,softfp}, etc. This hook in GDB has to take something
into account, such as gdbarch, current frame, the related bfd, etc, in
order to return a correct or compatible options for gcc to compile
source.
--
Yao (éå)