diff options
author | Pedro Alves <pedro@codesourcery.com> | 2011-02-14 11:22:29 +0000 |
---|---|---|
committer | Pedro Alves <pedro@codesourcery.com> | 2011-02-14 11:22:29 +0000 |
commit | 67d3c91a65d1fb133b1a45386cbc27bed1fe1490 (patch) | |
tree | 982282029409816459cabbdcc5e298e548733730 /gdb/tracepoint.c | |
parent | d1a11fe646d2bf954560fcc5cc4a99678d984722 (diff) | |
download | gdb-67d3c91a65d1fb133b1a45386cbc27bed1fe1490.tar.gz |
gdb/
* target.c (target_read_live_memory): New function.
(memory_xfer_live_readonly_partial): New.
(memory_xfer_partial): If reading from a traceframe, fallback to
reading unavailable read-only memory from read-only regions of
live target memory.
* tracepoint.c (disconnect_tracing): Adjust.
(set_current_traceframe): New, factored out from
set_traceframe_number.
(set_traceframe_number): Reimplement to only change the traceframe
number on the GDB side.
(do_restore_current_traceframe_cleanup): Adjust.
(make_cleanup_restore_traceframe_number): New.
(cur_traceframe_number): New global.
(tfile_open): Set cur_traceframe_number to no traceframe.
(set_tfile_traceframe): New function.
(tfile_trace_find): If looking up a traceframe using any method
other than by number, make sure the current tfile traceframe
matches gdb's current traceframe. Update the current tfile
traceframe if the lookup succeeded.
(tfile_fetch_registers, tfile_xfer_partial)
(tfile_get_trace_state_variable_value): Make sure the remote
traceframe matches gdb's current traceframe.
* remote.c (remote_traceframe_number): New global.
(remote_open_1): Set it to -1.
(set_remote_traceframe): New function.
(remote_fetch_registers, remote_store_registers)
(remote_xfer_memory, remote_xfer_partial)
(remote_get_trace_state_variable_value): Make sure the remote
traceframe matches gdb's current traceframe.
(remote_trace_find): If looking up a traceframe using any method
other than by number, make sure the current remote traceframe
matches gdb's current traceframe. Update the current remote
traceframe if the lookup succeeded.
* infrun.c (fetch_inferior_event): Adjust.
* tracepoint.h (set_current_traceframe): Declare.
(get_traceframe_number, set_traceframe_number): Add describing
comments.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 18f3c7f1d86..498f47c12d8 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1927,7 +1927,7 @@ disconnect_tracing (int from_tty) confusing upon reconnection. Just use these calls instead of full tfind_1 behavior because we're in the middle of detaching, and there's no point to updating current stack frame etc. */ - set_traceframe_number (-1); + set_current_traceframe (-1); set_traceframe_context (NULL); } @@ -2935,7 +2935,7 @@ get_traceframe_number (void) if NUM is already current. */ void -set_traceframe_number (int num) +set_current_traceframe (int num) { int newnum; @@ -2959,6 +2959,15 @@ set_traceframe_number (int num) clear_traceframe_info (); } +/* Make the traceframe NUM be the current trace frame, and do nothing + more. */ + +void +set_traceframe_number (int num) +{ + traceframe_number = num; +} + /* A cleanup used when switching away and back from tfind mode. */ struct current_traceframe_cleanup @@ -2972,7 +2981,7 @@ do_restore_current_traceframe_cleanup (void *arg) { struct current_traceframe_cleanup *old = arg; - set_traceframe_number (old->traceframe_number); + set_current_traceframe (old->traceframe_number); } static void @@ -2995,6 +3004,12 @@ make_cleanup_restore_current_traceframe (void) restore_current_traceframe_cleanup_dtor); } +struct cleanup * +make_cleanup_restore_traceframe_number (void) +{ + return make_cleanup_restore_integer (&traceframe_number); +} + /* Given a number and address, return an uploaded tracepoint with that number, creating if necessary. */ @@ -3247,6 +3262,7 @@ char *trace_filename; int trace_fd = -1; off_t trace_frames_offset; off_t cur_offset; +int cur_traceframe_number; int cur_data_size; int trace_regblock_size; @@ -3338,6 +3354,8 @@ tfile_open (char *filename, int from_tty) ts->disconnected_tracing = 0; ts->circular_buffer = 0; + cur_traceframe_number = -1; + /* Read through a section of newline-terminated lines that define things like tracepoints. */ i = 0; @@ -3752,6 +3770,28 @@ tfile_get_traceframe_address (off_t tframe_offset) return addr; } +/* Make tfile's selected traceframe match GDB's selected + traceframe. */ + +static void +set_tfile_traceframe (void) +{ + int newnum; + + if (cur_traceframe_number == get_traceframe_number ()) + return; + + /* Avoid recursion, tfile_trace_find calls us again. */ + cur_traceframe_number = get_traceframe_number (); + + newnum = target_trace_find (tfind_number, + get_traceframe_number (), 0, 0, NULL); + + /* Should not happen. If it does, all bets are off. */ + if (newnum != get_traceframe_number ()) + warning (_("could not set tfile's traceframe")); +} + /* Given a type of search and some parameters, scan the collection of traceframes in the file looking for a match. When found, return both the traceframe and tracepoint number, otherwise -1 for @@ -3768,6 +3808,12 @@ tfile_trace_find (enum trace_find_type type, int num, off_t offset, tframe_offset; ULONGEST tfaddr; + /* Lookups other than by absolute frame number depend on the current + trace selected, so make sure it is correct on the tfile end + first. */ + if (type != tfind_number) + set_tfile_traceframe (); + lseek (trace_fd, trace_frames_offset, SEEK_SET); offset = trace_frames_offset; while (1) @@ -3820,6 +3866,7 @@ tfile_trace_find (enum trace_find_type type, int num, *tpp = tpnum; cur_offset = offset; cur_data_size = data_size; + cur_traceframe_number = tfnum; return tfnum; } /* Skip past the traceframe's data. */ @@ -3936,6 +3983,8 @@ tfile_fetch_registers (struct target_ops *ops, if (!trace_regblock_size) return; + set_tfile_traceframe (); + regs = alloca (trace_regblock_size); if (traceframe_find_block_type ('R', 0) >= 0) @@ -4019,7 +4068,9 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, if (readbuf == NULL) error (_("tfile_xfer_partial: trace file is read-only")); - if (traceframe_number != -1) + set_tfile_traceframe (); + + if (traceframe_number != -1) { int pos = 0; @@ -4102,6 +4153,8 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val) { int pos; + set_tfile_traceframe (); + pos = 0; while ((pos = traceframe_find_block_type ('V', pos)) >= 0) { |