This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[12/19] target routines
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 5 Jun 2009 23:19:02 +0200 (CEST)
- Subject: [12/19] target routines
Hello,
this replaces a couple of references to current_gdbarch in native
or solib code by target_gdbarch where appropriate.
Two instances (dbug-rom.c and solib-pa64.c) were in fact unnecessary
and can be simply removed.
Bye,
Ulrich
ChangeLog:
* ada-tasks.c (read_known_tasks_array): Use target_gdbarch instead
of current_gdbarch.
* aix-thread.c (pd_enable): Likewise.
* amd64-linux-nat.c (ps_get_thread_area): Likewise.
* bsd-uthread.c (bsd_uthread_activate): Likewise.
* linux-nat.c (linux_nat_info_proc_cmd): Likewise.
* linux-thread-db.c (enable_thread_event): Likewise.
* monitor.c (monitor_write_memory, monitor_read_memory): Likewise.
* nto-procfs.c (procfs_open): Likewise.
* procfs.c (invalidate_cache, procfs_insert_watchpoint,
info_proc_mappings, info_mappings_callback): Likewise.
* record.c (record_open): Likewise.
* rs6000-nat.c (ARCH64): Likewise.
* solib-darwin.c (darwin_solib_create_inferior_hook): Likewise.
(darwin_bfd_open): Likewise.
* windows-nat.c (win32_resume): Use current regcache architecture
instead of current_gdbarch.
* dbug-rom.c (dbug_regname): Remove check against number of
registers in current_gdbarch.
* solib-pa64.c (read_dynamic_info): Remove unused variable.
Index: gdb-head/gdb/ada-tasks.c
===================================================================
--- gdb-head.orig/gdb/ada-tasks.c
+++ gdb-head/gdb/ada-tasks.c
@@ -609,7 +609,7 @@ static int
read_known_tasks_array (void)
{
const int target_ptr_byte =
- gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
+ gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT;
const CORE_ADDR known_tasks_addr = get_known_tasks_addr ();
const int known_tasks_size = target_ptr_byte * MAX_NUMBER_OF_KNOWN_TASKS;
gdb_byte *known_tasks = alloca (known_tasks_size);
@@ -632,7 +632,7 @@ read_known_tasks_array (void)
for (i = 0; i < MAX_NUMBER_OF_KNOWN_TASKS; i++)
{
struct type *data_ptr_type =
- builtin_type (current_gdbarch)->builtin_data_ptr;
+ builtin_type (target_gdbarch)->builtin_data_ptr;
CORE_ADDR task_id =
extract_typed_address (known_tasks + i * target_ptr_byte,
data_ptr_type);
Index: gdb-head/gdb/aix-thread.c
===================================================================
--- gdb-head.orig/gdb/aix-thread.c
+++ gdb-head/gdb/aix-thread.c
@@ -887,7 +887,7 @@ pd_enable (void)
return;
/* Check application word size. */
- arch64 = register_size (current_gdbarch, 0) == 8;
+ arch64 = register_size (target_gdbarch, 0) == 8;
/* Check whether the application is pthreaded. */
stub_name = NULL;
Index: gdb-head/gdb/amd64-linux-nat.c
===================================================================
--- gdb-head.orig/gdb/amd64-linux-nat.c
+++ gdb-head/gdb/amd64-linux-nat.c
@@ -341,7 +341,7 @@ ps_err_e
ps_get_thread_area (const struct ps_prochandle *ph,
lwpid_t lwpid, int idx, void **base)
{
- if (gdbarch_ptr_bit (current_gdbarch) == 32)
+ if (gdbarch_ptr_bit (target_gdbarch) == 32)
{
/* The full structure is found in <asm-i386/ldt.h>. The second
integer is the LDT's base_address and that is used to locate
Index: gdb-head/gdb/bsd-uthread.c
===================================================================
--- gdb-head.orig/gdb/bsd-uthread.c
+++ gdb-head/gdb/bsd-uthread.c
@@ -159,7 +159,7 @@ bsd_uthread_read_memory_address (CORE_AD
static int
bsd_uthread_activate (struct objfile *objfile)
{
- struct gdbarch *gdbarch = current_gdbarch;
+ struct gdbarch *gdbarch = target_gdbarch;
struct bsd_uthread_ops *ops = gdbarch_data (gdbarch, bsd_uthread_data);
/* Skip if the thread stratum has already been activated. */
Index: gdb-head/gdb/dbug-rom.c
===================================================================
--- gdb-head.orig/gdb/dbug-rom.c
+++ gdb-head/gdb/dbug-rom.c
@@ -90,8 +90,7 @@ dbug_regname (int index)
/* no float registers */
};
- if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
- || (index < 0) || (index >= gdbarch_num_regs (current_gdbarch)))
+ if (index >= ARRAY_SIZE (regnames) || index < 0)
return NULL;
else
return regnames[index];
Index: gdb-head/gdb/linux-nat.c
===================================================================
--- gdb-head.orig/gdb/linux-nat.c
+++ gdb-head/gdb/linux-nat.c
@@ -3785,7 +3785,7 @@ linux_nat_info_proc_cmd (char *args, int
cleanup = make_cleanup_fclose (procfile);
printf_filtered (_("Mapped address spaces:\n\n"));
- if (gdbarch_addr_bit (current_gdbarch) == 32)
+ if (gdbarch_addr_bit (target_gdbarch) == 32)
{
printf_filtered ("\t%10s %10s %10s %10s %7s\n",
"Start Addr",
@@ -3811,7 +3811,7 @@ linux_nat_info_proc_cmd (char *args, int
a generic local_address_string instead to print out
the addresses; that makes sense to me, too. */
- if (gdbarch_addr_bit (current_gdbarch) == 32)
+ if (gdbarch_addr_bit (target_gdbarch) == 32)
{
printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
(unsigned long) addr, /* FIXME: pr_addr */
Index: gdb-head/gdb/linux-thread-db.c
===================================================================
--- gdb-head.orig/gdb/linux-thread-db.c
+++ gdb-head/gdb/linux-thread-db.c
@@ -509,7 +509,7 @@ enable_thread_event (int event, CORE_ADD
/* Set up the breakpoint. */
gdb_assert (exec_bfd);
(*bp) = (gdbarch_convert_from_func_ptr_addr
- (current_gdbarch,
+ (target_gdbarch,
/* Do proper sign extension for the target. */
(bfd_get_sign_extend_vma (exec_bfd) > 0
? (CORE_ADDR) (intptr_t) notify.u.bptaddr
Index: gdb-head/gdb/monitor.c
===================================================================
--- gdb-head.orig/gdb/monitor.c
+++ gdb-head/gdb/monitor.c
@@ -1412,7 +1412,7 @@ monitor_write_memory (CORE_ADDR memaddr,
monitor_debug ("MON write %d %s\n", len, paddr (memaddr));
if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- memaddr = gdbarch_addr_bits_remove (current_gdbarch, memaddr);
+ memaddr = gdbarch_addr_bits_remove (target_gdbarch, memaddr);
/* Use memory fill command for leading 0 bytes. */
@@ -1811,7 +1811,7 @@ monitor_read_memory (CORE_ADDR memaddr,
paddr_nz (memaddr), (long) myaddr, len);
if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- memaddr = gdbarch_addr_bits_remove (current_gdbarch, memaddr);
+ memaddr = gdbarch_addr_bits_remove (target_gdbarch, memaddr);
if (current_monitor->flags & MO_GETMEM_READ_SINGLE)
return monitor_read_memory_single (memaddr, myaddr, len);
Index: gdb-head/gdb/nto-procfs.c
===================================================================
--- gdb-head.orig/gdb/nto-procfs.c
+++ gdb-head/gdb/nto-procfs.c
@@ -197,7 +197,7 @@ procfs_open (char *arg, int from_tty)
{
if (sysinfo->type !=
nto_map_arch_to_cputype (gdbarch_bfd_arch_info
- (current_gdbarch)->arch_name))
+ (target_gdbarch)->arch_name))
error (_("Invalid target CPU."));
}
}
Index: gdb-head/gdb/procfs.c
===================================================================
--- gdb-head.orig/gdb/procfs.c
+++ gdb-head/gdb/procfs.c
@@ -4470,7 +4470,7 @@ invalidate_cache (procinfo *parent, proc
if (!proc_set_gregs (pi)) /* flush gregs cache */
proc_warn (pi, "target_resume, set_gregs",
__LINE__);
- if (gdbarch_fp0_regnum (current_gdbarch) >= 0)
+ if (gdbarch_fp0_regnum (target_gdbarch) >= 0)
if (pi->fpregs_dirty)
if (parent == NULL ||
proc_get_current_thread (parent) != pi->tid)
@@ -5353,7 +5353,7 @@ static int
procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
{
if (!target_have_steppable_watchpoint
- && !gdbarch_have_nonsteppable_watchpoint (current_gdbarch))
+ && !gdbarch_have_nonsteppable_watchpoint (target_gdbarch))
{
/* When a hardware watchpoint fires off the PC will be left at
the instruction following the one which caused the
@@ -5781,7 +5781,7 @@ info_mappings_callback (struct prmap *ma
pr_off = map->pr_off;
#endif
- if (gdbarch_addr_bit (current_gdbarch) == 32)
+ if (gdbarch_addr_bit (target_gdbarch) == 32)
printf_filtered ("\t%#10lx %#10lx %#10lx %#10x %7s\n",
(unsigned long) map->pr_vaddr,
(unsigned long) map->pr_vaddr + map->pr_size - 1,
@@ -5812,7 +5812,7 @@ info_proc_mappings (procinfo *pi, int su
return; /* No output for summary mode. */
printf_filtered (_("Mapped address spaces:\n\n"));
- if (gdbarch_ptr_bit (current_gdbarch) == 32)
+ if (gdbarch_ptr_bit (target_gdbarch) == 32)
printf_filtered ("\t%10s %10s %10s %10s %7s\n",
"Start Addr",
" End Addr",
Index: gdb-head/gdb/rs6000-nat.c
===================================================================
--- gdb-head.orig/gdb/rs6000-nat.c
+++ gdb-head/gdb/rs6000-nat.c
@@ -75,7 +75,7 @@
#ifndef ARCH3264
# define ARCH64() 0
#else
-# define ARCH64() (register_size (current_gdbarch, 0) == 8)
+# define ARCH64() (register_size (target_gdbarch, 0) == 8)
#endif
/* Union of 32-bit and 64-bit versions of ld_info. */
Index: gdb-head/gdb/solib-pa64.c
===================================================================
--- gdb-head.orig/gdb/solib-pa64.c
+++ gdb-head/gdb/solib-pa64.c
@@ -213,9 +213,7 @@ read_dynamic_info (asection *dyninfo_sec
Elf64_Dyn *x_dynp = (Elf64_Dyn*)buf;
Elf64_Sxword dyn_tag;
CORE_ADDR dyn_ptr;
- char *pbuf;
- pbuf = alloca (gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT);
dyn_tag = bfd_h_get_64 (symfile_objfile->obfd,
(bfd_byte*) &x_dynp->d_tag);
Index: gdb-head/gdb/windows-nat.c
===================================================================
--- gdb-head.orig/gdb/windows-nat.c
+++ gdb-head/gdb/windows-nat.c
@@ -1246,9 +1246,10 @@ windows_resume (struct target_ops *ops,
if (step)
{
/* Single step by setting t bit */
- windows_fetch_inferior_registers (ops,
- get_current_regcache (),
- gdbarch_ps_regnum (current_gdbarch));
+ struct regcache *regcache = get_current_regcache ();
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ windows_fetch_inferior_registers (ops, regcache,
+ gdbarch_ps_regnum (gdbarch));
th->context.EFlags |= FLAG_TRACE_BIT;
}
Index: gdb-head/gdb/i386-darwin-nat.c
===================================================================
--- gdb-head.orig/gdb/i386-darwin-nat.c
+++ gdb-head/gdb/i386-darwin-nat.c
@@ -404,7 +404,7 @@ i386_darwin_dr_get_status (void)
void
darwin_check_osabi (darwin_inferior *inf, thread_t thread)
{
- if (gdbarch_osabi (current_gdbarch) == GDB_OSABI_UNKNOWN)
+ if (gdbarch_osabi (target_gdbarch) == GDB_OSABI_UNKNOWN)
{
/* Attaching to a process. Let's figure out what kind it is. */
x86_thread_state_t gp_regs;
@@ -422,7 +422,7 @@ darwin_check_osabi (darwin_inferior *inf
gdbarch_info_init (&info);
gdbarch_info_fill (&info);
- info.byte_order = gdbarch_byte_order (current_gdbarch);
+ info.byte_order = gdbarch_byte_order (target_gdbarch);
info.osabi = GDB_OSABI_DARWIN;
if (gp_regs.tsh.flavor == x86_THREAD_STATE64)
info.bfd_arch_info = bfd_lookup_arch (bfd_arch_i386,
Index: gdb-head/gdb/solib-darwin.c
===================================================================
--- gdb-head.orig/gdb/solib-darwin.c
+++ gdb-head/gdb/solib-darwin.c
@@ -313,7 +313,7 @@ darwin_solib_create_inferior_hook (void)
{
bfd *sub;
sub = bfd_mach_o_fat_extract (dyld_bfd, bfd_object,
- gdbarch_bfd_arch_info (current_gdbarch));
+ gdbarch_bfd_arch_info (target_gdbarch));
if (sub)
dyld_bfd = sub;
else
@@ -423,7 +423,7 @@ darwin_bfd_open (char *pathname)
abfd = solib_bfd_fopen (found_pathname, found_file);
res = bfd_mach_o_fat_extract (abfd, bfd_object,
- gdbarch_bfd_arch_info (current_gdbarch));
+ gdbarch_bfd_arch_info (target_gdbarch));
if (!res)
{
bfd_close (abfd);
Index: gdb-head/gdb/record.c
===================================================================
--- gdb-head.orig/gdb/record.c
+++ gdb-head/gdb/record.c
@@ -428,7 +428,7 @@ record_open (char *name, int from_tty)
error (_("Process record target can't debug inferior in asynchronous "
"mode (target-async)."));
- if (!gdbarch_process_record_p (current_gdbarch))
+ if (!gdbarch_process_record_p (target_gdbarch))
error (_("Process record: the current architecture doesn't support "
"record function."));
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com