public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: John Baldwin <jhb@FreeBSD.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 8/9] Support TLS variables on FreeBSD/riscv.
Date: Sun, 27 Jan 2019 23:35:00 -0000	[thread overview]
Message-ID: <20190127233530.GD4149@embecosm.com> (raw)
In-Reply-To: <b7154bcfa5124f78330d5f58a3b7d46ad59027ee.1548180889.git.jhb@FreeBSD.org>

* John Baldwin <jhb@FreeBSD.org> [2019-01-22 10:43:01 -0800]:

> Derive the pointer to the DTV array from the tp register.
> 
> gdb/ChangeLog:
> 
> 	* riscv-fbsd-tdep.c (riscv_fbsd_get_thread_local_address): New.
> 	(riscv_fbsd_init_abi): Install gdbarch
> 	"fetch_tls_load_module_address" and "get_thread_local_address"
> 	methods.
> ---
>  gdb/ChangeLog         |  7 +++++++
>  gdb/riscv-fbsd-tdep.c | 27 +++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)

These look good to me.

Thanks,
Andrew



> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 06c637c80a..5d228614db 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,10 @@
> +2019-01-22  John Baldwin  <jhb@FreeBSD.org>
> +
> +	* riscv-fbsd-tdep.c (riscv_fbsd_get_thread_local_address): New.
> +	(riscv_fbsd_init_abi): Install gdbarch
> +	"fetch_tls_load_module_address" and "get_thread_local_address"
> +	methods.
> +
>  2019-01-22  John Baldwin  <jhb@FreeBSD.org>
>  
>  	* i386-fbsd-tdep.c (i386fbsd_get_thread_local_address): New.
> diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
> index 97ad28f59a..3125a2285e 100644
> --- a/gdb/riscv-fbsd-tdep.c
> +++ b/gdb/riscv-fbsd-tdep.c
> @@ -174,6 +174,28 @@ static const struct tramp_frame riscv_fbsd_sigframe =
>    riscv_fbsd_sigframe_init
>  };
>  
> +/* Implement the "get_thread_local_address" gdbarch method.  */
> +
> +static CORE_ADDR
> +riscv_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
> +				     CORE_ADDR lm_addr, CORE_ADDR offset)
> +{
> +  struct regcache *regcache;
> +
> +  regcache = get_thread_arch_regcache (ptid, gdbarch);
> +
> +  target_fetch_registers (regcache, RISCV_TP_REGNUM);
> +
> +  ULONGEST tp;
> +  if (regcache->cooked_read (RISCV_TP_REGNUM, &tp) != REG_VALID)
> +    error (_("Unable to fetch %%tp"));
> +
> +  /* %tp points to the end of the TCB which contains two pointers.
> +      The first pointer in the TCB points to the DTV array.  */
> +  CORE_ADDR dtv_addr = tp - (gdbarch_ptr_bit (gdbarch) / 8) * 2;
> +  return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset);
> +}
> +
>  /* Implement the 'init_osabi' method of struct gdb_osabi_handler.  */
>  
>  static void
> @@ -193,6 +215,11 @@ riscv_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
>  
>    set_gdbarch_iterate_over_regset_sections
>      (gdbarch, riscv_fbsd_iterate_over_regset_sections);
> +
> +  set_gdbarch_fetch_tls_load_module_address (gdbarch,
> +					     svr4_fetch_objfile_link_map);
> +  set_gdbarch_get_thread_local_address (gdbarch,
> +					riscv_fbsd_get_thread_local_address);
>  }
>  
>  void
> -- 
> 2.19.2
> 

  reply	other threads:[~2019-01-27 23:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22 18:43 [PATCH 0/9] Support for thread-local variables on FreeBSD John Baldwin
2019-01-22 18:43 ` [PATCH 6/9] Support TLS variables on FreeBSD/amd64 John Baldwin
2019-01-22 18:43 ` [PATCH 2/9] Support fs_base and gs_base on FreeBSD/i386 John Baldwin
2019-02-02 15:26   ` Simon Marchi
2019-02-04 19:45     ` John Baldwin
2019-02-05 18:59       ` Simon Marchi
2019-01-22 18:43 ` [PATCH 7/9] Support TLS variables " John Baldwin
2019-01-22 18:43 ` [PATCH 9/9] Support TLS variables on FreeBSD/powerpc John Baldwin
2019-01-22 18:43 ` [PATCH 1/9] Support the fs_base and gs_base registers on i386 John Baldwin
2019-01-27  4:22   ` Simon Marchi
2019-01-28 17:54     ` John Baldwin
2019-02-02 15:11       ` Simon Marchi
2019-01-22 18:43 ` [PATCH 3/9] Handle TLS variable lookups when using separate debug object files John Baldwin
2019-02-02 15:52   ` Simon Marchi
2019-02-04 20:02     ` John Baldwin
2019-02-05 20:06       ` Simon Marchi
2019-02-05 22:21         ` John Baldwin
2019-02-05 22:33           ` John Baldwin
2019-02-07  4:05             ` Simon Marchi
2019-02-07  4:08               ` Simon Marchi
2019-01-22 18:52 ` [PATCH 5/9] Add a helper function to resolve TLS variable addresses for FreeBSD John Baldwin
2019-01-24 17:09   ` John Baldwin
2019-02-07  5:05     ` Simon Marchi
2019-02-07 17:02       ` John Baldwin
2019-02-09  0:34         ` John Baldwin
2019-01-22 18:52 ` [PATCH 8/9] Support TLS variables on FreeBSD/riscv John Baldwin
2019-01-27 23:35   ` Andrew Burgess [this message]
2019-01-22 18:52 ` [PATCH 4/9] Add a new gdbarch method to resolve the address of TLS variables John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190127233530.GD4149@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).