This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[04/19] overlay support routines
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 5 Jun 2009 23:15:24 +0200 (CEST)
- Subject: [04/19] overlay support routines
Hello,
this patch removes usage of current_gdbarch during overlay section processing.
Instead, the objfile architecture of the file using overlays is used to
determine the gdbarch_overlay_update function and the word size.
Bye,
Ulrich
ChangeLog:
* symfile.c (section_is_mapped): Use objfile architecture instead
of current_gdbarch.
(TARGET_LONG_BYTES): Remove.
(read_target_long_array): Add SIZE argument. Use it instead of
TARGET_LONG_BYTES.
(simple_read_overlay_table): Retrieve long size from objfile
architecture; pass it to read_target_long_array.
(simple_read_overlay_region_table): Likewise.
(simple_overlay_update_1): Likewise.
Index: gdb-head/gdb/symfile.c
===================================================================
--- gdb-head.orig/gdb/symfile.c
+++ gdb-head/gdb/symfile.c
@@ -128,7 +128,7 @@ static void overlay_command (char *, int
static void simple_free_overlay_table (void);
-static void read_target_long_array (CORE_ADDR, unsigned int *, int);
+static void read_target_long_array (CORE_ADDR, unsigned int *, int, int);
static int simple_read_overlay_table (void);
@@ -3289,6 +3289,8 @@ overlay_invalidate_all (void)
int
section_is_mapped (struct obj_section *osect)
{
+ struct gdbarch *gdbarch;
+
if (osect == 0 || !section_is_overlay (osect))
return 0;
@@ -3300,7 +3302,8 @@ section_is_mapped (struct obj_section *o
case ovly_auto: /* overlay debugging automatic */
/* Unles there is a gdbarch_overlay_update function,
there's really nothing useful to do here (can't really go auto) */
- if (gdbarch_overlay_update_p (current_gdbarch))
+ gdbarch = get_objfile_arch (osect->objfile);
+ if (gdbarch_overlay_update_p (gdbarch))
{
if (overlay_cache_invalid)
{
@@ -3308,7 +3311,7 @@ section_is_mapped (struct obj_section *o
overlay_cache_invalid = 0;
}
if (osect->ovly_mapped == -1)
- gdbarch_overlay_update (current_gdbarch, osect);
+ gdbarch_overlay_update (gdbarch, osect);
}
/* fall thru to manual case */
case ovly_on: /* overlay debugging manual */
@@ -3709,8 +3712,6 @@ enum ovly_index
{
VMA, SIZE, LMA, MAPPED
};
-#define TARGET_LONG_BYTES (gdbarch_long_bit (current_gdbarch) \
- / TARGET_CHAR_BIT)
/* Throw away the cached copy of _ovly_table */
static void
@@ -3736,19 +3737,19 @@ simple_free_overlay_region_table (void)
}
#endif
-/* Read an array of ints from the target into a local buffer.
+/* Read an array of ints of size SIZE from the target into a local buffer.
Convert to host order. int LEN is number of ints */
static void
-read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr, int len)
+read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
+ int len, int size)
{
/* FIXME (alloca): Not safe if array is very large. */
- gdb_byte *buf = alloca (len * TARGET_LONG_BYTES);
+ gdb_byte *buf = alloca (len * size);
int i;
- read_memory (memaddr, buf, len * TARGET_LONG_BYTES);
+ read_memory (memaddr, buf, len * size);
for (i = 0; i < len; i++)
- myaddr[i] = extract_unsigned_integer (TARGET_LONG_BYTES * i + buf,
- TARGET_LONG_BYTES);
+ myaddr[i] = extract_unsigned_integer (size * i + buf, size);
}
/* Find and grab a copy of the target _ovly_table
@@ -3757,6 +3758,8 @@ static int
simple_read_overlay_table (void)
{
struct minimal_symbol *novlys_msym, *ovly_table_msym;
+ struct gdbarch *gdbarch;
+ int word_size;
simple_free_overlay_table ();
novlys_msym = lookup_minimal_symbol ("_novlys", NULL, NULL);
@@ -3777,13 +3780,16 @@ simple_read_overlay_table (void)
return 0;
}
+ gdbarch = get_objfile_arch (msymbol_objfile (ovly_table_msym));
+ word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+
cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (novlys_msym), 4);
cache_ovly_table
= (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
read_target_long_array (cache_ovly_table_base,
(unsigned int *) cache_ovly_table,
- cache_novlys * 4);
+ cache_novlys * 4, word_size);
return 1; /* SUCCESS */
}
@@ -3808,10 +3814,12 @@ simple_read_overlay_region_table (void)
msym = lookup_minimal_symbol ("_ovly_region_table", NULL, NULL);
if (msym != NULL)
{
+ struct gdbarch *gdbarch = get_objfile_arch (msymbol_objfile (msym));
+ int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
read_target_long_array (cache_ovly_region_table_base,
(unsigned int *) cache_ovly_region_table,
- cache_novly_regions * 3);
+ cache_novly_regions * 3, word_size);
}
else
return 0; /* failure */
@@ -3836,6 +3844,8 @@ simple_overlay_update_1 (struct obj_sect
int i, size;
bfd *obfd = osect->objfile->obfd;
asection *bsect = osect->the_bfd_section;
+ struct gdbarch *gdbarch = get_objfile_arch (osect->objfile);
+ int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
size = bfd_get_section_size (osect->the_bfd_section);
for (i = 0; i < cache_novlys; i++)
@@ -3843,8 +3853,9 @@ simple_overlay_update_1 (struct obj_sect
&& cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
/* && cache_ovly_table[i][SIZE] == size */ )
{
- read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES,
- (unsigned int *) cache_ovly_table[i], 4);
+ read_target_long_array (cache_ovly_table_base + i * word_size,
+ (unsigned int *) cache_ovly_table[i],
+ 4, word_size);
if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
&& cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
/* && cache_ovly_table[i][SIZE] == size */ )
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com