2011-05-20 Pedro Alves <pedro@codesourcery.com>
gdb/ * tracepoint.c: Include exceptions.h. (TFILE_PID): Move higher in file. (tfile_open): Delay pushing the tfile target until we're assured the tfile header is present in the file. Wrap reading the initial newline-terminated lines in TRY_CATCH. Pop the target if the initial setup failed. Add the tfile's thread immediately aftwards, before any non-essential setup. Don't skip post_create_inferior if there are no traceframes present in the file. (tfile_close): Remove redundant check for null before xfree call. (tfile_thread_alive): New function. (init_tfile_ops): Register it as to_thread_alive callback.
This commit is contained in:
parent
6823e2b15f
commit
e93a69ed93
@ -1,3 +1,18 @@
|
||||
2011-05-20 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
* tracepoint.c: Include exceptions.h.
|
||||
(TFILE_PID): Move higher in file.
|
||||
(tfile_open): Delay pushing the tfile target until we're assured
|
||||
the tfile header is present in the file. Wrap reading the initial
|
||||
newline-terminated lines in TRY_CATCH. Pop the target if the
|
||||
initial setup failed. Add the tfile's thread immediately
|
||||
aftwards, before any non-essential setup. Don't skip
|
||||
post_create_inferior if there are no traceframes present in the
|
||||
file.
|
||||
(tfile_close): Remove redundant check for null before xfree call.
|
||||
(tfile_thread_alive): New function.
|
||||
(init_tfile_ops): Register it as to_thread_alive callback.
|
||||
|
||||
2011-05-20 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
* tracepoint.c (tfile_open): Delete #if 0'd code.
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "ax.h"
|
||||
#include "ax-gdb.h"
|
||||
#include "memrange.h"
|
||||
#include "exceptions.h"
|
||||
|
||||
/* readline include files */
|
||||
#include "readline/readline.h"
|
||||
@ -80,6 +81,8 @@ extern int bin2hex (const gdb_byte *bin, char *hex, int count);
|
||||
large. (400 - 31)/2 == 184 */
|
||||
#define MAX_AGENT_EXPR_LEN 184
|
||||
|
||||
#define TFILE_PID (1)
|
||||
|
||||
/* A hook used to notify the UI of tracepoint operations. */
|
||||
|
||||
void (*deprecated_trace_find_hook) (char *arg, int from_tty);
|
||||
@ -3293,6 +3296,7 @@ tfile_read (gdb_byte *readbuf, int size)
|
||||
static void
|
||||
tfile_open (char *filename, int from_tty)
|
||||
{
|
||||
volatile struct gdb_exception ex;
|
||||
char *temp;
|
||||
struct cleanup *old_chain;
|
||||
int flags;
|
||||
@ -3330,8 +3334,6 @@ tfile_open (char *filename, int from_tty)
|
||||
discard_cleanups (old_chain); /* Don't free filename any more. */
|
||||
unpush_target (&tfile_ops);
|
||||
|
||||
push_target (&tfile_ops);
|
||||
|
||||
trace_filename = xstrdup (filename);
|
||||
trace_fd = scratch_chan;
|
||||
|
||||
@ -3344,6 +3346,8 @@ tfile_open (char *filename, int from_tty)
|
||||
&& (strncmp (header + 1, "TRACE0\n", 7) == 0)))
|
||||
error (_("File is not a valid trace file."));
|
||||
|
||||
push_target (&tfile_ops);
|
||||
|
||||
trace_regblock_size = 0;
|
||||
ts = current_trace_status ();
|
||||
/* We know we're working with a file. */
|
||||
@ -3358,28 +3362,52 @@ tfile_open (char *filename, int from_tty)
|
||||
|
||||
cur_traceframe_number = -1;
|
||||
|
||||
/* Read through a section of newline-terminated lines that
|
||||
define things like tracepoints. */
|
||||
i = 0;
|
||||
while (1)
|
||||
TRY_CATCH (ex, RETURN_MASK_ALL)
|
||||
{
|
||||
tfile_read (&byte, 1);
|
||||
|
||||
++bytes;
|
||||
if (byte == '\n')
|
||||
/* Read through a section of newline-terminated lines that
|
||||
define things like tracepoints. */
|
||||
i = 0;
|
||||
while (1)
|
||||
{
|
||||
/* Empty line marks end of the definition section. */
|
||||
if (i == 0)
|
||||
break;
|
||||
linebuf[i] = '\0';
|
||||
i = 0;
|
||||
tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs);
|
||||
tfile_read (&byte, 1);
|
||||
|
||||
++bytes;
|
||||
if (byte == '\n')
|
||||
{
|
||||
/* Empty line marks end of the definition section. */
|
||||
if (i == 0)
|
||||
break;
|
||||
linebuf[i] = '\0';
|
||||
i = 0;
|
||||
tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs);
|
||||
}
|
||||
else
|
||||
linebuf[i++] = byte;
|
||||
if (i >= 1000)
|
||||
error (_("Excessively long lines in trace file"));
|
||||
}
|
||||
else
|
||||
linebuf[i++] = byte;
|
||||
if (i >= 1000)
|
||||
error (_("Excessively long lines in trace file"));
|
||||
|
||||
/* Record the starting offset of the binary trace data. */
|
||||
trace_frames_offset = bytes;
|
||||
|
||||
/* If we don't have a blocksize, we can't interpret the
|
||||
traceframes. */
|
||||
if (trace_regblock_size == 0)
|
||||
error (_("No register block size recorded in trace file"));
|
||||
}
|
||||
if (ex.reason < 0)
|
||||
{
|
||||
/* Pop the partially set up target. */
|
||||
pop_target ();
|
||||
throw_exception (ex);
|
||||
}
|
||||
|
||||
inferior_appeared (current_inferior (), TFILE_PID);
|
||||
inferior_ptid = pid_to_ptid (TFILE_PID);
|
||||
add_thread_silent (inferior_ptid);
|
||||
|
||||
if (ts->traceframe_count <= 0)
|
||||
warning (_("No traceframes present in this file."));
|
||||
|
||||
/* Add the file's tracepoints and variables into the current mix. */
|
||||
|
||||
@ -3389,24 +3417,6 @@ tfile_open (char *filename, int from_tty)
|
||||
|
||||
merge_uploaded_tracepoints (&uploaded_tps);
|
||||
|
||||
/* Record the starting offset of the binary trace data. */
|
||||
trace_frames_offset = bytes;
|
||||
|
||||
/* If we don't have a blocksize, we can't interpret the
|
||||
traceframes. */
|
||||
if (trace_regblock_size == 0)
|
||||
error (_("No register block size recorded in trace file"));
|
||||
if (ts->traceframe_count <= 0)
|
||||
{
|
||||
warning (_("No traceframes present in this file."));
|
||||
return;
|
||||
}
|
||||
|
||||
#define TFILE_PID (1)
|
||||
inferior_appeared (current_inferior (), TFILE_PID);
|
||||
inferior_ptid = pid_to_ptid (TFILE_PID);
|
||||
add_thread_silent (inferior_ptid);
|
||||
|
||||
post_create_inferior (&tfile_ops, from_tty);
|
||||
}
|
||||
|
||||
@ -3712,8 +3722,8 @@ tfile_close (int quitting)
|
||||
|
||||
close (trace_fd);
|
||||
trace_fd = -1;
|
||||
if (trace_filename)
|
||||
xfree (trace_filename);
|
||||
xfree (trace_filename);
|
||||
trace_filename = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4206,6 +4216,12 @@ tfile_has_registers (struct target_ops *ops)
|
||||
return traceframe_number != -1;
|
||||
}
|
||||
|
||||
static int
|
||||
tfile_thread_alive (struct target_ops *ops, ptid_t ptid)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Callback for traceframe_walk_blocks. Builds a traceframe_info
|
||||
object for the tfile target's current traceframe. */
|
||||
|
||||
@ -4278,6 +4294,7 @@ init_tfile_ops (void)
|
||||
tfile_ops.to_has_stack = tfile_has_stack;
|
||||
tfile_ops.to_has_registers = tfile_has_registers;
|
||||
tfile_ops.to_traceframe_info = tfile_traceframe_info;
|
||||
tfile_ops.to_thread_alive = tfile_thread_alive;
|
||||
tfile_ops.to_magic = OPS_MAGIC;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user