mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-09 01:26:29 +08:00
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:
@ -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>
|
2011-05-20 Pedro Alves <pedro@codesourcery.com>
|
||||||
|
|
||||||
* tracepoint.c (tfile_open): Delete #if 0'd code.
|
* tracepoint.c (tfile_open): Delete #if 0'd code.
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "ax.h"
|
#include "ax.h"
|
||||||
#include "ax-gdb.h"
|
#include "ax-gdb.h"
|
||||||
#include "memrange.h"
|
#include "memrange.h"
|
||||||
|
#include "exceptions.h"
|
||||||
|
|
||||||
/* readline include files */
|
/* readline include files */
|
||||||
#include "readline/readline.h"
|
#include "readline/readline.h"
|
||||||
@ -80,6 +81,8 @@ extern int bin2hex (const gdb_byte *bin, char *hex, int count);
|
|||||||
large. (400 - 31)/2 == 184 */
|
large. (400 - 31)/2 == 184 */
|
||||||
#define MAX_AGENT_EXPR_LEN 184
|
#define MAX_AGENT_EXPR_LEN 184
|
||||||
|
|
||||||
|
#define TFILE_PID (1)
|
||||||
|
|
||||||
/* A hook used to notify the UI of tracepoint operations. */
|
/* A hook used to notify the UI of tracepoint operations. */
|
||||||
|
|
||||||
void (*deprecated_trace_find_hook) (char *arg, int from_tty);
|
void (*deprecated_trace_find_hook) (char *arg, int from_tty);
|
||||||
@ -3293,6 +3296,7 @@ tfile_read (gdb_byte *readbuf, int size)
|
|||||||
static void
|
static void
|
||||||
tfile_open (char *filename, int from_tty)
|
tfile_open (char *filename, int from_tty)
|
||||||
{
|
{
|
||||||
|
volatile struct gdb_exception ex;
|
||||||
char *temp;
|
char *temp;
|
||||||
struct cleanup *old_chain;
|
struct cleanup *old_chain;
|
||||||
int flags;
|
int flags;
|
||||||
@ -3330,8 +3334,6 @@ tfile_open (char *filename, int from_tty)
|
|||||||
discard_cleanups (old_chain); /* Don't free filename any more. */
|
discard_cleanups (old_chain); /* Don't free filename any more. */
|
||||||
unpush_target (&tfile_ops);
|
unpush_target (&tfile_ops);
|
||||||
|
|
||||||
push_target (&tfile_ops);
|
|
||||||
|
|
||||||
trace_filename = xstrdup (filename);
|
trace_filename = xstrdup (filename);
|
||||||
trace_fd = scratch_chan;
|
trace_fd = scratch_chan;
|
||||||
|
|
||||||
@ -3344,6 +3346,8 @@ tfile_open (char *filename, int from_tty)
|
|||||||
&& (strncmp (header + 1, "TRACE0\n", 7) == 0)))
|
&& (strncmp (header + 1, "TRACE0\n", 7) == 0)))
|
||||||
error (_("File is not a valid trace file."));
|
error (_("File is not a valid trace file."));
|
||||||
|
|
||||||
|
push_target (&tfile_ops);
|
||||||
|
|
||||||
trace_regblock_size = 0;
|
trace_regblock_size = 0;
|
||||||
ts = current_trace_status ();
|
ts = current_trace_status ();
|
||||||
/* We know we're working with a file. */
|
/* We know we're working with a file. */
|
||||||
@ -3358,28 +3362,52 @@ tfile_open (char *filename, int from_tty)
|
|||||||
|
|
||||||
cur_traceframe_number = -1;
|
cur_traceframe_number = -1;
|
||||||
|
|
||||||
/* Read through a section of newline-terminated lines that
|
TRY_CATCH (ex, RETURN_MASK_ALL)
|
||||||
define things like tracepoints. */
|
|
||||||
i = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
tfile_read (&byte, 1);
|
/* Read through a section of newline-terminated lines that
|
||||||
|
define things like tracepoints. */
|
||||||
++bytes;
|
i = 0;
|
||||||
if (byte == '\n')
|
while (1)
|
||||||
{
|
{
|
||||||
/* Empty line marks end of the definition section. */
|
tfile_read (&byte, 1);
|
||||||
if (i == 0)
|
|
||||||
break;
|
++bytes;
|
||||||
linebuf[i] = '\0';
|
if (byte == '\n')
|
||||||
i = 0;
|
{
|
||||||
tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs);
|
/* 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;
|
/* Record the starting offset of the binary trace data. */
|
||||||
if (i >= 1000)
|
trace_frames_offset = bytes;
|
||||||
error (_("Excessively long lines in trace file"));
|
|
||||||
|
/* 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. */
|
/* 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);
|
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);
|
post_create_inferior (&tfile_ops, from_tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3712,8 +3722,8 @@ tfile_close (int quitting)
|
|||||||
|
|
||||||
close (trace_fd);
|
close (trace_fd);
|
||||||
trace_fd = -1;
|
trace_fd = -1;
|
||||||
if (trace_filename)
|
xfree (trace_filename);
|
||||||
xfree (trace_filename);
|
trace_filename = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4206,6 +4216,12 @@ tfile_has_registers (struct target_ops *ops)
|
|||||||
return traceframe_number != -1;
|
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
|
/* Callback for traceframe_walk_blocks. Builds a traceframe_info
|
||||||
object for the tfile target's current traceframe. */
|
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_stack = tfile_has_stack;
|
||||||
tfile_ops.to_has_registers = tfile_has_registers;
|
tfile_ops.to_has_registers = tfile_has_registers;
|
||||||
tfile_ops.to_traceframe_info = tfile_traceframe_info;
|
tfile_ops.to_traceframe_info = tfile_traceframe_info;
|
||||||
|
tfile_ops.to_thread_alive = tfile_thread_alive;
|
||||||
tfile_ops.to_magic = OPS_MAGIC;
|
tfile_ops.to_magic = OPS_MAGIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user