diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-10-20 10:58:02 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-04-03 14:46:32 +0100 |
commit | 0576dff20f052ab6d1ddba861235c7dc2584a145 (patch) | |
tree | bf13ca4bf84057252c0be0c31d44ca51eff6c41b /gdbserver/tracepoint.cc | |
parent | 2dc3457a454a35d0617dc1f9cc1db77468471f95 (diff) | |
download | gdb-0576dff20f052ab6d1ddba861235c7dc2584a145.zip gdb-0576dff20f052ab6d1ddba861235c7dc2584a145.tar.gz gdb-0576dff20f052ab6d1ddba861235c7dc2584a145.tar.bz2 |
gdbserver: allows agent_mem_read to return an error code
Currently the gdbserver function agent_mem_read ignores any errors
from calling read_inferior_memory. This means that if there is an
attempt to access invalid memory then this will appear to succeed.
In this patch I update agent_mem_read so that if read_inferior_memory
fails, agent_mem_read will return an error code.
However, none of the callers of agent_mem_read actually check the
return value, so this commit will have no effect on anything. In the
next commit I will update the users of agent_mem_read to check for the
error code.
I've also updated the header comments on agent_mem_read to better
reflect what the function does, and its possible return values.
Diffstat (limited to 'gdbserver/tracepoint.cc')
-rw-r--r-- | gdbserver/tracepoint.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 3f60989..125a384 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -4914,8 +4914,7 @@ condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx, return (value ? 1 : 0); } -/* Do memory copies for bytecodes. */ -/* Do the recording of memory blocks for actions and bytecodes. */ +/* See tracepoint.h. */ int agent_mem_read (struct eval_agent_expr_context *ctx, @@ -4927,10 +4926,7 @@ agent_mem_read (struct eval_agent_expr_context *ctx, /* If a 'to' buffer is specified, use it. */ if (to != NULL) - { - read_inferior_memory (from, to, len); - return 0; - } + return read_inferior_memory (from, to, len); /* Otherwise, create a new memory block in the trace buffer. */ while (remaining > 0) @@ -4951,7 +4947,8 @@ agent_mem_read (struct eval_agent_expr_context *ctx, memcpy (mspace, &blocklen, sizeof (blocklen)); mspace += sizeof (blocklen); /* Record the memory block proper. */ - read_inferior_memory (from, mspace, blocklen); + if (read_inferior_memory (from, mspace, blocklen) != 0) + return 1; trace_debug ("%d bytes recorded", blocklen); remaining -= blocklen; from += blocklen; |