gdbserver: handle all eval_result_type values in tracepoint.cc

It was pointed out[1] that after this commit:

  commit 3812b38d8d
  Date:   Thu Oct 20 11:14:33 2022 +0100

      gdbserver: allow agent expressions to fail with invalid memory access

Now that agent expressions might fail with the error
expr_eval_invalid_memory_access, we might overflow the
eval_result_names array in tracepoint.cc.  This is because the
eval_result_names array does not include a string for either
expr_eval_invalid_goto or expr_eval_invalid_memory_access.

I don't know if having expr_eval_invalid_goto missing is also a
problem, but it feels like eval_result_names should just include a
string for every possible error.

I could just add two more strings into the array, but I figure that a
more robust solution will be to move all of the error types, and their
associated strings, into a new ax-result-types.def file, and to then
include this file in both ax.h and tracepoint.cc in order to build
the enum eval_result_type and the eval_result_names string array.
Doing this means it is impossible to have a missing error string in
the future.

[1] https://inbox.sourceware.org/gdb-patches/01059f8a-0e59-55b5-f530-190c26df5ba3@palves.net/

Approved-By: Pedro Alves <pedro@palves.net>
This commit is contained in:
Andrew Burgess
2023-07-07 17:18:46 +01:00
parent 9f462ddef8
commit 424646edf4
3 changed files with 50 additions and 18 deletions

View File

@@ -33,16 +33,9 @@ struct traceframe;
enum eval_result_type
{
expr_eval_no_error,
expr_eval_empty_expression,
expr_eval_empty_stack,
expr_eval_stack_overflow,
expr_eval_stack_underflow,
expr_eval_unhandled_opcode,
expr_eval_unrecognized_opcode,
expr_eval_divide_by_zero,
expr_eval_invalid_goto,
expr_eval_invalid_memory_access
#define AX_RESULT_TYPE(ENUM,STR) ENUM,
#include "ax-result-types.def"
#undef AX_RESULT_TYPE
};
struct agent_expr