Commit Graph

119 Commits

Author SHA1 Message Date
Sami Wagiaalla cbd7053759 Enable custom bcache hash function.
2010-08-25  Sami Wagiaalla  <swagiaal@redhat.com>

	* psymtab.c (add_psymbol_to_bcache): Remove 'static' from
	'static partial_symbol psymbol'.
	(psymbol_hash): New function.
	(psymbol_compare): New function.
	* bcache.c (hash_continue): New.
	(hash): Use hash_continue.
	* bcache.c: Add hash_function and compare_function
	pointers to bcache struct.
	(bcache_full): Use bcache->hash_function, and
	bcache->compare_function.
	(bcache_compare): New function.
	(bcache_xmalloc): Take hash_function and
	compare_function arguments and initialize the
	bcach's pointers.
	Updated comment.
	* objfiles.c (allocate_objfile): Updated.
	* symfile.c (reread_symbols): Updated.
	* python/py-type.c (typy_richcompare): Updated.
2010-08-31 17:26:08 +00:00
Tom Tromey 03f17ccfe1 gdb
2010-08-30  Andre Poenitz  <andre.poenitz@nokia.com>
	    Tom Tromey  <tromey@redhat.com>

	PR python/11792:
	* python/py-value.c (valpy_get_dynamic_type): New function.
	(value_object_getset): Add "dynamic_type".
	(valpy_get_type): Fail on error.
gdb/doc
	PR python/11792:
	* gdb.texinfo (Values From Inferior): Document dynamic_type.
gdb/testsuite
	PR python/11792:
	* gdb.python/py-value.exp (test_subscript_regression): Add
	dynamic_type test.
2010-08-30 20:28:31 +00:00
Jan Kratochvil e8fd65ef54 gdb/
* python/py-type.c (typy_richcompare): Initialize worklist.
2010-08-24 17:24:28 +00:00
Tom Tromey f9ffd4bb11 gdb
PR python/11145:
	* python/py-value.c: Include expression.h.
	(valpy_do_cast): New function.
	(valpy_cast): Use it.
	(valpy_dynamic_cast): New function.
	(valpy_reinterpret_cast): Likewise.
	(value_object_methods): Add dynamic_cast, reinterpret_cast.
gdb/doc
	PR python/11145:
	* gdb.texinfo (Values From Inferior): Document dynamic_cast and
	reinterpret_cast methods.
gdb/testsuite
	PR python/11145:
	* gdb.python/py-value.c (Base, Derived): New types.
	(base): New global.
	* gdb.python/py-value.exp (test_subscript_regression): Add
	dynamic_cast test.
2010-08-23 20:29:19 +00:00
Tom Tromey 96f73ba54f PR python/11391:
* python/py-value.c (valpy_nonzero): Don't throw error for other
	Value types.
2010-08-23 20:27:49 +00:00
Tom Tromey d839c8a4e8 gdb
PR python/10676:
	* python/py-type.c: Include bcache.h, vec.h.
	(struct type_equality_entry): New.
	(compare_strings): New function.
	(check_types_equal): Likewise.
	(check_types_worklist): Likewise.
	(typy_richcompare): Likewise.
	(type_object_type): Set tp_richcompare field.
gdb/testsuite
	PR python/10676:
	* gdb.python/py-type.exp (test_fields): Add tests for type
	equality.
2010-08-23 20:26:10 +00:00
Tom Tromey 05d0e1e74e PR python/10953:
* python/py-type.c (typy_fields): Call check_typedef.
	(typy_template_argument): Add TRY_CATCH.
2010-08-23 20:23:55 +00:00
Tom Tromey 702c271136 gdb
PR python/11915:
	* python/py-type.c (typy_array): New function.
	(type_object_methods): Add "array".
gdb/doc
	PR python/11915:
	* gdb.texinfo (Types In Python): Document array method.
gdb/testsuite
	PR python/11915:
	* gdb.python/py-type.exp (test_fields): Add tests for array.
