/* Trace file TFILE format support in GDB.
- Copyright (C) 1997-2020 Free Software Foundation, Inc.
+ Copyright (C) 1997-2022 Free Software Foundation, Inc.
This file is part of GDB.
#include "regcache.h"
#include "inferior.h"
#include "gdbthread.h"
-#include "exec.h" /* exec_bfd */
+#include "exec.h"
#include "completer.h"
#include "filenames.h"
#include "remote.h"
= (struct tfile_trace_file_writer *) self;
gdb::optional<std::string> tdesc
- = target_fetch_description_xml (current_top_target ());
+ = target_fetch_description_xml (current_inferior ()->top_target ());
if (!tdesc)
return;
flags = O_BINARY | O_LARGEFILE;
flags |= O_RDONLY;
- scratch_chan = gdb_open_cloexec (filename.get (), flags, 0);
+ scratch_chan = gdb_open_cloexec (filename.get (), flags, 0).release ();
if (scratch_chan < 0)
perror_with_name (filename.get ());
/* Looks semi-reasonable. Toss the old trace file and work on the new. */
- unpush_target (&tfile_ops);
+ current_inferior ()->unpush_target (&tfile_ops);
trace_filename = filename.release ();
trace_fd = scratch_chan;
&& (startswith (header + 1, "TRACE0\n"))))
error (_("File is not a valid trace file."));
- push_target (&tfile_ops);
+ current_inferior ()->push_target (&tfile_ops);
trace_regblock_size = 0;
ts = current_trace_status ();
catch (const gdb_exception &ex)
{
/* Remove the partially set up target. */
- unpush_target (&tfile_ops);
+ current_inferior ()->unpush_target (&tfile_ops);
throw;
}
inferior_appeared (current_inferior (), TFILE_PID);
- inferior_ptid = ptid_t (TFILE_PID);
- add_thread_silent (&tfile_ops, inferior_ptid);
+
+ thread_info *thr = add_thread_silent (&tfile_ops, ptid_t (TFILE_PID));
+ switch_to_thread (thr);
if (ts->traceframe_count <= 0)
warning (_("No traceframes present in this file."));
merge_uploaded_tracepoints (&uploaded_tps);
- post_create_inferior (&tfile_ops, from_tty);
+ post_create_inferior (from_tty);
}
/* Interpret the given line from the definitions part of the trace
{
gdb_assert (trace_fd != -1);
- inferior_ptid = null_ptid; /* Avoid confusion from thread stuff. */
+ switch_to_no_thread (); /* Avoid confusion from thread stuff. */
exit_inferior_silent (current_inferior ());
::close (trace_fd);
if (num == -1)
{
if (tpp)
- *tpp = -1;
+ *tpp = -1;
return -1;
}
break;
tfile_read ((gdb_byte *) &data_size, 4);
data_size = (unsigned int) extract_unsigned_integer
- ((gdb_byte *) &data_size, 4,
+ ((gdb_byte *) &data_size, 4,
gdbarch_byte_order (target_gdbarch ()));
offset += 4;
case 'M':
lseek (trace_fd, cur_offset + pos + 8, SEEK_SET);
tfile_read ((gdb_byte *) &mlen, 2);
- mlen = (unsigned short)
- extract_unsigned_integer ((gdb_byte *) &mlen, 2,
- gdbarch_byte_order
- (target_gdbarch ()));
+ mlen = (unsigned short)
+ extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+ gdbarch_byte_order
+ (target_gdbarch ()));
lseek (trace_fd, mlen, SEEK_CUR);
pos += (8 + 2 + mlen);
break;
amt = len;
if (maddr != offset)
- lseek (trace_fd, offset - maddr, SEEK_CUR);
+ lseek (trace_fd, offset - maddr, SEEK_CUR);
tfile_read (readbuf, amt);
*xfered_len = amt;
return TARGET_XFER_OK;
buffer_grow_str (&trace_tdesc, "\n");
}
+void _initialize_tracefile_tfile ();
void
-_initialize_tracefile_tfile (void)
+_initialize_tracefile_tfile ()
{
add_target (tfile_target_info, tfile_target_open, filename_completer);
}