aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-01-28 16:18:55 +0000
committerPedro Alves <palves@redhat.com>2011-01-28 16:18:55 +0000
commitffd5ec2486b4786e903d72aca3cc42aade30b15f (patch)
tree356ac10e3f74d39f759adf0f8778a39820a6046a
parente8c9e0a18f11d0247f43aecf6771494ee033177a (diff)
downloadgdb-ffd5ec2486b4786e903d72aca3cc42aade30b15f.zip
gdb-ffd5ec2486b4786e903d72aca3cc42aade30b15f.tar.gz
gdb-ffd5ec2486b4786e903d72aca3cc42aade30b15f.tar.bz2
gdb/
* tracepoint.c (tfile_xfer_partial): If there's no traceframe selected, don't try iterating over the traceframe's blocks. (tfile_has_stack): If there's no traceframe selected, then there's no stack. (tfile_has_registers): If there's no traceframe selected, then there's no registers. gdb/testsuite/ * gdb.trace/tfile.exp: Test that with no traceframe selected, there's no stack or registers.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.trace/tfile.exp8
-rw-r--r--gdb/tracepoint.c62
4 files changed, 55 insertions, 29 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aab7ed1..fd1bf3a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
2011-01-28 Pedro Alves <pedro@codesourcery.com>
+ * tracepoint.c (tfile_xfer_partial): If there's no traceframe
+ selected, don't try iterating over the traceframe's blocks.
+ (tfile_has_stack): If there's no traceframe selected, then there's
+ no stack.
+ (tfile_has_registers): If there's no traceframe selected, then
+ there's no registers.
+
+2011-01-28 Pedro Alves <pedro@codesourcery.com>
+
* target.c (memory_xfer_partial): No need to restore shadows if we
haven't read anything.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3b9b284..1e7543e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-28 Pedro Alves <pedro@codesourcery.com>
+
+ * gdb.trace/tfile.exp: Test that with no traceframe selected,
+ there's no stack or registers.
+
2011-01-26 Tom Tromey <tromey@redhat.com>
* gdb.python/py-prettyprint.exp (run_lang_tests): Ensure no blank
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index ec21a89..0614423 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -92,6 +92,14 @@ Trace buffer has 256 bytes of 4096 bytes free \\(93% full\\).*
Looking at trace frame 0, tracepoint .*" \
"tstatus on trace file"
+gdb_test "tfind end" "No longer looking at any trace frame" "leave tfind mode"
+
+gdb_test "backtrace" "No stack\." \
+ "no stack if no traceframe selected"
+
+gdb_test "info registers" "The program has no registers now\." \
+ "no registers if no traceframe selected"
+
# Now start afresh, using only a trace file.
gdb_exit
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index b15f75d..59fb593 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3970,8 +3970,6 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
- int pos;
-
/* We're only doing regular memory for now. */
if (object != TARGET_OBJECT_MEMORY)
return -1;
@@ -3979,36 +3977,42 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
if (readbuf == NULL)
error (_("tfile_xfer_partial: trace file is read-only"));
- /* Iterate through the traceframe's blocks, looking for memory. */
- pos = 0;
- while ((pos = traceframe_find_block_type ('M', pos)) >= 0)
+ if (traceframe_number != -1)
{
- ULONGEST maddr, amt;
- unsigned short mlen;
+ int pos = 0;
- tfile_read ((gdb_byte *) &maddr, 8);
- maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8,
- gdbarch_byte_order (target_gdbarch));
- tfile_read ((gdb_byte *) &mlen, 2);
- mlen = (unsigned short)
- extract_unsigned_integer ((gdb_byte *) &mlen, 2,
- gdbarch_byte_order (target_gdbarch));
-
- /* If the block includes the first part of the desired range,
- return as much it has; GDB will re-request the remainder,
- which might be in a different block of this trace frame. */
- if (maddr <= offset && offset < (maddr + mlen))
+ /* Iterate through the traceframe's blocks, looking for
+ memory. */
+ while ((pos = traceframe_find_block_type ('M', pos)) >= 0)
{
- amt = (maddr + mlen) - offset;
- if (amt > len)
- amt = len;
+ ULONGEST maddr, amt;
+ unsigned short mlen;
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
- tfile_read (readbuf, amt);
- return amt;
- }
+ tfile_read ((gdb_byte *) &maddr, 8);
+ maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8,
+ byte_order);
+ tfile_read ((gdb_byte *) &mlen, 2);
+ mlen = (unsigned short)
+ extract_unsigned_integer ((gdb_byte *) &mlen, 2, byte_order);
+
+ /* If the block includes the first part of the desired
+ range, return as much it has; GDB will re-request the
+ remainder, which might be in a different block of this
+ trace frame. */
+ if (maddr <= offset && offset < (maddr + mlen))
+ {
+ amt = (maddr + mlen) - offset;
+ if (amt > len)
+ amt = len;
+
+ tfile_read (readbuf, amt);
+ return amt;
+ }
- /* Skip over this block. */
- pos += (8 + 2 + mlen);
+ /* Skip over this block. */
+ pos += (8 + 2 + mlen);
+ }
}
/* It's unduly pedantic to refuse to look at the executable for
@@ -4095,13 +4099,13 @@ tfile_has_memory (struct target_ops *ops)
static int
tfile_has_stack (struct target_ops *ops)
{
- return 1;
+ return traceframe_number != -1;
}
static int
tfile_has_registers (struct target_ops *ops)
{
- return 1;
+ return traceframe_number != -1;
}
static void