2010-08-23 20:21:28 +00:00
Pedro Alves 4a5321319d * python/python.c: Include "serial.h".
(gdbpy_event_fds): Change type to `struct serial *' a array from
	int array.
	(gdbpy_run_events): Change parameters.  Use serial_readchar in
	place of read.
	(gdbpy_post_event): Use serial_write in place of write.
	(gdbpy_initialize_events): Use serial_pipe instead of pipe, and
	serial_async in place of add_file_handler.
2010-08-20 18:52:11 +00:00
Tom Tromey 4eb5405278 * python/python-internal.h (gdbpy_get_hook_function): Don't
declare.
2010-08-13 20:50:47 +00:00
Ken Werner 76d8b686dc gdb:
* python/python.c (gdbpy_solib_name): Remove the const qualifier of
the format strings to be compatible with Python 2.4.
2010-08-13 16:19:48 +00:00
Phil Muldoon ca5c20b6d3 2010-08-11 Tom Tromey <tromey@redhat.com>
Phil Muldoon  <pmuldoon@redhat.com>

	* python/python.c (gdbpy_run_events): New function.
	(gdbpy_post_event): Likewise.
	(gdbpy_initialize_events): Likewise.
	(_initialize_python): Call gdbpy_initialize_events.


2010-08-11  Tom Tromey  <tromey@redhat.com>
            Phil Muldoon <pmuldoon@redhat.com>

	* gdb.texinfo (Basic Python): Describe post_event API.

2010-08-11  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/python.exp (gdb_py_test_multiple): Add gdb.post_event
	tests.
2010-08-11 20:54:12 +00:00
Phil Muldoon cb2e07a6f0 2010-08-11 Phil Muldoon <pmuldoon@redhat.com>
Thiago Jung Bauermann  <bauerman@br.ibm.com>
	    Tom Tromey  <tromey@redhat.com>

	* python/python.c (gdbpy_solib_address):  New function.
	(gdbpy_decode_line): Likewise.

2010-08-11  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.texinfo (Basic Python): Describe solib_address and
          decode_line Python APIs

2010-08-11  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/python.c: New File.
	* gdb.python/python-sl.c: New File.
	* gdb.python/python.exp: Test solib_address and decode_line
	* functions.
2010-08-11 12:48:24 +00:00
Jan Kratochvil 5da1313be2 gdb/
* defs.h (make_cleanup_restore_uinteger, make_cleanup_restore_ui_file)
	(make_cleanup_restore_page_info)
	(set_batch_flag_and_make_cleanup_restore_page_info): New declarations.
	* gdbcmd.h (execute_command_to_string): New declaration.
	* python/python.c (struct restore_ui_file_closure, restore_ui_file)
	(make_cleanup_restore_ui_file): Move to utils.c
	(execute_gdb_command) <to_string>: Move ...
	* top.c (execute_command_to_string): ... here.  Call
	set_batch_flag_and_make_cleanup_restore_page_info.
	* utils.c (make_cleanup_restore_integer): New source file blank line.
	(make_cleanup_restore_uinteger): New.
	(struct restore_ui_file_closure, do_restore_ui_file)
	(make_cleanup_restore_ui_file): Move here from python/python.c.
	(init_page_info) <batch_flag>
	(do_restore_page_info_cleanup, make_cleanup_restore_page_info)
	(set_batch_flag_and_make_cleanup_restore_page_info): New.

gdb/testsuite/
	* gdb.python/python.exp (show height, set height 10)
	(verify pagination beforehand, verify pagination beforehand: q)
	(gdb.execute does not page, verify pagination afterwards)
	(verify pagination afterwards: q): New.

gdb/doc/
	* gdb.texinfo (Mode Options) <-batch>
	(Basic Python) <gdb.execute>: Describe setting width and height.
2010-08-07 15:00:39 +00:00
Tom Tromey 326fd672ca gdb
PR python/11060:
	* python/py-type.c (typy_legacy_template_argument): New function,
	extracted from typy_template_argument.
	(typy_template_argument): Use TYPE_TEMPLATE_ARGUMENT.  Return a
	value when needed.
gdb/testsuite
	PR python/11060:
	* gdb.python/py-type.c (Temargs): New template.
	(temvar): New variable.
	* gdb.python/py-type.exp (test_template): New proc.
2010-07-28 20:50:17 +00:00
Phil Muldoon 5374244e7a 2010-07-27 Phil Muldoon <pmuldoon@redhat.com>
* python/py-value.c (valpy_call): New Function.

2010-07-27  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-value.exp (test_inferior_function_call): New function.
	* gdb.python/py-value.c (func1): New function.
	(func2): Likewise.

2010-07-27  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.texinfo (Values From Inferior): Add value inferior function
	call description.
2010-07-27 12:40:42 +00:00
Tom Tromey f04e4012c7 * python/py-prettyprint.c (gdbpy_get_display_hint): Don't use
'hint' if it is NULL.
2010-07-09 20:29:56 +00:00
Joel Brobecker 7e6e39e562 Resync python-config.py with Python-2.7 version.
This is just a copy of the Python 2.7 version of python-config.py.
Tested with versions 2.5 and 2.6.  It's nearly identical to the
previous version, except it's written in a more pythonic way,
so it should be fine for 2.4 as well.

gdb/ChangeLog:

        * python/python-config.py: Resync with Python 2.7 version of this
        script.
2010-07-08 22:12:44 +00:00
Tom Tromey 11763c1856 * configure, config.in: Rebuild.
* configure.ac (HAVE_LIBPYTHON2_7): New define.
	* python/python-internal.h: Handle HAVE_LIBPYTHON2_7.
2010-07-06 19:03:12 +00:00
Pedro Alves 0fb4aa4bfc Static tracepoints support, and UST integration.
gdb/gdbserver/
	* configure.ac: Handle --with-ust.  substitute ustlibs and ustinc.
	* mem-break.c (uninsert_all_breakpoints)
	(reinsert_all_breakpoints): New.
	* mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints):
	* tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New.
	(gdb_agent_ust_loaded, helper_thread_id)
	(gdb_agent_helper_thread_id): New macros.
	(struct ipa_sym_addresses): Add addr_ust_loaded,
	addr_helper_thread_id, addr_cmd_buf.
	(symbol_list): Add ust_loaded, helper_thread_id, cmd_buf.
	(in_process_agent_loaded_ust): New.
	(write_e_ust_not_loaded): New.
	(maybe_write_ipa_ust_not_loaded): New.
	(struct collect_static_trace_data_action): New.
	(enum tracepoint_type) <static_tracepoint>: New.
	(struct tracepoint) <handle>: Mention static tracepoints.
	(struct static_tracepoint_ctx): New.
	(CMD_BUF_SIZE): New.
	(add_tracepoint_action): Handle static tracepoint actions.
	(unprobe_marker_at): New.
	(clear_installed_tracepoints): Handle static tracepoints.
	(cmd_qtdp): Handle static tracepoints.
	(probe_marker_at): New.
	(cmd_qtstart): Handle static tracepoints.
	(response_tracepoint): Handle static tracepoints.
	(cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New.
	(handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat.
	(get_context_regcache): Handle static tracepoints.
	(do_action_at_tracepoint): Handle static tracepoint actions.
	(traceframe_find_block_type): Handle static trace data blocks.
	(traceframe_read_sdata): New.
	(download_tracepoints): Download static tracepoint actions.
	[HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h.
	(GDB_PROBE_NAME): New.
	(ust_ops): New.
	(GET_UST_SYM): New.
	(USTF): New.
	(dlsym_ust): New.
	(ust_marker_to_static_tracepoint): New.
	(gdb_probe): New.
	(collect_ust_data_at_tracepoint): New.
	(gdb_ust_probe): New.
	(UNIX_PATH_MAX, SOCK_DIR): New.
	(gdb_ust_connect_sync_socket): New.
	(resume_thread, stop_thread): New.
	(run_inferior_command): New.
	(init_named_socket): New.
	(gdb_ust_socket_init): New.
	(cstr_to_hexstr): New.
	(next_st): New.
	(first_marker, next_marker): New.
	(response_ust_marker): New.
	(cmd_qtfstm, cmd_qtsstm): New.
	(unprobe_marker_at, probe_marker_at): New.
	(cmd_qtstmat, gdb_ust_thread): New.
	(gdb_ust_init): New.
	(initialize_tracepoint_ftlib): Call gdb_ust_init.
	* linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h
	(ST_REGENTRY): New.
	(x86_64_st_collect_regmap): New.
	(X86_64_NUM_ST_COLLECT_GREGS): New.
	(AMD64_RIP_REGNUM): New.
	(supply_static_tracepoint_registers): New.
	* linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h
	(ST_REGENTRY): New.
	(i386_st_collect_regmap): New.
	(i386_NUM_ST_COLLECT_GREGS): New.
	(supply_static_tracepoint_registers): New.
	* server.c (handle_query): Handle qXfer:statictrace:read.
	<qSupported>: Report support for StaticTracepoints, and
	qXfer:statictrace:read features.
	* server.h (traceframe_read_sdata)
	(supply_static_tracepoint_registers): Declare.
	* remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex)
	(unpack_varlen_hex): Include in IPA build.
	* Makefile.in (ustlibs, ustinc): New.
	(IPA_OBJS): Add remote-utils-ipa.o.
	($(IPA_LIB)): Link -ldl and -lpthread.
	(UST_CFLAGS): New.
	(IPAGENT_CFLAGS): Add UST_CFLAGS.
	* config.in, configure: Regenerate.

	gdb/
	* NEWS: Mention new support for static tracepoints.
	(New packets): Mention qTfSTM, qTsSTM, qTSTMat and
	qXfer:statictrace:read.
	(New features in the GDB remote stub, GDBserver): Mention static
	tracepoints support using an UST based backend.
	(New commands): Mention "info static-tracepoint-markers" and
	"strace".
	* breakpoint.c (is_marker_spec): New.
	(is_tracepoint): Handle static tracepoints.
	(validate_commands_for_breakpoint): Static tracepoints can't do
	while-stepping.
	(static_tracepoints_here): New.
	(bpstat_what): Handle static tracepoints.
	(print_one_breakpoint_location, allocate_bp_location, mention):
	Ditto.
	(create_breakpoint_sal): Ditto.
	(decode_static_tracepoint_spec): New.
	(create_breakpoint): Replace `hardwareflag', and `traceflag' with
	`type_wanted'.  Adjust.  Handle static tracepoint marker
	locations.
	(break_command_1): Adjust.
	(update_static_tracepoint): New.
	(update_breakpoint_locations): Handle static tracepoints.
	(breakpoint_re_set_one): Handle static tracepoint marker
	locations.
	(disable_command, enable_command): Handle static tracepoints.
	(trace_command, ftrace_command): Adjust.
	(strace_command): New.
	(create_tracepoint_from_upload): Adjust.
	(save_breakpoints): Handle static tracepoints.
	(_initialize_breakpoint): Install the "strace" command.
	* breakpoint.h (enum bptype): New bp_static_tracepoint type.
	(struct breakpoint): New fields static_trace_marker_id and
	static_trace_marker_id_idx.
	(breakpoints_here_p): Declare.
	(create_breakpoint): Adjust.
	(static_tracepoints_here): Declare.
	* remote.c (struct remote_state) <static_tracepoints>: New field.
	(PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New.
	(remote_static_tracepoint_marker_at): New.
	(remote_static_tracepoint_markers_by_strid): New.
	(remote_static_tracepoint_feature): New.
	(remote_disconnected_tracing_feature): Handle "StaticTracepoints".
	(remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA.
	(remote_supports_static_tracepoints): New.
	(remote_download_tracepoint): Download static tracepoints.
	(init_remote_ops): Install remote_static_tracepoint_marker_at and
	remote_static_tracepoint_markers_by_strid.
	(_initialize_remote): Install set|show remote static-tracepoints,
	and set|show remote read-sdata-object commands.
	* target.c (update_current_target): Inherit and default
	to_static_tracepoint_marker_at, and
	to_static_tracepoint_markers_by_strid.
	* target.h (static_tracepoint_marker): Forward declare.
	(enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA.
	(static_tracepoint_marker_p): New typedef.
	(DEF_VEC_P(static_tracepoint_marker_p)): New VEC type.
	(struct target_ops): New fields to_static_tracepoint_marker_at and
	to_static_tracepoint_markers_by_strid.
	(target_static_tracepoint_marker_at)
	(target_static_tracepoint_markers_by_strid): New.
	* tracepoint.c: Include source.h.
	(validate_actionline): Handle $_sdata.
	(struct collection_list): New field strace_data.
	(add_static_trace_data): New.
	(clear_collection_list): Clear strace_data.
	(stringify_collection_list): Account for a possible static trace
	data collection.
	(encode_actions_1): Encode an $_sdata collection.
	(parse_tracepoint_definition): Handle static tracepoints.
	(parse_static_tracepoint_marker_definition): New.
	(release_static_tracepoint_marker): New.
	(print_one_static_tracepoint_marker): New.
	(info_static_tracepoint_markers_command): New.
	(sdata_make_value): New.
	(_initialize_tracepoint): Create the $_sdata convenience variable.
	Add the "info static-tracepoint-markers" command.
	Mention $_sdata in the "collect" command's help output.
	* tracepoint.h (struct static_tracepoint_marker): New.
	(parse_static_tracepoint_marker_definition)
	(release_static_tracepoint_marker): Declare.
	* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
	* python/py-breakpoint.c (bppy_new): Adjust.

	doc/
	* gdb.texinfo (Convenience Variables): Document $_sdata.
	(Commands to Set Tracepoints): Describe static tracepoints.  Add
	`Listing Static Tracepoint Markers' menu entry.  Document
	"strace".
	(Tracepoint Action Lists): Document collecting $_sdata.
	(Listing Static Tracepoint Markers): New subsection.
	(Tracepoints support in gdbserver): Mention static tracepoints.
	(remote packets, enabling and disabling): Mention
	read-sdata-object.
	(General Query Packets) <qSupported>: Document qXfer:sdata:read
	and StaticTracepoint.
	Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets.
	Document qXfer:sdata:read.
	(Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 10:36:12 +00:00
Joel Brobecker aac63f0f26 Fix build failure with Python installed in non-system location.
The debugger fails to build when configure with --python-python=<path>
where <path> is a non-system location.  The reason is a warning made
fatal due to the definition of _XOPEN_SOURCE inside pyconfig.h.  This
is exactly the same problem as with _POSIX_C_SOURCE, handled in
python-internal.h as follow:

| /* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE
|    if it sees _GNU_SOURCE (which config.h will define).
|    pyconfig.h defines _POSIX_C_SOURCE to a different value than
|    /usr/include/features.h does causing compilation to fail.
|    To work around this, undef _POSIX_C_SOURCE before we include Python.h.  */
| #undef _POSIX_C_SOURCE

This patch fixes this problem the same way.

2010-06-30  Joel Brobecker  <brobecker@adacore.com>

        * python/python-internal.h (_XOPEN_SOURCE): Undefine before
        including Python.h.
2010-06-30 23:12:04 +00:00
Phil Muldoon 595939dea1 2010-06-28 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey  <tromey@redhat.com>
            Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* value.c (pack_unsigned_long): New function.
	(value_from_ulongest): New function.
	* value.h (value_from_ulongest): Declare.
	* python/python.c (_initialize_python): Call
	gdbpy_initialize_thread and gdbpy_initialize_inferior.
	* python/python-internal.h: Define thread_object.
	(gdbpy_inferiors, gdbpy_selected_thread)
	(frame_info_to_frame_object, create_thread_object)
	(find_thread_object, find_inferior_object)
	(gdbpy_initialize_thread, gdbpy_initialize_inferiors)
	(gdbpy_is_value_object, get_addr_from_python): Declare.
	* python/py-value.c (builtin_type_upylong): Define.
	(convert_value_from_python): Add logic for ulongest.
	(gdbpy_is_value_object): New function.
	* python/py-utils.c (get_addr_from_python): New function.
	* python/py-frame.c (frame_info_to_frame_object): Return a PyObject.
	(gdbpy_selected_frame): Use PyObject over frame_info.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-inferior and
	py-infthread.
	(SUBDIR_PYTHON_SRCS): Likewise.
	(py-inferior.o): New Rule.
	(py-infthread.o): New Rule.
	* python/py-inferior.c: New File.
	* python/py-infthread.c: New File.

2010-06-28  Phil Muldoon  <pmuldoon@redhat.com>
	    Tom Tromey  <tromey@redhat.com>
	    Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* gdb.texinfo (Inferiors In Python): New node.
	* gdb.texinfo (Threads In Python): New node.

2010-06-28  Phil Muldoon  <pmuldoon@redhat.com>
            Tom Tromey  <tromey@redhat.com>
            Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* gdb.python/py-inferior.c: New File.
	* gdb.python/py-infthread.c: New File.
	* gdb.python/py-inferior.exp: New File.
	* gdb.python/py-infthread.exp: New File.
2010-06-28 21:16:04 +00:00
Tom Tromey bc9f0842f1 gdb
PR python/10808:
	* python/python.c (execute_gdb_command): Add keywords.  Accept
	"to_string" argument.
	(struct restore_ui_file_closure): New.
	(restore_ui_file): New function.
	(make_cleanup_restore_ui_file): Likewise.
	(GdbMethods) <execute>: Update.
gdb/doc
	PR python/10808:
	* gdb.texinfo (Basic Python): Document new gdb.execute argument.
gdb/testsuite
	PR python/10808:
	* gdb.python/python.exp: Add new tests.
2010-06-25 18:15:18 +00:00
Joel Brobecker b14285f60e Add support for gdb.PYTHONDIR as $gdb_datadir/python.
Python scripts to be used by GDB can be stored in that directory,
and will be automatically found by the interpreter when importing them.
This patch also sets up <gdb_pythondir>/gdb as the directory where gdb
submodules can be stored.  For now, there is nothing there, but it can
now be added easily without further code changes.

gdb/ChangeLog:
2010-06-24  Joel Brobecker  <brobecker@adacore.com>

        * python/python.c (_initialize_python): Add new "constant"
        PYTHONDIR in gdb module.  Insert this path at the head of
        sys.path. Set gdb.__path__ to gdb.PYTHONDIR + '/gdb' and
        exec its __init__.py script if it exists in that directory.
2010-06-24 22:52:04 +00:00
Tom Tromey 0e03807e1c gdb
PR gdb/9977, PR exp/11636:
	* value.h (value_offset): Update.
	(struct lval_funcs) <check_validity>: New field.
	<copy_closure>: Make argument const.
	(value_computed_closure): Update.
	(value_contents_for_printing): Declare.
	(value_bits_valid): Likewise.
	(val_print): Likewise.
	(set_value_component_location): Update.
	(value_entirely_optimized_out): Declare.
	* value.c (value_offset): Argument now const.
	(require_not_optimized_out): New function.
	(value_contents_for_printing): New function.
	(value_contents_all): Call require_not_optimized_out.
	(value_contents): Likewise.
	(value_bits_valid): New function.
	(value_computed_closure): Argument now const.
	(set_value_component_location): Make 'whole' argument const.
	(value_entirely_optimized_out): New function.
	(value_bitsize): Argument now 'const'.
	(value_bitpos): Likewise.
	(value_type): Likewise.
	* valprint.h (val_print_array_elements): Update.
	* valprint.c (val_print): Add 'val' argument.  Use
	valprint_check_validity.
	(valprint_check_validity): New function.
	(value_check_printable): Use value_entirely_optimized_out.
	(common_val_print): Update.
	(value_print): Likewise.
	(val_print_array_elements): Add 'val' argument.
	* valops.c (value_fetch_lazy): Use value_contents_for_printing,
	value_bits_valid.  Reinit frame cache for lval_computed.
	* sh64-tdep.c (sh64_do_register): Update.
	* scm-valprint.c (scm_val_print): Add 'val' argument.
	* scm-lang.h (scm_val_print): Update.
	* python/python.h (apply_val_pretty_printer): Update.
	* python/py-prettyprint.c (apply_val_pretty_printer): Add 'val'
	argument.  Call set_value_component_location.
	* printcmd.c (print_scalar_formatted): Update.
	* p-valprint.c (pascal_val_print): Add 'val' argument.
	(pascal_object_print_value_fields): Likewise.
	(pascal_object_print_value): Likewise.
	(pascal_object_print_static_field): Update.
	* p-lang.h (pascal_val_print): Update.
	(pascal_object_print_value_fields): Update.
	* mt-tdep.c (mt_registers_info): Update.
	* mi/mi-main.c (get_register): Update.
	(mi_cmd_data_evaluate_expression): Use common_val_print.
	* m2-valprint.c (m2_print_array_contents): Add 'val' argument.
	(m2_print_unbounded_array): Likewise.
	(m2_val_print): Likewise.
	* m2-lang.h (m2_val_print): Update.
	* language.h (struct language_defn) <la_val_print>: Add 'val'
	argument.
	(LA_VAL_PRINT): Likewise.
	* language.c (unk_lang_val_print): Add 'val' argument.
	* jv-valprint.c (java_print_value_fields): Add 'val' argument.
	(java_val_print): Likewise.
	* jv-lang.h (java_val_print): Add 'val' argument.
	* infcmd.c (default_print_registers_info): Update.
	* f-valprint.c (f77_print_array_1): Add 'val' argument.
	(f77_print_array): Likewise.
	(f_val_print): Likewise.
	* f-lang.h (f_val_print): Add 'val' argument.
	* dwarf2loc.c (read_pieced_value): Use value_bitsize and
	value_bitpos.
	<DWARF_VALUE_OPTIMIZED_OUT>: Don't print warning.  Call
	set_value_optimized_out.
	(write_pieced_value): Use value_bitsize and value_bitpos.
	<default>: Don't exit loop.
	(check_pieced_value_validity): New function.
	(pieced_value_funcs): Reference check_pieced_value_validity,
	check_pieced_value_invalid.
	(copy_pieced_value_closure): Update.
	(check_pieced_value_bits): New function.
	(check_pieced_value_invalid): New function.
	* d-valprint.c (dynamic_array_type): Add 'val' argument.
	(d_val_print): Likewise.
	* d-lang.h (d_val_print): Update.
	* cp-valprint.c (cp_print_value_fields): Add 'val' argument.
	(cp_print_value_fields_rtti): Likewise.
	(cp_print_value): Likewise.
	(cp_print_static_field): Update.
	* c-valprint.c (c_val_print): Add 'val' argument.
	(c_value_print): Update.
	* c-lang.h (c_val_print): Update.
	(cp_print_value_fields): Likewise.
	(cp_print_value_fields_rtti): Likewise.
	* ada-valprint.c (struct ada_val_print_args): Remove.
	(val_print_packed_array_elements): Add 'val' argument.
	(ada_val_print): Likewise.  Rewrite.
	(ada_val_print_stub): Remove.
	(ada_val_print_array): Add 'val' argument.
	(ada_val_print_1): Likewise.
	(print_variant_part): Likewise.
	(ada_value_print): Update.
	(print_record): Add 'val' argument.
	(print_field_values): Likewise.
	* ada-lang.h (ada_val_print): Update.
gdb/testsuite
	PR gdb/9977, PR exp/11636::
	* gdb.dwarf2/pieces.exp (pieces_test_f3): Remove kfail.
	(pieces_test_f6): Update expected output.
2010-06-11 15:36:10 +00:00
Doug Evans 967cf47793 Add support for enabling/disabling individual pretty-printers.
* python/py-prettyprint.c (search_pp_list): Skip disabled printers.
	* python/python-internal.h (gdbpy_enabled_cst): Declare.
	* python/python.c (gdbpy_enabled_cst): Define.
	(_initialize_python): Initialize gdbpy_enabled_cst.
	* NEWS: Add entry.

	doc/
	* gdb.texinfo (Python API): New node `Disabling Pretty-Printers'.

	testsuite/
	* gdb.python/py-prettyprint.exp: Add new test for enabled and
	disabled printers.
	* gdb.python/py-prettyprint.py (disable_lookup_function): New function.
	(enable_lookup_function): New function.
2010-06-04 18:18:28 +00:00
Doug Evans 0c4a40633c Allow python to find its files if moved from original location.
* acinclude.m4 (GDB_AC_DEFINE_RELOCATABLE): New function.
	(GDB_AC_WITH_DIR): Call it.
	* configure.ac: Define WITH_PYTHON_PATH if we can find the
	python installation directory.
	* config.in: Regenerate.
	* configure: Regenerate.
	* defs.h (python_libdir): Declare.
	* main.c (python_libdir): Define.
	(captured_main): Initialize python_libdir.
	* python/python.c (_initialize_python): #ifdef WITH_PYTHON_PATH,
	call Py_SetProgramName to make sure python can find its libraries
	and modules.
2010-05-27 03:40:45 +00:00
Doug Evans ec685c5eca * configure.ac: Try to use python's distutils to fetch compilation
parameters.
	* configure: Regenerate.
	* python/python-config.py: New file.
2010-05-27 01:36:22 +00:00
Doug Evans 07ca107c2d Add python gdb.GdbError and gdb.string_to_argv.
* NEWS: Document them.
	* python/py-cmd.c (cmdpy_function): Don't print a traceback if
	the exception is gdb.GdbError.  Print a second traceback if there's
	an error computing the error message.
	(gdbpy_string_to_argv): New function.
	* python/py-utils.c (gdbpy_obj_to_string): New function.
	(gdbpy_exception_to_string): New function.
	* python/python-internal.h (gdbpy_string_to_argv): Declare.
	(gdbpy_obj_to_string, gdbpy_exception_to_string): Declare.
	(gdbpy_gdberror_exc): Declare.
	* python/python.c (gdbpy_gdberror_exc): New global.
	(_initialize_python): Initialize gdbpy_gdberror_exc and create
	gdb.GdbError.
	(GdbMethods): Add string_to_argv.

	doc/
	* gdb.texinfo (Exception Handling): Document gdb.GdbError.
	(Commands In Python): Document gdb.string_to_argv.

	testsuite/
	* gdb.python/py-cmd.exp: Add tests for gdb.GdbError and
	gdb.string_to_argv.
2010-05-25 15:27:17 +00:00
Doug Evans 0bf0f8c4cd * python.c (gdbpy_print_stack): Ensure output ends with a newline. 2010-05-19 23:32:24 +00:00
Doug Evans 3a1d4620d6 * python.c (source_python_script): Add comment.
(source_python_script_for_objfile): Remove unnecessary call to
	gdbpy_print_stack.
2010-05-19 21:57:24 +00:00
Michael Snyder d59b6f6c38 2010-05-17 Michael Snyder <msnyder@vmware.com>
* python/py-auto-load.c: White space.
	* python/py-block.c: White space.
	* python/py-breakpoint.c: White space.
	* python/py-cmd.c: White space.
	* python/py-function.c: White space.
	* python/py-lazy-string.c: White space.
	* python/py-objfile.c: White space.
	* python/py-param.c: White space.
	* python/py-prettyprint.c: White space.
	* python/py-progspace.c: White space.
	* python/py-symtab.c: White space.
	* python/python.c: White space.
	* python/py-type.c: White space.
	* python/py-utils.c: White space.
	* python/py-value.c: White space.
2010-05-17 21:23:25 +00:00
Phil Muldoon 88d4aea747 2010-05-14 Phil Muldoon <pmuldoon@redhat.com>
PR python/11482

	* python/py-value.c (valpy_hash): New function.
	(value_object_type): Register valpy_hash.

2010-05-14  Phil Muldoon  <pmuldoon@redhat.com>

 	PR python/11482

	* gdb.python/py-value.exp (test_value_hash): New function
2010-05-14 11:11:28 +00:00
Michael Snyder f92adf3ccc 2010-05-07 Michael Snyder <msnyder@vmware.com>
* python/python.c (execute_gdb_command): Remove unused variables.
	* python/py-block.c (gdbpy_block_for_pc): Remove unused variable.
	* python/py-breakpoint.c (gdbpy_breakpoint_created):
	Remove unused variable.
	* python/py-cmd.c (cmdpy_function): Remove unused variable.
	(cmdpy_completer): Remove unused variable.
	* python/py-frame.c (frapy_find_sal): Remove unused variable.
	* python/py-function.c (fnpy_call): Remove unused variable.
	* python/py-objfile.c (objfile_to_objfile_object):
	Remove unused variable.
	* python/py-param.c (parmpy_init): Remove unused variable.
	* python/py-prettyprint.c (apply_varobj_pretty_printer):
	Remove unused variable.
	(gdbpy_default_visualizer): Remove unused variable.
	* python/py-progspace.c (pspace_to_pspace_object):
	Remove unused variable.
	* python/py-symtab.c (symtab_and_line_to_sal_object):
	Remove unused variable.
	* python/py-type.c (typy_template_argument):
	Remove unused variable.
	* python/py-value.c (valpy_string): Remove unused variable.
	(convert_value_from_python): Remove unused variables.
2010-05-07 19:26:30 +00:00
Pierre Muller 3c0ee1a464 * python/py-param.c (parm_constants): Avoid ARI warning
by adding ARI comment.
	(parmpy_init): Likewise.
2010-04-30 16:22:42 +00:00
Phil Muldoon d7b32ed3ab 2010-04-29 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey  <tromey@redhat.com>
            Thiago Jung Bauermann  <bauerman@br.ibm.com>

       	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-parameter.
        (SUBDIR_PYTHON_SRCS): Likewise.
       	(py-parameter.o): New rule.
       	* python/py-parameter.c: New file.
        * python/python-internal.h (gdbpy_initialize_parameter)
        (gdbpy_parameter, gdbpy_parameter_value)
        (gdbpy_parse_command_name): Declare.
        * python/py-cmd.c (parse_command_name): Rename to
       	gdbpy_parse_command_name.
        (gdbpy_parse_command_name): Accept a starting list parameter and
       	use over cmdlist.
       	(cmdpy_init): Use gdbpy_parse_command_name.
        * python/python.c (parameter_to_python): Rename to
        gdbpy_parameter_to_python.  Accept enum var_types and value.
        (gdbpy_parameter): Use gdbpy_parameter_value.
        (_initialize_python): Call gdbpy_initialize_parameters.

2010-04-29  Phil Muldoon  <pmuldoon@redhat.com>

        * gdb.python/py-param.exp: New File.

2010-04-29  Phil Muldoon  <pmuldoon@redhat.com>
            Tom Tromey  <tromey@redhat.com>
            Thiago Jung Bauermann  <bauerman@br.ibm.com>

        * gdb.texinfo (Parameters In Python): New Node.
2010-04-29 15:45:57 +00:00
Joel Brobecker e78f4312c5 ARI warning fix.
* python/py-auto-load.c (source_section_scripts): Remove trailing
        new-line in i18n string.
2010-04-27 16:36:02 +00:00
Doug Evans 88a1906b0d * configure.ac (CONFIG_SRCS): Add py-auto-load.o even if not using
python.
	* configure: Regenerate.
	* main.c: #include "python/python.h".
	(captured_main): Defer loading auto-loaded scripts until after
	local_gdbinit has been sourced.
	* python/py-auto-load.c (gdbpy_global_auto_load): New global.
	(load_auto_scripts_for_objfile): New function.
	(auto_load_new_objfile): Call it.
	* python/python.h (gdbpy_global_auto_load): Declare.
	(load_auto_scripts_for_objfile): Declare.
2010-04-23 18:09:16 +00:00
Doug Evans 8a1ea21f7e Add support for auto-loading scripts from .debug_gdb_scripts section.
* NEWS: Add entry for .debug_gdb_scripts.
	* Makefile.in SUBDIR_PYTHON_OBS): Add py-auto-load.o.
	(SUBDIR_PYTHON_SRCS): Add py-auto-load.c.
	(py-auto-load.o): New rule.
	* cli/cli-cmds.c (find_and_open_script): Make externally visible.
	* cli/cli-cmds.h (find_and_open_script): Update prototype.
	* python/py-auto-load.c: New file.
	* python/python-internal.h: #include <stdio.h>.
	(set_python_list, show_python_list): Declare.
	(gdbpy_initialize_auto_load): Declare.
	(source_python_script_for_objfile): Declare.
	* python/python.c: Remove #include of observer.h.
	(gdbpy_auto_load): Moved to py-auto-load.c.
	(GDBPY_AUTO_FILENAME): Ditto.
	(gdbpy_new_objfile): Delete.
	(source_python_script_for_objfile): New function.
	(set_python_list, show_python_list): Make externally visible.
	(_initialize_python): Move "auto-load" command to py-auto-load.c
	and observer_attach_new_objfile to py-auto-load.c.

	doc/
	* gdb.texinfo (Python): Move Auto-loading section here ...
	(Python API): from here.
	(Auto-loading): Add docs for .debug_gdb_scripts auto-loaded scripts.
	(Maintenance Commands): Add docs for "maint print section-scripts".

	testsuite/
	* gdb.python/py-section-script.c: New file.
	* gdb.python/py-section-script.exp: New file.
	* gdb.python/py-section-script.py: New file.
2010-04-23 16:20:13 +00:00
Doug Evans fa33c3cd05 * NEWS: Add entry for python program space support.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-progspace.o.
	(SUBDIR_PYTHON_SRCS): Add py-progspace.c.
	(py-progspace.o): New rule.
	* python/py-prettyprint.c (find_pretty_printer_from_objfiles): New
	function.
	(find_pretty_printer_from_progspace): New function.
	(find_pretty_printer_from_gdb): New function.
	(find_pretty_printer): Rewrite.
	* python/py-progspace.c: New file.
	* python/python-internal.h (program_space): Add forward decl.
	(pspace_to_pspace_object, pspy_get_printers): Declare.
	(gdbpy_initialize_pspace): Declare.
	* python/python.c: #include "progspace.h".
	(gdbpy_get_current_progspace, gdbpy_progspaces): New functions.
	(_initialize_python): Call gdbpy_initialize_pspace.
	(GdbMethods): Add current_progspace, progspaces.

	doc/
	* gdb.texinfo (Python API): Add progspaces section.
	(Selecting Pretty-Printers): Progspace pretty-printers are
	searched too.
	(Progspaces In Python): New section.

	testsuite/
	* gdb.python/py-progspace.c: New file.
	* gdb.python/py-progspace.exp: New file.
2010-04-15 19:54:13 +00:00
Doug Evans 3f7b2faa4b Add -s option to source command.
* NEWS: Document new option.
	* cli/cli-cmds.c (find_and_open_script): Add function comment.
	Delete from_tty and cleanupp args.  Split filep arg into file and
	full_pathp.  New arg search_path.
	(source_script_from_stream): New function.
	(source_script_with_search): New function.
	(source_script): Rewrite.
	(source_command): Parse "-s" option.
	(init_cli_cmds): Add "-s" docs to source command help, and reformat.
	* python/python.c (source_python_script): Make file arg a const char *.
	Don't call fclose, leave for caller.
	* python/python.h (source_python_script): Update.

	testsuite/
	* gdb.base/source-test.gdb: New file.
	* gdb.base/source.exp: Add tests for "source -s".

	doc/
	* gdb.texinfo (Command Files): Add docs for new "source -s" option.
2010-04-15 17:45:57 +00:00
Phil Muldoon 044c0f87fe 2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
* python/py-block.c (gdbpy_block_for_pc): Use i8n to encompass
	error/warning messages.  Capitalize and use complete sentences.
	(blpy_block_syms_iternext): Likewise.
	* python/py-cmd.c (parse_command_name, cmdpy_init): Likewise.
	* python/py-frame.c (FRAPY_REQUIRE_VALID, frapy_block)
	(frame_info_to_frame_object, frapy_read_var)
	(gdbpy_frame_stop_reason_string): Likewise.
	* python/py-lazy-string.c (stpy_convert_to_value)
	(gdbpy_create_lazy_string_object): Likewise.
	* python/py-objfile.c (objfpy_set_printers): Likewise.
	* python/py-prettyprint.c (gdbpy_default_visualizer): Likewise.
	* python/python.c (parameter_to_python): Likewise.
	* python/py-type.c (typy_range, typy_target): Likewise.
	* python/py-value.c (valpy_cast, valpy_length, valpy_getitem)
	(valpy_richcompare, valpy_int, valpy_long, valpy_float): Likewise.
2010-04-14 13:18:55 +00:00
Phil Muldoon 79f283fe85 2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
PR python/11381

	* python/py-prettyprint.c (pretty_print_one_value): Test for
	Py_None.
	(print_string_repr): Test for Py_None.  Set flags accordingly.
	Return value depending on return type.
	(print_children): Take a value indicating whether data was printed
	before this function was called.  Alter output accordingly.
	(apply_val_pretty_printer): Capture return value from
	print_string_repr and pass to print_children.

2010-04-14  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-prettyprint.py (NoStringContainerPrinter): New printer.
	* gdb.python/py-prettyprint.c: Add justchildren struct, typedefs.
	* gdb.python/py-prettyprint.exp: New test for to_string returning None.
	* gdb.python/py-mi.exp: New test for to_string returning None.

2010-04-14  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.texinfo (Pretty Printing): Document behaviour when to_string
	returns None.
2010-04-14 12:02:46 +00:00
Phil Muldoon adc368187c 2010-04-09 Phil Muldoon <pmuldoon@redhat.com>
Thiago Jung Bauermann  <bauerman@br.ibm.com>
   	    Tom Tromey  <tromey@redhat.com>

	* breakpoint.c (condition_command): Simplify.  Move condition
	setting code to ...
	(set_breakpoint_condition): ... here.  New function.
	* breakpoint.h  (set_breakpoint_condition): Declare.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-breakpoint.
	(SUBDIR_PYTHON_SRCS): Likewise.
	(py-breakpoint.o): New rule.
	* python/py-breakpoint.c: New file.
	* python/python-internal.h (gdbpy_breakpoints)
	(gdbpy_initialize_breakpoints): Declare.
	(GDB_PY_SET_HANDLE_EXCEPTION) Define.


2010-04-09  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-breakpoint.exp: New File.
	* gdb.python/py-breakpoint.C: Ditto.

2010-04-09  Phil Muldoon  <pmuldoon@redhat.com>
	    Thiago Jung Bauermann  <bauerman@br.ibm.com>
   	    Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Breakpoints In Python): New Node.
2010-04-09 09:41:43 +00:00
Phil Muldoon f5f8b5baf4 2010-04-08 Phil Muldoon <pmuldoon@redhat.com>
* python/py-lazy-string.c (stpy_convert_to_value): Add i8n to error string.
2010-04-08 10:47:56 +00:00
Phil Muldoon fff5cc649e 2010-04-08 Phil Muldoon <pmuldoon@redhat.com>
PR python/11417

	* python/py-lazy-string.c (stpy_convert_to_value): Check for
          a NULL address.
	  (gdbpy_create_lazy_string_object): Allow strings with a NULL
          address and a zero length.

2010-04-08  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-value: Add null string variable.
	  (test_lazy_string): Test zero length, NULL address lazy
	  strings.
2010-04-08 10:28:42 +00:00
Doug Evans eb5cda8649 * python/python.c (source_python_script): Use ensure_python_env
to prepare environment for script.
2010-04-08 04:57:25 +00:00
Pierre Muller 9cb74f47a1 * python/python-internal.h: Include symtab.h. 2010-03-09 17:12:40 +00:00
Tom Tromey f870a310ee gdb
2010-03-05  Corinna Vinschen  <vinschen@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* utils.c (host_char_to_target): Add 'gdbarch' argument.
	(parse_escape): Likewise.
	* python/py-utils.c (unicode_to_target_string): Update.
	(unicode_to_target_python_string): Update.
	(target_string_to_unicode): Update.
	* printcmd.c (printf_command): Update.
	* p-exp.y (yylex): Update.
	* objc-exp.y (yylex): Update.
	* mi/mi-parse.c: Include charset.h.
	(mi_parse_escape): New function.
	(mi_parse_argv): Use it.
	* jv-exp.y (yylex): Update.
	* i386-cygwin-tdep.c (i386_cygwin_auto_wide_charset): New
	function.
	(i386_cygwin_init_abi): Call set_gdbarch_auto_wide_charset.
	* gdbarch.sh (auto_charset, auto_wide_charset): New.
	* gdbarch.c: Rebuild.
	* gdbarch.h: Rebuild.
	* defs.h (parse_escape): Update.
	* cli/cli-setshow.c: Include arch-utils.h.
	(do_setshow_command): Update.
	* cli/cli-cmds.c (echo_command): Update.
	* charset.h (target_charset, target_wide_charset): Update.
	* charset.c: Include arch-utils.h.
	(target_charset_name): Default to "auto".
	(target_wide_charset_name): Likewise.
	(show_target_charset_name): Handle "auto".
	(show_target_wide_charset_name): Likewise.
	(be_le_arch): New global.
	(set_be_le_names): Add 'gdbarch' argument.
	(validate): Likewise.  Don't call set_be_le_names.
	(set_charset_sfunc, set_host_charset_sfunc)
	(set_target_charset_sfunc, set_target_wide_charset_sfunc):
	Update.
	(target_charset): Add 'gdbarch' argument.
	(target_wide_charset): Likewise.  Remove 'byte_order' argument.
	(auto_target_charset_name): New global.
	(default_auto_charset, default_auto_wide_charset): New functions.
	(_initialize_charset): Set auto_target_charset_name.  Allow "auto"
	for target charsets.  Copy result of nl_langinfo.  Use GetACP if
	USE_WIN32API.
	* c-lang.c (charset_for_string_type): Add 'gdbarch' argument,
	remove 'byte_order' argument.  Update.
	(classify_type): Likewise.
	(c_emit_char): Update.
	(c_printchar): Update.
	(c_printstr): Update.
	(c_get_string): Update.
	(evaluate_subexp_c): Update.
	* arch-utils.h (default_auto_charset, default_auto_wide_charset):
	Declare.
	* python/python.c (gdbpy_target_charset): New function.
	(gdbpy_target_wide_charset): Likewise.
	(GdbMethods): Update.
	* NEWS: Update.
gdb/doc
	* gdb.texinfo (Basic Python): Document target_charset and
	target_wide_charset.
gdb/testsuite
	* gdb.python/py-prettyprint.py (pp_nullstr.to_string): Use
	gdb.target_charset.
	(pp_ns.to_string): Likewise.
2010-03-05 20:18:19 +00:00
Ulrich Weigand aab48ede09 * python/py-lazy-string.c (gdbpy_extract_lazy_string): Extract
address as UnsignedLongLong, not LongLong.
2010-03-05 19:28:13 +00:00