old-cross-binutils/gdb/python/python.h
Doug Evans 5b2bf9471f Move .debug_gdb_script processing to auto-load.c.
Simplify handling of auto-loaded objfile scripts.

.debug_gdb_scripts was always intended to handle more than just python,
thus the rightful home for the code that processes it is not in py-foo.c.
This is just a cleanup to move the code to a better place.

This also simplifies the handling of the ${objfile}-${suffix} auto-loaded
scripts.  There's no need for each of the the handlers to do is-safe-to-load
checking, or call maybe_add_script.  Doing it in the caller removes the
duplication.

	* auto-load.h (script_language): New members name, auto_load_enabled.
	Add missing comments on struct members.
	(auto_load_objfile_script): Delete.
	* auto-load.c: #include "cli/cli-cmds.h".
	(auto_load_gdb_scripts_enabled): New function.
	(script_language_gdb): Update, add new members.
	(source_gdb_script_for_objfile): Simplify, auto-load safe-checking
	and call to maybe_add_script moved to caller.
	(auto_load_objfile_script_1): Auto-load safe-checking and
	call to maybe_add_script moved here.
	(auto_load_objfile_script): Make static.  Early exit if support for
	scripting language hasn't been compiled in, or auto-loading has been
	disabled.
	(source_section_scripts): Argument "source_name" renamed to
	"section_name".  All uses updated.  Replace uses of AUTO_SECTION_NAME
	with section_name.  Skip loading script if support for scripting
	language hasn't been compiled in, or auto-loading has been disabled.
	Call language->source_script_for_objfile instead of calling
	source_python_script_for_objfile directly.
	(load_auto_scripts_for_objfile): Update.
	* python/py-auto-load.c: Delete #include "cli/cli-cmds.h".
	(gdbpy_load_auto_script_for_objfile): Delete.
	(auto_load_python_scripts_enabled): New function.
	(script_language_python): Update, add new members.
	(gdbpy_script_language_defn): New function.
	* python/python.h (gdbpy_load_auto_scripts_for_objfile): Delete.
	(gdbpy_script_language_defn): Declare.

	* auto-load.c (AUTO_SECTION_NAME): Moved here and renamed from
	py-auto-load.c, GDBPY_AUTO_SECTION_NAME.
	(source_section_scripts): Moved here from py-auto-load.c.
	(auto_load_section_scripts): Ditto.
	* python/py-auto-load.c (GDBPY_AUTO_SECTION_NAME): Moved to
	auto-load.c, renamed AUTO_SECTION_NAME.
	(source_section_scripts, auto_load_section_scripts): Moved to
	auto-load.c.
2013-11-29 21:29:26 -08:00

124 lines
3.8 KiB
C

/* Python/gdb header for generic use in gdb
Copyright (C) 2008-2013 Free Software Foundation, Inc.
This file is part of GDB.
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_PYTHON_H
#define GDB_PYTHON_H
#include "value.h"
#include "mi/mi-cmds.h"
struct gdbpy_breakpoint_object;
/* The suffix of per-objfile scripts to auto-load.
E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
#define GDBPY_AUTO_FILE_NAME "-gdb.py"
/* Python frame-filter status return values. */
enum py_bt_status
{
/* Return when an error has occurred in processing frame filters,
or when printing the stack. */
PY_BT_ERROR = -1,
/* Return from internal routines to indicate that the function
succeeded. */
PY_BT_OK = 1,
/* Return when the frame filter process is complete, and all
operations have succeeded. */
PY_BT_COMPLETED = 2,
/* Return when the frame filter process is complete, but there
were no filter registered and enabled to process. */
PY_BT_NO_FILTERS = 3
};
/* Flags to pass to apply_frame_filter. */
enum frame_filter_flags
{
/* Set this flag if frame level is to be printed. */
PRINT_LEVEL = 1,
/* Set this flag if frame information is to be printed. */
PRINT_FRAME_INFO = 2,
/* Set this flag if frame arguments are to be printed. */
PRINT_ARGS = 4,
/* Set this flag if frame locals are to be printed. */
PRINT_LOCALS = 8,
};
/* A choice of the different frame argument printing strategies that
can occur in different cases of frame filter instantiation. */
typedef enum py_frame_args
{
/* Print no values for arguments when invoked from the MI. */
NO_VALUES = PRINT_NO_VALUES,
MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,
/* Print only simple values (what MI defines as "simple") for
arguments when invoked from the MI. */
MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES,
/* Print only scalar values for arguments when invoked from the
CLI. */
CLI_SCALAR_VALUES,
/* Print all values for arguments when invoked from the
CLI. */
CLI_ALL_VALUES
} py_frame_args;
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
void source_python_script (FILE *file, const char *filename);
int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options,
const struct language_defn *language);
enum py_bt_status apply_frame_filter (struct frame_info *frame, int flags,
enum py_frame_args args_type,
struct ui_out *out, int frame_low,
int frame_high);
void preserve_python_values (struct objfile *objfile, htab_t copied_types);
const struct script_language *gdbpy_script_language_defn (void);
int gdbpy_should_stop (struct gdbpy_breakpoint_object *bp_obj);
int gdbpy_breakpoint_has_py_cond (struct gdbpy_breakpoint_object *bp_obj);
void *start_type_printers (void);
char *apply_type_printers (void *, struct type *type);
void free_type_printers (void *arg);
#endif /* GDB_PYTHON_H */