aboutsummaryrefslogtreecommitdiff
path: root/gdb/record-full.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/record-full.c')
-rw-r--r--gdb/record-full.c76
1 files changed, 33 insertions, 43 deletions
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 7e3da27..e2298b3 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -908,7 +908,7 @@ record_full_exec_insn (struct regcache *regcache,
}
}
-static void record_full_restore (void);
+static void record_full_restore (struct bfd &cbfd);
/* Asynchronous signal handle registered as event loop source for when
we have pending events ready to be passed to the core. */
@@ -921,10 +921,11 @@ record_full_async_inferior_event_handler (gdb_client_data data)
inferior_event_handler (INF_REG_EVENT);
}
-/* Open the process record target for 'core' files. */
+/* Open the process record target for 'core' files. CBFD is the core file
+ containing the record information. */
static void
-record_full_core_open_1 ()
+record_full_core_open_1 (struct bfd &cbfd)
{
regcache *regcache = get_thread_regcache (inferior_thread ());
int regnum = gdbarch_num_regs (regcache->arch ());
@@ -937,11 +938,10 @@ record_full_core_open_1 ()
for (i = 0; i < regnum; i ++)
record_full_core_regbuf->raw_supply (i, *regcache);
- record_full_core_sections
- = build_section_table (current_program_space->core_bfd ());
+ record_full_core_sections = build_section_table (&cbfd);
current_inferior ()->push_target (&record_full_core_ops);
- record_full_restore ();
+ record_full_restore (cbfd);
}
/* Open the process record target for 'live' processes. */
@@ -987,8 +987,8 @@ record_full_open (const char *args, int from_tty)
record_full_list = &record_full_first;
record_full_list->next = NULL;
- if (current_program_space->core_bfd ())
- record_full_core_open_1 ();
+ if (current_program_space->core_bfd () != nullptr)
+ record_full_core_open_1 (*current_program_space->core_bfd ());
else
record_full_open_1 ();
@@ -1084,14 +1084,15 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
if (!RECORD_FULL_IS_REPLAY)
{
- struct gdbarch *gdbarch = target_thread_architecture (ptid);
+ struct regcache *regcache = get_thread_regcache (inferior_thread ());
+ struct gdbarch *gdbarch = regcache->arch ();
- record_full_message (get_thread_regcache (inferior_thread ()), signal);
+ record_full_message (regcache, signal);
if (!step)
{
/* This is not hard single step. */
- if (!gdbarch_software_single_step_p (gdbarch))
+ if (!gdbarch_get_next_pcs_p (gdbarch))
{
/* This is a normal continue. */
step = 1;
@@ -1266,7 +1267,7 @@ record_full_wait_1 (struct target_ops *ops,
process_stratum_target *proc_target
= current_inferior ()->process_target ();
- if (gdbarch_software_single_step_p (gdbarch))
+ if (gdbarch_get_next_pcs_p (gdbarch))
{
/* Try to insert the software single step breakpoint.
If insert success, set step to 0. */
@@ -2332,9 +2333,10 @@ netorder32 (uint32_t input)
return ret;
}
-/* Restore the execution log from a core_bfd file. */
+/* Restore the execution log from core file CBFD. */
+
static void
-record_full_restore (void)
+record_full_restore (struct bfd &cbfd)
{
uint32_t magic;
struct record_full_entry *rec;
@@ -2342,11 +2344,6 @@ record_full_restore (void)
uint32_t osec_size;
int bfd_offset = 0;
- /* We restore the execution log from the open core bfd,
- if there is one. */
- if (current_program_space->core_bfd () == nullptr)
- return;
-
/* "record_full_restore" can only be called when record list is empty. */
gdb_assert (record_full_first.next == NULL);
@@ -2354,7 +2351,7 @@ record_full_restore (void)
gdb_printf (gdb_stdlog, "Restoring recording from core file.\n");
/* Now need to find our special note section. */
- osec = bfd_get_section_by_name (current_program_space->core_bfd (), "null0");
+ osec = bfd_get_section_by_name (&cbfd, "null0");
if (record_debug)
gdb_printf (gdb_stdlog, "Find precord section %s.\n",
osec ? "succeeded" : "failed");
@@ -2365,11 +2362,10 @@ record_full_restore (void)
gdb_printf (gdb_stdlog, "%s", bfd_section_name (osec));
/* Check the magic code. */
- bfdcore_read (current_program_space->core_bfd (), osec, &magic,
- sizeof (magic), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &magic, sizeof (magic), &bfd_offset);
if (magic != RECORD_FULL_FILE_MAGIC)
error (_("Version mismatch or file format error in core file %s."),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
if (record_debug)
gdb_printf (gdb_stdlog,
" Reading 4-byte magic cookie "
@@ -2395,23 +2391,21 @@ record_full_restore (void)
/* We are finished when offset reaches osec_size. */
if (bfd_offset >= osec_size)
break;
- bfdcore_read (current_program_space->core_bfd (), osec, &rectype,
- sizeof (rectype), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &rectype, sizeof (rectype), &bfd_offset);
switch (rectype)
{
case record_full_reg: /* reg */
/* Get register number to regnum. */
- bfdcore_read (current_program_space->core_bfd (), osec, &regnum,
- sizeof (regnum), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &regnum, sizeof (regnum),
+ &bfd_offset);
regnum = netorder32 (regnum);
rec = record_full_reg_alloc (regcache, regnum);
/* Get val. */
- bfdcore_read (current_program_space->core_bfd (), osec,
- record_full_get_loc (rec), rec->u.reg.len,
- &bfd_offset);
+ bfdcore_read (&cbfd, osec, record_full_get_loc (rec),
+ rec->u.reg.len, &bfd_offset);
if (record_debug)
gdb_printf (gdb_stdlog,
@@ -2424,21 +2418,18 @@ record_full_restore (void)
case record_full_mem: /* mem */
/* Get len. */
- bfdcore_read (current_program_space->core_bfd (), osec, &len,
- sizeof (len), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &len, sizeof (len), &bfd_offset);
len = netorder32 (len);
/* Get addr. */
- bfdcore_read (current_program_space->core_bfd (), osec, &addr,
- sizeof (addr), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &addr, sizeof (addr), &bfd_offset);
addr = netorder64 (addr);
rec = record_full_mem_alloc (addr, len);
/* Get val. */
- bfdcore_read (current_program_space->core_bfd (), osec,
- record_full_get_loc (rec), rec->u.mem.len,
- &bfd_offset);
+ bfdcore_read (&cbfd, osec, record_full_get_loc (rec),
+ rec->u.mem.len, &bfd_offset);
if (record_debug)
gdb_printf (gdb_stdlog,
@@ -2456,14 +2447,13 @@ record_full_restore (void)
record_full_insn_num ++;
/* Get signal value. */
- bfdcore_read (current_program_space->core_bfd (), osec, &signal,
- sizeof (signal), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &signal, sizeof (signal),
+ &bfd_offset);
signal = netorder32 (signal);
rec->u.end.sigval = (enum gdb_signal) signal;
/* Get insn count. */
- bfdcore_read (current_program_space->core_bfd (), osec, &count,
- sizeof (count), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &count, sizeof (count), &bfd_offset);
count = netorder32 (count);
rec->u.end.insn_num = count;
record_full_insn_count = count + 1;
@@ -2479,7 +2469,7 @@ record_full_restore (void)
default:
error (_("Bad entry type in core file %s."),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
break;
}
@@ -2509,7 +2499,7 @@ record_full_restore (void)
/* Succeeded. */
gdb_printf (_("Restored records from core file %s.\n"),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}