Re: [PATCH 1/9] Support the fs_base and gs_base registers on i386.

Simon Marchi
2019-01-27T04:22:35Z

On 2019-01-22 1:42 p.m., John Baldwin wrote:
> As on amd64, these registers hold the base address of the fs and gs
> segments, respectively. For i386 these two registers are 32 bits.

I just started to look at this, still trying to get my head around it and
connect all the dots. Just a silly question for now:

> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index d4143ae155..1eb0bcdf17 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -3107,15 +3107,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
>
> if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments") != NULL)
> {
> - const struct tdesc_feature *feature =
> - tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments");
> - struct tdesc_arch_data *tdesc_data_segments =
> - (struct tdesc_arch_data *) info.tdep_info;
> -
> - tdesc_numbered_register (feature, tdesc_data_segments,
> - AMD64_FSBASE_REGNUM, "fs_base");
> - tdesc_numbered_register (feature, tdesc_data_segments,
> - AMD64_GSBASE_REGNUM, "gs_base");
> + tdep->fsbase_regnum = AMD64_FSBASE_REGNUM;
> }

Can you explain what this change does and why it is needed? I am a bit lost.

I see you add something equivalent in i386-tdep.c, but as far as I know, they are completely
separate.

Simon