aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-09-21 13:54:03 +0000
committerDaniel Jacobowitz <drow@false.org>2006-09-21 13:54:03 +0000
commitfd79eceebf094938376c671ea3538a31d4f63eac (patch)
tree40bfd6dc3f8a1035a4eedb63f57460ebf033284a /gdb/target.c
parent253c8abb67a72cdfcdb2be4b92e2dba8689e6554 (diff)
downloadgdb-fd79eceebf094938376c671ea3538a31d4f63eac.zip
gdb-fd79eceebf094938376c671ea3538a31d4f63eac.tar.gz
gdb-fd79eceebf094938376c671ea3538a31d4f63eac.tar.bz2
gdb/
2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * Makefile.in (SFILES): Add memory-map.c and xml-support.c. (memory_map_h, xml_support_h): New. (target_h): Add vec_h dependency. (COMMON_OBS): Add memory-map.o and xml-support.o. (memory-map.o, xml-support.o): New rules. (remote.o): Update. * exceptions.h (enum errors): Add XML_PARSE_ERROR. * infcmd.c (run_command_1, attach_command): Call target_pre_inferior. * memattr.c (default_mem_attrib): Initialize blocksize. (target_mem_region_list, mem_use_target) (target_mem_regions_valid, mem_region_cmp, mem_region_init) (require_user_regions, require_target_regions) (invalidate_target_mem_regions): New. (create_mem_region): Use mem_region_init. (mem_clear): Move higher. (lookup_mem_region): Use require_target_regions. (mem_command): Implement "mem auto". (mem_info_command): Handle target-supplied regions and flash attributes. (mem_enable_command, mem_disable_command, mem_delete_command): Use require_user_regions. (_initialize_mem): Mention "mem auto" in help. * memattr.h (enum mem_access_mode): Add MEM_FLASH. (struct mem_attrib): Add blocksize. (invalidate_target_mem_regions, mem_region_init, mem_region_cmp): New prototypes. * remote.c: Include "memory-map.h". (PACKET_qXfer_memory_map): New enum value. (remote_protocol_features): Add qXfer:memory-map:read. (remote_xfer_partial): Handle memory maps. (remote_memory_map): New. (init_remote_ops, init_remote_async_ops): Set to_memory_map. (_initialize_remote): Register qXfer:memory-map:read. * target.c (update_current_target): Mention to_memory_map. (target_memory_map, target_pre_inferior): New. (target_preopen): Call target_pre_inferior. * target.h: Include "vec.h". (enum target_object): Add TARGET_OBJECT_MEMORY_MAP. (struct target_ops): Add to_memory_map. (target_memory_map, target_pre_inferior): New prototypes. * memory-map.c, memory-map.h, xml-support.c, xml-support.h: New files. gdb/doc/ 2006-09-21 Vladimir Prus <vladimir@codesourcery.com> Daniel Jacobowitz <dan@codesourcery.com> * gdb.texinfo (Memory Region Attributes): Mention target-supplied memory regions and "mem auto".
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/gdb/target.c b/gdb/target.c
index 65d24a5..3f63527 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -464,6 +464,7 @@ update_current_target (void)
INHERIT (to_make_corefile_notes, t);
INHERIT (to_get_thread_local_address, t);
INHERIT (to_magic, t);
+ /* Do not inherit to_memory_map. */
}
#undef INHERIT
@@ -1040,6 +1041,54 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
return EIO;
}
+/* Fetch the target's memory map. */
+
+VEC(mem_region_s) *
+target_memory_map (void)
+{
+ VEC(mem_region_s) *result;
+ struct mem_region *last_one, *this_one;
+ int ix;
+ struct target_ops *t;
+
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_memory_map ()\n");
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_memory_map != NULL)
+ break;
+
+ if (t == NULL)
+ return NULL;
+
+ result = t->to_memory_map (t);
+ if (result == NULL)
+ return NULL;
+
+ qsort (VEC_address (mem_region_s, result),
+ VEC_length (mem_region_s, result),
+ sizeof (struct mem_region), mem_region_cmp);
+
+ /* Check that regions do not overlap. Simultaneously assign
+ a numbering for the "mem" commands to use to refer to
+ each region. */
+ last_one = NULL;
+ for (ix = 0; VEC_iterate (mem_region_s, result, ix, this_one); ix++)
+ {
+ this_one->number = ix;
+
+ if (last_one && last_one->hi > this_one->lo)
+ {
+ warning (_("Overlapping regions in memory map: ignoring"));
+ VEC_free (mem_region_s, result);
+ return NULL;
+ }
+ last_one = this_one;
+ }
+
+ return result;
+}
+
#ifndef target_stopped_data_address_p
int
target_stopped_data_address_p (struct target_ops *target)
@@ -1356,6 +1405,18 @@ target_info (char *args, int from_tty)
}
}
+/* This function is called before any new inferior is created, e.g.
+ by running a program, attaching, or connecting to a target.
+ It cleans up any state from previous invocations which might
+ change between runs. This is a subset of what target_preopen
+ resets (things which might change between targets). */
+
+void
+target_pre_inferior (int from_tty)
+{
+ invalidate_target_mem_regions ();
+}
+
/* This is to be called by the open routine before it does
anything. */
@@ -1378,6 +1439,8 @@ target_preopen (int from_tty)
if (target_has_execution)
pop_target ();
+
+ target_pre_inferior (from_tty);
}
/* Detach a target after doing deferred register stores. */