This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfc] Eliminate current_regcache global variable
- From: Daniel Jacobowitz <drow at false dot org>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 12 Jun 2007 10:10:35 -0400
- Subject: Re: [rfc] Eliminate current_regcache global variable
- References: <200706072119.l57LJJ3j030038@d12av02.megacenter.de.ibm.com>
On Thu, Jun 07, 2007 at 11:19:19PM +0200, Ulrich Weigand wrote:
> Hello,
>
> as a follow-on to the patch set eliminating read_register, this patch
> gets rid of the global current_regcache variable, and makes a first step
> into the direction of real per-thread register caches.
The idea sounds fine. I just looked at the Linux bits.
> diff -urNp gdb-orig/gdb/linux-nat.c gdb-head/gdb/linux-nat.c
> --- gdb-orig/gdb/linux-nat.c 2007-06-01 18:51:01.000000000 +0200
> +++ gdb-head/gdb/linux-nat.c 2007-06-06 19:49:08.553079253 +0200
> @@ -2580,19 +2580,26 @@ linux_nat_do_thread_registers (bfd *obfd
> gdb_fpxregset_t fpxregs;
> #endif
> unsigned long lwp = ptid_get_lwp (ptid);
> - struct gdbarch *gdbarch = current_gdbarch;
> + struct regcache *regcache = get_thread_regcache (ptid);
> + struct gdbarch *gdbarch = get_regcache_arch (regcache);
> const struct regset *regset;
> int core_regset_p;
> + ptid_t saved_ptid;
> +
> + saved_ptid = inferior_ptid;
> + inferior_ptid = ptid;
> + target_fetch_registers (regcache, -1);
> + inferior_ptid = saved_ptid;
Shouldn't we use a cleanup for this?
> @@ -2672,15 +2670,11 @@ static char *
> linux_nat_do_registers (bfd *obfd, ptid_t ptid,
> char *note_data, int *note_size)
> {
> - registers_changed ();
> - /* FIXME should not be necessary; fill_gregset should do it automatically. */
> - target_fetch_registers (current_regcache, -1);
> return linux_nat_do_thread_registers (obfd,
> ptid_build (ptid_get_pid (inferior_ptid),
> ptid_get_pid (inferior_ptid),
> 0),
> note_data, note_size);
> - return note_data;
> }
Why'd the return value go?
--
Daniel Jacobowitz
CodeSourcery