aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-10-20 11:14:33 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-04-03 14:46:32 +0100
commit3812b38d8de5804ad3eadd6c7a5d532402ddabab (patch)
tree24567807fc8f29e4b8eaab45db57fcf4e9f494d6 /gdbserver
parent0576dff20f052ab6d1ddba861235c7dc2584a145 (diff)
downloadgdb-3812b38d8de5804ad3eadd6c7a5d532402ddabab.zip
gdb-3812b38d8de5804ad3eadd6c7a5d532402ddabab.tar.gz
gdb-3812b38d8de5804ad3eadd6c7a5d532402ddabab.tar.bz2
gdbserver: allow agent expressions to fail with invalid memory access
This commit extends gdbserver to take account of a failed memory access from agent_mem_read, and to return a new eval_result_type expr_eval_invalid_memory_access. I have only updated the agent_mem_read calls related directly to reading memory, I have not updated any of the calls related to tracepoint data collection. This is just because I'm not familiar with that area of gdb/gdbserver, and I don't want to break anything, so leaving the existing behaviour untouched seems like the safest approach. I've then updated gdb.base/bp-cond-failure.exp to test evaluating the breakpoints on the target, and have also extended the test so that it checks for different sizes of memory access.
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/ax.cc12
-rw-r--r--gdbserver/ax.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 38ebfbb..fba5b4a 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -1112,22 +1112,26 @@ gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
break;
case gdb_agent_op_ref8:
- agent_mem_read (ctx, cnv.u8.bytes, (CORE_ADDR) top, 1);
+ if (agent_mem_read (ctx, cnv.u8.bytes, (CORE_ADDR) top, 1) != 0)
+ return expr_eval_invalid_memory_access;
top = cnv.u8.val;
break;
case gdb_agent_op_ref16:
- agent_mem_read (ctx, cnv.u16.bytes, (CORE_ADDR) top, 2);
+ if (agent_mem_read (ctx, cnv.u16.bytes, (CORE_ADDR) top, 2) != 0)
+ return expr_eval_invalid_memory_access;
top = cnv.u16.val;
break;
case gdb_agent_op_ref32:
- agent_mem_read (ctx, cnv.u32.bytes, (CORE_ADDR) top, 4);
+ if (agent_mem_read (ctx, cnv.u32.bytes, (CORE_ADDR) top, 4) != 0)
+ return expr_eval_invalid_memory_access;
top = cnv.u32.val;
break;
case gdb_agent_op_ref64:
- agent_mem_read (ctx, cnv.u64.bytes, (CORE_ADDR) top, 8);
+ if (agent_mem_read (ctx, cnv.u64.bytes, (CORE_ADDR) top, 8) != 0)
+ return expr_eval_invalid_memory_access;
top = cnv.u64.val;
break;
diff --git a/gdbserver/ax.h b/gdbserver/ax.h
index 8e64a7a..c98e36a 100644
--- a/gdbserver/ax.h
+++ b/gdbserver/ax.h
@@ -41,7 +41,8 @@ enum eval_result_type
expr_eval_unhandled_opcode,
expr_eval_unrecognized_opcode,
expr_eval_divide_by_zero,
- expr_eval_invalid_goto
+ expr_eval_invalid_goto,
+ expr_eval_invalid_memory_access
};
struct agent_expr