mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
8588b35692
Since commit
56bcdbea2b
("Let gdb.execute handle multi-line commands")
trying to use a command like gdb.execute("show commands") in Python
fails. GDB ends up trying to run the "commands" command.
The reason is that GDB gets confused with the special "commands"
command. In process_next_line, the lookup_cmd_1 function returns the
cmd_list_element representing the "commands" sub-command of "show".
Lower, we check the cmd_list_element to see if it matches various
control commands by name, including the "commands" command. This is
where we wrongfully conclude that the executed command must be
"commands", when in reality it was "show commands".
The fix proposed in this patch removes the comparisons by name, instead
comparing the cmd_list_element object by pointer with the objects
created at initialization time.
Tested on the buildbot, though on a single builder (Fedora-x86_64-m64).
gdb/ChangeLog:
PR python/23669
* breakpoint.c (commands_cmd_element): New.
(_initialize_breakpoint): Assign commands_cmd_element.
* breakpoint.h (commands_cmd_element): New.
* cli/cli-script.c (while_cmd_element, if_command,
define_cmd_element): New.
(command_name_equals): Remove.
(process_next_line): Compare commands by pointer, not by name.
(_initialize_cli_script): Assign the various cmd_list_element
variables.
* compile/compile.c (compile_cmd_element): New.
(_initialize_compile): Assign compile_cmd_element.
* compile/compile.h (compile_cmd_element): New.
* guile/guile.c (guile_cmd_element): New.
(install_gdb_commands): Assign guile_cmd_element.
* guile/guile.h (guile_cmd_element): New.
* python/python.c (python_cmd_element): New.
(_initialize_python): Assign python_cmd_element.
* python/python.h (python_cmd_element): New.
* tracepoint.c (while_stepping_cmd_element): New.
(_initialize_tracepoint): Assign while_stepping_cmd_element.
* tracepoint.h (while_stepping_cmd_element): New.
gdb/testsuite/ChangeLog:
PR python/23669
* gdb.python/python.exp: Test gdb.execute("show commands").
110 lines
3.6 KiB
C
110 lines
3.6 KiB
C
/* Header file for Compile and inject module.
|
|
|
|
Copyright (C) 2014-2018 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef GDB_COMPILE_H
|
|
#define GDB_COMPILE_H
|
|
|
|
struct ui_file;
|
|
struct gdbarch;
|
|
struct dwarf2_per_cu_data;
|
|
struct symbol;
|
|
struct dynamic_prop;
|
|
|
|
/* Public function that is called from compile_control case in the
|
|
expression command. GDB returns either a CMD, or a CMD_STRING, but
|
|
never both. */
|
|
|
|
extern void eval_compile_command (struct command_line *cmd,
|
|
const char *cmd_string,
|
|
enum compile_i_scope_types scope,
|
|
void *scope_data);
|
|
|
|
/* Compile a DWARF location expression to C, suitable for use by the
|
|
compiler.
|
|
|
|
STREAM is the stream where the code should be written.
|
|
|
|
RESULT_NAME is the name of a variable in the resulting C code. The
|
|
result of the expression will be assigned to this variable.
|
|
|
|
SYM is the symbol corresponding to this expression.
|
|
PC is the location at which the expression is being evaluated.
|
|
ARCH is the architecture to use.
|
|
|
|
REGISTERS_USED is an out parameter which is updated to note which
|
|
registers were needed by this expression.
|
|
|
|
ADDR_SIZE is the DWARF address size to use.
|
|
|
|
OPT_PTR and OP_END are the bounds of the DWARF expression.
|
|
|
|
PER_CU is the per-CU object used for looking up various other
|
|
things. */
|
|
|
|
extern void compile_dwarf_expr_to_c (string_file *stream,
|
|
const char *result_name,
|
|
struct symbol *sym,
|
|
CORE_ADDR pc,
|
|
struct gdbarch *arch,
|
|
unsigned char *registers_used,
|
|
unsigned int addr_size,
|
|
const gdb_byte *op_ptr,
|
|
const gdb_byte *op_end,
|
|
struct dwarf2_per_cu_data *per_cu);
|
|
|
|
/* Compile a DWARF bounds expression to C, suitable for use by the
|
|
compiler.
|
|
|
|
STREAM is the stream where the code should be written.
|
|
|
|
RESULT_NAME is the name of a variable in the resulting C code. The
|
|
result of the expression will be assigned to this variable.
|
|
|
|
PROP is the dynamic property for which we're compiling.
|
|
|
|
SYM is the symbol corresponding to this expression.
|
|
PC is the location at which the expression is being evaluated.
|
|
ARCH is the architecture to use.
|
|
|
|
REGISTERS_USED is an out parameter which is updated to note which
|
|
registers were needed by this expression.
|
|
|
|
ADDR_SIZE is the DWARF address size to use.
|
|
|
|
OPT_PTR and OP_END are the bounds of the DWARF expression.
|
|
|
|
PER_CU is the per-CU object used for looking up various other
|
|
things. */
|
|
|
|
extern void compile_dwarf_bounds_to_c (string_file *stream,
|
|
const char *result_name,
|
|
const struct dynamic_prop *prop,
|
|
struct symbol *sym, CORE_ADDR pc,
|
|
struct gdbarch *arch,
|
|
unsigned char *registers_used,
|
|
unsigned int addr_size,
|
|
const gdb_byte *op_ptr,
|
|
const gdb_byte *op_end,
|
|
struct dwarf2_per_cu_data *per_cu);
|
|
|
|
extern void compile_print_value (struct value *val, void *data_voidp);
|
|
|
|
/* Command element for the 'compile' command. */
|
|
extern cmd_list_element *compile_cmd_element;
|
|
|
|
#endif /* GDB_COMPILE_H */
|