aboutsummaryrefslogtreecommitdiff
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2010-04-05 21:57:18 +0000
committerStan Shebs <shebs@codesourcery.com>2010-04-05 21:57:18 +0000
commitfce3c1f0f17879e1c60d1acb277a232f37255aab (patch)
treebf0a2376c01eb3a26327873a9e6645f47a559452 /gdb/tracepoint.c
parent9cdcc3e8b3ed0291e48a9783f4db6fb52cacd936 (diff)
downloadgdb-fce3c1f0f17879e1c60d1acb277a232f37255aab.zip
gdb-fce3c1f0f17879e1c60d1acb277a232f37255aab.tar.gz
gdb-fce3c1f0f17879e1c60d1acb277a232f37255aab.tar.bz2
2010-04-05 Stan Shebs <stan@codesourcery.com>
* tracepoint.c: Include gdbcore.h. (tfile_xfer_partial): Return partial results, also try reading from executable. (tfile_has_all_memory): New function. (init_tfile_ops): Use it. * gdb.trace/tfile.c: Add a variable split across two blocks, and a constant global. * gdb.trace/tfile.exp: Try to print them.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c65
1 files changed, 54 insertions, 11 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 0fb0e93..331d46c 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -45,6 +45,7 @@
#include "filenames.h"
#include "gdbthread.h"
#include "stack.h"
+#include "gdbcore.h"
#include "ax.h"
#include "ax-gdb.h"
@@ -3793,7 +3794,7 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
{
char block_type;
int pos, gotten;
- ULONGEST maddr;
+ ULONGEST maddr, amt;
unsigned short mlen;
/* We're only doing regular memory for now. */
@@ -3831,16 +3832,19 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
- if (maddr <= offset && (offset + len) <= (maddr + mlen))
- {
- gotten = read (trace_fd, readbuf, mlen);
- if (gotten < 0)
- perror_with_name (trace_filename);
- else if (gotten < mlen)
- error (_("Premature end of file qwhile reading trace file"));
-
- return mlen;
- }
+ /* 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;
+
+ read (trace_fd, readbuf, amt);
+ return amt;
+ }
lseek (trace_fd, mlen, SEEK_CUR);
pos += (8 + 2 + mlen);
break;
@@ -3854,6 +3858,38 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
break;
}
}
+
+ /* It's unduly pedantic to refuse to look at the executable for
+ read-only pieces; so do the equivalent of readonly regions aka
+ QTro packet. */
+ /* FIXME account for relocation at some point */
+ if (exec_bfd)
+ {
+ asection *s;
+ bfd_size_type size;
+ bfd_vma lma;
+
+ for (s = exec_bfd->sections; s; s = s->next)
+ {
+ if ((s->flags & SEC_LOAD) == 0 ||
+ (s->flags & SEC_READONLY) == 0)
+ continue;
+
+ lma = s->lma;
+ size = bfd_get_section_size (s);
+ if (lma <= offset && offset < (lma + size))
+ {
+ amt = (lma + size) - offset;
+ if (amt > len)
+ amt = len;
+
+ amt = bfd_get_section_contents (exec_bfd, s,
+ readbuf, offset - lma, amt);
+ return amt;
+ }
+ }
+ }
+
/* Indicate failure to find the requested memory block. */
return -1;
}
@@ -3923,6 +3959,12 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
}
static int
+tfile_has_all_memory (struct target_ops *ops)
+{
+ return 1;
+}
+
+static int
tfile_has_memory (struct target_ops *ops)
{
return 1;
@@ -3958,6 +4000,7 @@ init_tfile_ops (void)
/* core_stratum might seem more logical, but GDB doesn't like having
more than one core_stratum vector. */
tfile_ops.to_stratum = process_stratum;
+ tfile_ops.to_has_all_memory = tfile_has_all_memory;
tfile_ops.to_has_memory = tfile_has_memory;
tfile_ops.to_has_stack = tfile_has_stack;
tfile_ops.to_has_registers = tfile_has_registers;