Commit Graph

2394 Commits

Author SHA1 Message Date
Doug Evans b6577aab8a Add producer string to output of info source.
gdb/ChangeLog:

	* NEWS: "info source" command now display producer string if present.
	* source.c (source_info): Print producer string if present.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols) <info source>: Output now contains producer
	string if present.
2015-01-30 20:49:51 -08:00
Doug Evans 3a8b707add Add gdb.Objfile.username.
gdb/ChangeLog:

	* NEWS: Mention gdb.Objfile.username.
	* python/py-objfile.c (objfpy_get_username): New function.
	(objfile_getset): Add "username".

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document Objfile.username.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for objfile.username.
	Add test for objfile.filename, objfile.username after objfile
	has been unloaded.
2015-01-27 10:13:52 -08:00
Doug Evans 1b5493961a Improve docs of objfile filename method.
gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python) <Objfile.filename>: Improve docs.
	* guile.texi (Objfiles In Guile) <objfile-filename>: Improve docs.
2015-01-27 10:03:15 -08:00
Jan Kratochvil 253828f102 Sort threads for thread apply all
downstream Fedora request:
	Please make it easier to find the backtrace of the crashing thread
	https://bugzilla.redhat.com/show_bug.cgi?id=1024504

Currently after loading a core file GDB prints:

Core was generated by `./threadcrash1'.
Program terminated with signal SIGSEGV, Segmentation fault.
8       *(volatile int *)0=0;
(gdb) _

there is nowhere seen which of the threads had crashed.  In reality GDB always
numbers that thread as #1 and it is the current thread that time.  But after
dumping all the info into a file for later analysis it is no longer obvious.
'thread apply all bt' even puts the thread #1 to the _end_ of the output!!!

I find maybe as good enough and with no risk of UI change flamewar to just
sort the threads by their number.  Currently they are printed as they happen
in the internal GDB list which has no advantage.  Printing thread #1 as the
first one with assumed 'thread apply all bt' (after the core file is loaded)
should make the complaint resolved I guess.

On Thu, 15 Jan 2015 20:29:07 +0100, Doug Evans wrote:
No objection to sorting the list, but if thread #1 is the important one,
then a concern could be it'll have scrolled off the screen (such a
concern has been voiced in another thread in another context),
and if not lost (say it's in an emacs buffer) one would still have
to scroll back to see it.
So one *could* still want #1 to be last.
Do we want an option to choose the sort direction?

gdb/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* NEWS (Changes since GDB 7.9): Add 'thread apply all' option
	'-ascending'.
	* thread.c (tp_array_compar_ascending, tp_array_compar): New.
	(thread_apply_all_command): Parse CMD for tp_array_compar_ascending.
	Sort tp_array using tp_array_compar.
	(_initialize_thread): Extend thread_apply_all_command help.

gdb/doc/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Threads): Describe -ascending for thread apply all.
2015-01-22 21:04:53 +01:00
Eli Zaretskii bf555842fc Fix TUI-related documentation.
tui/tui-win.c (tui_scroll_left_command, tui_scroll_right_command):
Doc fix.
doc/gdb.texinfo (TUI Commands): Document the possible
values of NAME argument to 'winheight' command.  Explain the
effect of 'tabset' setting better.
2015-01-16 13:33:25 +02:00
Doug Evans 6a3ca06752 Temporarily revert symbol lookup cache.
clear_symtab_users calls breakpoint_re_set before
observer_notify_new_objfile(NULL), and thus symbol lookup
done during breakpoint_re_set will see a stale cache.

Presumably we just need to move the call to observer_notify_new_objfile(NULL)
to before breakpoint_re_set, but need to check for other such issues,
and 7.9 is scheduled to branch tomorrow.

Reverts commits:
b2fb95e006
400678a494
d98b9ccbcc
77087adf50

gdb/ChangeLog:

	* symtab.c (eq_symbol_entry): Use SYMBOL_SEARCH_NAME and
	symbol_matches_domain for symbol comparisons.

	* symtab.c (symbol_cache_mark_found): Improve function comment.
	Rename parameter objfile to objfile_context.
	(symbol_cache_mark_not_found): Improve function comment.

	Add symbol lookup cache.
	* NEWS: Document new options and commands.
	* symtab.c (symbol_cache_key): New static global.
	(DEFAULT_SYMBOL_CACHE_SIZE, MAX_SYMBOL_CACHE_SIZE): New macros.
	(SYMBOL_LOOKUP_FAILED): New macro.
	(symbol_cache_slot_state): New enum.
	(block_symbol_cache): New struct.
	(symbol_cache): New struct.
	(new_symbol_cache_size, symbol_cache_size): New static globals.
	(hash_symbol_entry, eq_symbol_entry): New functions.
	(symbol_cache_byte_size, resize_symbol_cache): New functions.
	(make_symbol_cache, free_symbol_cache): New functions.
	(get_symbol_cache, symbol_cache_cleanup): New function.
	(set_symbol_cache_size, set_symbol_cache_size_handler): New functions.
	(symbol_cache_lookup, symbol_cache_clear_slot): New function.
	(symbol_cache_mark_found, symbol_cache_mark_not_found): New functions.
	(symbol_cache_flush, symbol_cache_dump): New functions.
	(maintenance_print_symbol_cache): New function.
	(maintenance_flush_symbol_cache): New function.
	(symbol_cache_stats): New function.
	(maintenance_print_symbol_cache_statistics): New function.
	(symtab_new_objfile_observer): New function.
	(symtab_free_objfile_observer): New function.
	(lookup_static_symbol, lookup_global_symbol): Use symbol cache.
	(_initialize_symtab): Init symbol_cache_key.  New parameter
	maint symbol-cache-size.  New maint commands print symbol-cache,
	print symbol-cache-statistics, flush-symbol-cache.
	Install new_objfile, free_objfile observers.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols): Document new commands
	"maint print symbol-cache", "maint print symbol-cache-statistics",
	"maint flush-symbol-cache".  Document new option
	"maint set symbol-cache-size".
2015-01-11 15:16:26 -08:00
Doug Evans 439250fbac PR gdb/15830
gdb/ChangeLog:

	PR gdb/15830
	* NEWS: The "maint demangle" command is renamed as "demangle".
	* demangle.c: #include cli/cli-utils.h, language.h.
	(demangle_command): New function.
	(_initialize_demangle): Add new command "demangle".
	* maint.c (maintenance_demangle): Stub out.
	(_initialize_maint_cmds): Update help text for "maint demangle",
	and mark as deprecated.

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging C Plus Plus): Mention "demangle".
	(Symbols): Ditto.
	(Maintenance Commands): Delete docs for "maint demangle".

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Remove references to "maint demangle".
	* gdb.cp/demangle.exp: Update.  "maint demangle" -> "demangle".
	Add tests for explicitly specifying language to demangle.
	* gdb.dlang/demangle.exp: Ditto.
2015-01-11 14:06:34 -08:00
Doug Evans b2fb95e006 Add symbol lookup cache.
gdb/ChangeLog:

	Add symbol lookup cache.
	* NEWS: Document new options and commands.
	* symtab.c (symbol_cache_key): New static global.
	(DEFAULT_SYMBOL_CACHE_SIZE, MAX_SYMBOL_CACHE_SIZE): New macros.
	(SYMBOL_LOOKUP_FAILED): New macro.
	(symbol_cache_slot_state): New enum.
	(block_symbol_cache): New struct.
	(symbol_cache): New struct.
	(new_symbol_cache_size, symbol_cache_size): New static globals.
	(hash_symbol_entry, eq_symbol_entry): New functions.
	(symbol_cache_byte_size, resize_symbol_cache): New functions.
	(make_symbol_cache, free_symbol_cache): New functions.
	(get_symbol_cache, symbol_cache_cleanup): New function.
	(set_symbol_cache_size, set_symbol_cache_size_handler): New functions.
	(symbol_cache_lookup, symbol_cache_clear_slot): New function.
	(symbol_cache_mark_found, symbol_cache_mark_not_found): New functions.
	(symbol_cache_flush, symbol_cache_dump): New functions.
	(maintenance_print_symbol_cache): New function.
	(maintenance_flush_symbol_cache): New function.
	(symbol_cache_stats): New function.
	(maintenance_print_symbol_cache_statistics): New function.
	(symtab_new_objfile_observer): New function.
	(symtab_free_objfile_observer): New function.
	(lookup_static_symbol, lookup_global_symbol): Use symbol cache.
	(_initialize_symtab): Init symbol_cache_key.  New parameter
	maint symbol-cache-size.  New maint commands print symbol-cache,
	print symbol-cache-statistics, flush-symbol-cache.
	Install new_objfile, free_objfile observers.

doc/ChangeLog:

	* gdb.texinfo (Symbols): Document new commands
	"maint print symbol-cache", "maint print symbol-cache-statistics",
	"maint flush-symbol-cache".  Document new option
	"maint set symbol-cache-size".
2015-01-10 22:27:10 -08:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Joel Brobecker 6bf6fd090a Remove "add-shared-symbol-files", "dll-symbols" and "assf" commands doc.
This patch removes documentation from some commands whose support has
been recently removed.

gdb/ChangeLog:

        * NEWS: Document removal of "dll-symbols", "add-shared-symbol-files"
        and "assf" commands.

gdb/doc/ChangeLog:

        * gdb.texinfo (Files): Remove documentation of the
        "add-shared-symbol-files" and "assf" commands.
        (Cygwin Native): Remove documentation of the "dll-symbols"
        command.
2014-12-31 11:13:00 +04:00
Doug Evans cc485e6201 New parameter "debug symbol-lookup".
gdb/ChangeLog:

	New parameter "debug symbol-lookup".
	* NEWS: Mention it.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Add debug
	output.
	(cp_lookup_symbol_namespace, cp_lookup_symbol_nonlocal): Ditto.
	(cp_lookup_nested_symbol): Ditto.
	* language.c (language_lookup_primitive_type_by_name): Add debug
	output.
	* minsyms.c (lookup_minimal_symbol): Add debug output.
	* objfiles.c (objfile_debug_name): Moved here, and renamed ...
	* symfile-debug.c (debug_objfile_name): ... from here.  All callers
	updated.
	* objfiles.h (objfile_debug_name): Declare.
	* symtab.h (symbol_lookup_debug): Declare.
	* symtab.c (symbol_lookup_debug): New global.
	(lookup_language_this): Add debug output.
	(lookup_symbol_aux, lookup_symbol_in_block): Ditto.
	(lookup_symbol_in_objfile_symtabs, lookup_symbol_via_quick_fns): Ditto.
	(lookup_symbol_in_static_block, lookup_symbol_in_objfile): Ditto.
	(_initialize_symtab): Add new parameter "debug symbol-lookup".

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Document "debug symbol-lookup".
2014-12-17 00:17:27 -08:00
Tom Tromey bb2ec1b34e the "compile" command
This final patch adds the new "compile" command and subcommands, and
all the machinery needed to make it work.

A shared library supplied by gcc is used for all communications with
gcc.  Types and most aspects of symbols are provided directly by gdb
to the compiler using this library.

gdb provides some information about the user's code using plain text.
Macros are emitted this way, and DWARF location expressions (and
bounds for VLA) are compiled to C code.

This hybrid approach was taken because, on the one hand, it is better
to provide global declarations and such on demand; but on the other
hand, for local variables, translating DWARF location expressions to C
was much simpler than exporting a full compiler API to gdb -- the same
result, only easier to implement, understand, and debug.

In the ordinary mode, the user's expression is wrapped in a dummy
function.  After compilation, gdb inserts the resulting object code
into the inferior, then calls this function.

Access to local variables is provided by noting which registers are
used by location expressions, and passing a structure of register
values into the function.  Writes to registers are supported by
copying out these values after the function returns.

This approach was taken so that we could eventually implement other
more interesting features based on this same infrastructure; for
example, we're planning to investigate inferior-side breakpoint
conditions.

gdb/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* NEWS: Update.
	* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
	field.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_get_compile_instance,
	la_compute_program>: New fields.
	* language.c (unknown_language_defn, auto_language_defn)
	(local_language_defn): Update.
	* jv-lang.c (java_language_defn): Update.
	* go-lang.c (go_language_defn): Update.
	* f-lang.c (f_language_defn): Update.
	* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
	* dwarf2loc.c (dwarf2_compile_property_to_c)
	(locexpr_generate_c_location, loclist_generate_c_location): New
	functions.
	(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
	* defs.h (enum compile_i_scope_types): New.
	(enum command_control_type) <compile_control>: New constant.
	(struct command_line) <control_u>: New field.
	* d-lang.c (d_language_defn): Update.
	* compile/compile.c: New file.
	* compile/compile-c-support.c: New file.
	* compile/compile-c-symbols.c: New file.
	* compile/compile-c-types.c: New file.
	* compile/compile.h: New file.
	* compile/compile-internal.h: New file.
	* compile/compile-loc2c.c: New file.
	* compile/compile-object-load.c: New file.
	* compile/compile-object-load.h: New file.
	* compile/compile-object-run.c: New file.
	* compile/compile-object-run.h: New file.
	* cli/cli-script.c (multi_line_command_p, print_command_lines)
	(execute_control_command, process_next_line)
	(recurse_read_control_structure): Handle compile_control.
	* c-lang.h (c_get_compile_context, c_compute_program): Declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-lang.c (ada_language_defn): Update.
	* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
	New variables.
	(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
	(HFILES_NO_SRCDIR): Add compile.h.
	(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
	(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
	(compile.o, compile-c-types.o, compile-c-symbols.o)
	(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
	(compile-c-support.o): New targets.

gdb/doc/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Altering): Update.
	(Compiling and Injecting Code): New node.

gdb/testsuite/ChangeLog
2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* configure.ac: Add gdb.compile/.
	* configure: Regenerate.
	* gdb.compile/Makefile.in: New file.
	* gdb.compile/compile-ops.exp: New file.
	* gdb.compile/compile-ops.c: New file.
	* gdb.compile/compile-tls.c: New file.
	* gdb.compile/compile-tls.exp: New file.
	* gdb.compile/compile-constvar.S: New file.
	* gdb.compile/compile-constvar.c: New file.
	* gdb.compile/compile-mod.c: New file.
	* gdb.compile/compile-nodebug.c: New file.
	* gdb.compile/compile-setjmp-mod.c: New file.
	* gdb.compile/compile-setjmp.c: New file.
	* gdb.compile/compile-setjmp.exp: New file.
	* gdb.compile/compile-shlib.c: New file.
	* gdb.compile/compile.c: New file.
	* gdb.compile/compile.exp: New file.
	* lib/gdb.exp (skip_compile_feature_tests): New proc.
2014-12-12 22:28:44 +01:00
Doug Evans 6dddd6a574 New python function gdb.lookup_objfile.
gdb/ChangeLog:

	* NEWS: Mention gdb.lookup_objfile.
	* python/python.c (GdbMethods): Add lookup_objfile.
	* python/python-internal.h (gdbpy_lookup_objfile): Declare.
	* python/py-objfile.c: #include "symtab.h".
	(objfpy_build_id_ok, objfpy_build_id_matches): New functions.
	(objfpy_lookup_objfile_by_name): New function.
	(objfpy_lookup_objfile_by_build_id): New function.
	(gdbpy_lookup_objfile): New function.

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document gdb.lookup_objfile.

gdb/testsuite/ChangeLog:

	* lib/gdb-python.exp (get_python_valueof): New function.
	* gdb.python/py-objfile.exp: Add tests for gdb.lookup_objfile.
2014-12-12 09:48:13 -08:00
Andreas Arnez f5b95c01fb Add new GDB command "maint print user-registers"
This adds a command for listing the "user" registers.  So far GDB
offered no means of determining the set of user registers and omitted
them from all other register listings.

gdb/ChangeLog:

	* user-regs.c: Include "arch-utils.h", "command.h", and
	"cli/cli-cmds.h".
	(maintenance_print_user_registers): New.
	(_initialize_user_regs): Register new "maint print user-registers"
	subcommand.
	* NEWS: Mention new GDB command "maint print user-registers".

gdb/doc/ChangeLog:

	* gdb.texinfo: Document "maint print user-registers".
2014-12-12 17:11:22 +01:00
Doug Evans a0be3e44c7 New "owner" attribute for gdb.Objfile.
gdb/ChangeLog:

	* NEWS: Mention gdb.Objfile.owner.
	* python/py-objfile.c (objfpy_get_owner): New function.
	(objfile_getset): Add "owner".

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document Objfile.owner.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for objfile.owner.
2014-12-08 08:50:48 -08:00
Doug Evans 86e4ed3959 New python method gdb.Objfile.add_separate_debug_file.
gdb/ChangeLog:

	* NEWS: Mention gdb.Objfile.add_separate_debug_file.
	* python/py-objfile.c (objfpy_add_separate_debug_file): New function.
	(objfile_getset): Add "add_separate_debug_file".

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document
	Objfile.add_separate_debug_file.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for
	objfile.add_separate_debug_file.
2014-12-04 12:01:22 -08:00
Doug Evans 7c50a93137 New python attribute gdb.Objfile.build_id.
gdb/ChangeLog:

	* NEWS: Mention gdb.Objfile.build_id.
	* build-id.c (build_id_bfd_get): Make non-static.
	* build-id.h (build_id_bfd_get): Add declaration.
	* python/py-objfile.c: #include "build-id.h", "elf-bfd.h".
	(OBJFPY_REQUIRE_VALID): New macro.
	(objfpy_get_build_id): New function.
	(objfile_getset): Add "build_id".
	* utils.c (make_hex_string): New function.
	* utils.h (make_hex_string): Add declaration.

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document Objfile.build_id.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (get_build_id): New function.
	(build_id_debug_filename_get): Rewrite to use it.
	* gdb.python/py-objfile.exp: Add test for objfile.build_id.
2014-12-04 11:32:24 -08:00
Nick Bull 162078c893 New python events: inferior call, register/memory changed.
gdb/ChangeLog:

	* NEWS: Mention new Python events.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
	(py-infevents.o): New rule.
	* doc/observer.texi (inferior_call_pre, inferior_call_post)
	(memory_changed, register_changed): New observers.
	* infcall.c (call_function_by_hand): Notify observer before and
	after inferior call.
	* python/py-event.h (inferior_call_kind): New enum.
	(emit_inferior_call_event): New prototype.
	(emit_register_changed_event): New prototype.
	(emit_memory_changed_event): New prototype.
	* python/py-events.h (events_object): New registries
	inferior_call, memory_changed and register_changed.
	* python/py-evts.c (gdbpy_initialize_py_events): Add the
	inferior_call, memory_changed and register_changed registries.
	* python/py-infevents.c: New.
	* python/py-inferior.c (python_on_inferior_call_pre)
	(python_on_inferior_call_post, python_on_register_change)
	(python_on_memory_change): New functions.
	(gdbpy_initialize_inferior): Attach python handler to new
	observers.
	* python/py-infthread.c(gdbpy_create_ptid_object): New.
	(thpy_get_ptid) Use gdbpy_create_ptid_object.
	* python/python-internal.h:
	(gdbpy_create_ptid_object)
	(gdbpy_initialize_inferior_call_pre_event)
	(gdbpy_initialize_inferior_call_post_event)
	(gdbpy_initialize_register_changed_event)
	(gdbpy_initialize_memory_changed_event): New prototypes.
	* python/python.c (_initialize_python): Initialize new events.
	* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

	* python.texi (Events In Python): Document new events
	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
	and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

	* gdb.python/py-events.py (inferior_call_handler): New.
	(register_changed_handler, memory_changed_handler): New.
	(test_events.invoke): Register new handlers.
	* gdb.python/py-events.exp: Add tests for inferior call,
	memory_changed and register_changed events.
2014-12-02 11:15:29 -08:00
Doug Evans 71dd4b30a7 revert previous patch so that I can re-commit with correct author 2014-12-02 11:12:49 -08:00
Doug Evans dc6c87175b New python events: infcall, register/memory changed.
gdb/ChangeLog:

	* NEWS: Mention new Python events.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
	(py-infevents.o): New rule.
	* doc/observer.texi (inferior_call_pre, inferior_call_post)
	(memory_changed, register_changed): New observers.
	* infcall.c (call_function_by_hand): Notify observer before and
	after inferior call.
	* python/py-event.h (inferior_call_kind): New enum.
	(emit_inferior_call_event): New prototype.
	(emit_register_changed_event): New prototype.
	(emit_memory_changed_event): New prototype.
	* python/py-events.h (events_object): New registries
	inferior_call, memory_changed and register_changed.
	* python/py-evts.c (gdbpy_initialize_py_events): Add the
	inferior_call, memory_changed and register_changed registries.
	* python/py-infevents.c: New.
	* python/py-inferior.c (python_on_inferior_call_pre)
	(python_on_inferior_call_post, python_on_register_change)
	(python_on_memory_change): New functions.
	(gdbpy_initialize_inferior): Attach python handler to new
	observers.
	* python/py-infthread.c(gdbpy_create_ptid_object): New.
	(thpy_get_ptid) Use gdbpy_create_ptid_object.
	* python/python-internal.h:
	(gdbpy_create_ptid_object)
	(gdbpy_initialize_inferior_call_pre_event)
	(gdbpy_initialize_inferior_call_post_event)
	(gdbpy_initialize_register_changed_event)
	(gdbpy_initialize_memory_changed_event): New prototypes.
	* python/python.c (_initialize_python): Initialize new events.
	* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

	* python.texi (Events In Python): Document new events
	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
	and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

	* gdb.python/py-events.py (inferior_call_handler): New.
	(register_changed_handler, memory_changed_handler): New.
	(test_events.invoke): Register new handlers.
	* gdb.python/py-events.exp: Add tests for inferior call,
	memory_changed and register_changed events.
2014-12-02 10:59:08 -08:00
Jan Kratochvil f10c5b19e0 Add add-auto-load-scripts-directory.
There is already "add-auto-load-safe-path" which works
like "set auto-load safe-path" but in append mode.

There was missing an append equivalent for "set auto-load scripts-directory".

ABRT has directory /var/cache/abrt-di/ as an alternative one
to /usr/lib/debug/ . Therefore ABRT needs to use -iex parameters to add this
/var/cache/abrt-di/ directory as a first-class debuginfo directory.
Using absolute "set auto-load scripts-directory" would hard-code the path
possibly overriding local system directory additions; besides it would not be
nice anyway.

gdb/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Add add-auto-load-scripts-directory.
	* NEWS (Changes since GDB 7.8): Add add-auto-load-scripts-directory.
	* auto-load.c (add_auto_load_dir): New function.
	(_initialize_auto_load): Install it.

gdb/doc/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Add add-auto-load-scripts-directory.
	* gdb.texinfo (Auto-loading): Add add-auto-load-scripts-directory link.
	(objfile-gdbdotext file): Add add-auto-load-scripts-directory.
2014-11-30 20:25:48 +01:00
Jan Kratochvil 413b59aecb Fix add-auto-load-safe-path typo.
gdb/doc/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Auto-loading safe path): Fix add-auto-load-safe-path
	description typo.
2014-11-30 20:22:24 +01:00
Doug Evans 02be9a7100 Add ability to add attributes to gdb.Objfile and gdb.Progspace objects.
gdb/ChangeLog:

	* NEWS: Mention ability add attributes to gdb.Objfile and
	gdb.Progspace objects.
	* python/py-objfile.c (objfile_object): New member dict.
	(objfpy_dealloc): Py_XDECREF dict.
	(objfpy_initialize): Initialize dict.
	(objfile_getset): Add __dict__.
	(objfile_object_type): Set tp_dictoffset member.
	* python/py-progspace.c (progspace_object): New member dict.
	(pspy_dealloc): Py_XDECREF dict.
	(pspy_initialize): Initialize dict.
	(pspace_getset): Add __dict__.
	(pspace_object_type): Set tp_dictoffset member.

gdb/doc/ChangeLog:

	* python.texi (Progspaces In Python): Document ability to add
	random attributes to gdb.Progspace objects.
	(Objfiles In Python): Document ability to add random attributes to
	gdb.objfile objects.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for setting random attributes
	in objfiles.
	* gdb.python/py-progspace.exp: Add tests for setting random attributes
	in progspaces.
2014-10-30 17:05:17 -07:00
Pedro Alves e5f8a7cc2d stepi/nexti: skip signal handler if "handle nostop" signal arrives
I noticed that "si" behaves differently when a "handle nostop" signal
arrives while the step is in progress, depending on whether the
program was stopped at a breakpoint when "si" was entered.
Specifically, in case GDB needs to step off a breakpoint, the handler
is skipped and the program stops in the next "mainline" instruction.
Otherwise, the "si" stops in the first instruction of the signal
handler.

I was surprised the testsuite doesn't catch this difference.  Turns
out gdb.base/sigstep.exp covers a bunch of cases related to stepping
and signal handlers, but does not test stepi nor nexti, only
step/next/continue.

My first reaction was that stopping in the signal handler was the
correct thing to do, as it's where the next user-visible instruction
that is executed is.  I considered then "nexti" -- a signal handler
could be reasonably considered a subroutine call to step over, it'd
seem intuitive to me that "nexti" would skip it.

But then, I realized that signals that arrive while a plain/line
"step" is in progress _also_ have their handler skipped.  A user might
well be excused for being confused by this, given:

  (gdb) help step
  Step program until it reaches a different source line.

And the signal handler's sources will be in different source lines,
after all.

I think that having to explain that "stepi" steps into handlers, (and
that "nexti" wouldn't according to my reasoning above), while "step"
does not, is a sign of an awkward interface.

E.g., if a user truly is interested in stepping into signal handlers,
then it's odd that she has to either force the signal to "handle
stop", or recall to do "stepi" whenever such a signal might be
delivered.  For that use case, it'd seem nicer to me if "step" also
stepped into handlers.

This suggests to me that we either need a global "step-into-handlers"
setting, or perhaps better, make "handle pass/nopass stop/nostop
print/noprint" have have an additional axis - "handle
stepinto/nostepinto", so that the user could configure whether
handlers for specific signals should be stepped into.

In any case, I think it's simpler (and thus better) for all step
commands to behave the same.  This commit thus makes "si/ni" skip
handlers for "handle nostop" signals that arrive while the command was
already in progress, like step/next do.

To be clear, nothing changes if the program was stopped for a signal,
and the user enters a stepping command _then_ -- GDB still steps into
the handler.  The change concerns signals that don't cause a stop and
that arrive while the step is in progress.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-27  Pedro Alves  <palves@redhat.com>

	* infrun.c (handle_signal_stop): Also skip handlers when a random
	signal arrives while handling a "stepi" or a "nexti".  Set the
	thread's 'step_after_step_resume_breakpoint' flag.

gdb/doc/
2014-10-27  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Continuing and Stepping): Add cross reference to
	info on stepping and signal handlers.
	(Signals): Explain stepping and signal handlers.  Add context
	index entry, and cross references.

gdb/testsuite/
2014-10-27  Pedro Alves  <palves@redhat.com>

	* gdb.base/sigstep.c (dummy): New global.
	(main): Issue a couple writes to the new global.
	* gdb.base/sigstep.exp (get_next_pc, test_skip_handler): New
	procedures.
	(skip_over_handler): Use test_skip_handler.
	(top level): Call skip_over_handler for stepi and nexti too.
	(breakpoint_over_handler): Use test_skip_handler.
	(top level): Call breakpoint_over_handler for stepi and nexti too.
2014-10-27 20:26:12 +00:00
Simon Marchi fab3a15dfb Small fixes to the Python API doc
First:
"Breakpoint.delete" is missing parenthesis.

Second:
Someone on IRC asked, how come there is no disable() method in the
Breakpoint object.  It turns out you have to do "bp.enabled = False".
Since every normal person would probably search for "disable" in that page
if their intent is to disable a python breakpoint, I thought it would be
useful if the description contained "disable" so it would be easy to find.
The result might seem a bit silly and redundant, so I am open to
suggestions.

gdb/doc/ChangeLog:

	* python.texi (Breakpoints In Python): Add parenthesis after
	Breakpoint.delete.  Clarify Breakpoint.enabled description so
	that it	contains "disable".
2014-10-20 13:29:36 -04:00
Doug Evans 4ffbba72f3 New python event "clear_objfiles".
If one is watching new_objfile events in python, it helps to know
when the list of objfiles is cleared.  This patch adds a new
clear_objfiles event to support this.

This patch is all just cut-n-paste-n-tweak derived from
the new_objfiles event.

gdb/ChangeLog:

	* NEWS: Mention new event gdb.clear_objfiles.
	* python/py-event.h (emit_clear_objfiles_event): Clear
	* python/py-events.h (events_object): New member clear_objfiles.
	* python/py-evts.c (gdbpy_initialize_py_events): Add clear_objfiles
	event.
	* python/py-inferior.c (python_new_objfile): If objfile is NULL,
	emit clear_objfiles event.
	* python/py-newobjfileevent.c (create_clear_objfiles_event_object): New
	function.
	(emit_clear_objfiles_event): New function.
	(clear_objfiles): New event.
	* python/python-internal.h (gdbpy_initialize_clear_objfiles_event):
	Declare.
	* python/python.c (_initialize_python): Call
	gdbpy_initialize_clear_objfiles_event.

gdb/doc/ChangeLog:

	* python.texi (Events In Python): Document clear_objfiles event.

gdb/testsuite/ChangeLog:

	* gdb.python/py-events.exp: Update expected output for clear_objfiles
	event.
	* gdb.python/py-events.py: Add clear_objfiles event.
2014-10-17 11:12:17 -07:00
Doug Evans d096d8c11e Add gdb.Objfile.progspace attribute.
gdb/ChangeLog:

	* NEWS: Mention new gdb.Objfile.progspace attribute.
	* python/py-objfile.c (objfpy_get_progspace): New function.
	(objfile_getset): New entry for "progspace".

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document new progspace attribute.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Test progspace attribute.
2014-10-17 10:57:26 -07:00
Pedro Alves 32a8097ba5 Delete Tru64 support
This commit does most of the mechanical removal.  IOW, the easy part.

procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h.  Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.

Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them.  That can always be
done on a separate pass, preferably by someone who can test on alpha.

A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better.  We can revisit those when we next need to touch that
code.

I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.

Built and tested on x86_64 Fedora 20, with --enable-targets=all.

Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:

 checking for default auto-load directory... $debugdir:$datadir/auto-load
 checking for default auto-load safe-path... $debugdir:$datadir/auto-load
 *** Configuration alpha-unknown-osf3 is obsolete.
 *** Support has been REMOVED.
 make[1]: *** [configure-gdb] Error 1
 make[1]: Leaving directory `build-osf'
 make: *** [all] Error 2

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
	(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
	(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
	solib-osf.c.
	* NEWS: Mention that support for alpha*-*-osf* has been removed.
	* ada-lang.h [__alpha__ && __osf__]
	(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
	* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
	* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
	GDB_OSABI_OSF1.
	* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
	files.
	* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
	(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
	* configure: Regenerate.
	* configure.ac: Remove references to osf.
	* configure.host: Handle alpha*-*-osf* in the obsolete hosts
	section.  Remove all other references to osf.
	* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
	Remove all other references to osf.
	* dec-thread.c: Delete file.
	* defs.h (GDB_OSABI_OSF1): Delete.
	* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
	defined.
	* osabi.c (gdb_osabi_names): Delete "OSF/1".
	* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
	Delete code.
	(unconditionally_kill_inferior)
	[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
	* solib-osf.c: Delete file.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* gdb.base/callfuncs.exp: emove references to osf.
	* gdb.base/sigall.exp: Likewise.
	* gdb.gdb/selftest.exp: Likewise.
	* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
	* gdb.mi/non-stop.c: Likewise.
	* gdb.mi/pthreads.c: Likewise.
	* gdb.reverse/sigall-precsave.exp: Likewise.
	* gdb.reverse/sigall-reverse.exp: Likewise.
	* gdb.threads/pthreads.c: Likewise.
	* gdb.threads/pthreads.exp: Likewise.

gdb/doc/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
	(SVR4 Process Information): Delete mention of OSF/1.
2014-10-17 11:18:59 +01:00
Simon Marchi 2ddf430110 Exit code of exited inferiors in -list-thread-groups
Don't reset the exit code at inferior exit and print it in
-list-thread-groups.

gdb/ChangeLog:

	* NEWS: Announce new exit-code field in -list-thread-groups
	output.
	* inferior.c (exit_inferior_1): Don't clear exit code.
	(inferior_appeared): Clear exit code.
	* mi/mi-main.c (print_one_inferior): Add printing of the exit
	code.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-exit-code.exp: New file.
	* gdb.mi/mi-exit-code.c: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Miscellaneous gdb/mi Commands): Document new
	exit-code field in -list-thread-groups output.
2014-10-01 10:20:49 -04:00
Jan-Benedict Glaw 342cc09114 2014-09-22 Jan-Benedict Glaw <jbglaw@lug-owl.de>
* gdb.texinfo (Set Breaks): Add missing "@end table".
2014-09-22 13:02:10 +02:00
Pedro Alves a25a5a45ef Fix "breakpoint always-inserted off"; remove "breakpoint always-inserted auto"
By default, GDB removes all breakpoints from the target when the
target stops and the prompt is given back to the user.  This is useful
in case GDB crashes while the user is interacting, as otherwise,
there's a higher chance breakpoints would be left planted on the
target.

But, as long as any thread is running free, we need to make sure to
keep breakpoints inserted, lest a thread misses a breakpoint.  With
that in mind, in preparation for non-stop mode, we added a "breakpoint
always-inserted on" mode.  This traded off the extra crash protection
for never having threads miss breakpoints, and in addition is more
efficient if there's a ton of breakpoints to remove/insert at each
user command (e.g., at each "step").

When we added non-stop mode, and for a period, we required users to
manually set "always-inserted on" when they enabled non-stop mode, as
otherwise GDB removes all breakpoints from the target as soon as any
thread stops, which means the other threads still running will miss
breakpoints.  The test added by this patch exercises this.

That soon revealed a nuisance, and so later we added an extra
"breakpoint always-inserted auto" mode, that made GDB behave like
"always-inserted on" when non-stop was enabled, and "always-inserted
off" when non-stop was disabled.  "auto" was made the default at the
same time.

In hindsight, this "auto" setting was unnecessary, and not the ideal
solution.  Non-stop mode does depends on breakpoints always-inserted
mode, but only as long as any thread is running.  If no thread is
running, no breakpoint can be missed.  The same is true for all-stop
too.  E.g., if, in all-stop mode, and the user does:

 (gdb) c&
 (gdb) b foo

That breakpoint at "foo" should be inserted immediately, but it
currently isn't -- currently it'll end up inserted only if the target
happens to trip on some event, and is re-resumed, e.g., an internal
breakpoint triggers that doesn't cause a user-visible stop, and so we
end up in keep_going calling insert_breakpoints.  The test added by
this patch also covers this.

IOW, no matter whether in non-stop or all-stop, if the target fully
stops, we can remove breakpoints.  And no matter whether in all-stop
or non-stop, if any thread is running in the target, then we need
breakpoints to be immediately inserted.  And then, if the target has
global breakpoints, we need to keep breakpoints even when the target
is stopped.

So with that in mind, and aiming at reducing all-stop vs non-stop
differences for all-stop-on-stop-of-non-stop, this patch fixes
"breakpoint always-inserted off" to not remove breakpoints from the
target until it fully stops, and then removes the "auto" setting as
unnecessary.  I propose removing it straight away rather than keeping
it as an alias, unless someone complains they have scripts that need
it and that can't adjust.

Tested on x86_64 Fedora 20.

gdb/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention merge of "breakpoint always-inserted" modes "off"
	and "auto" merged.
	* breakpoint.c (enum ugll_insert_mode): New enum.
	(always_inserted_mode): Now a plain boolean.
	(show_always_inserted_mode): No longer handle AUTO_BOOLEAN_AUTO.
	(breakpoints_always_inserted_mode): Delete.
	(breakpoints_should_be_inserted_now): New function.
	(insert_breakpoints): Pass UGLL_INSERT to
	update_global_location_list instead of calling
	insert_breakpoint_locations manually.
	(create_solib_event_breakpoint_1): New, factored out from ...
	(create_solib_event_breakpoint): ... this.
	(create_and_insert_solib_event_breakpoint): Use
	create_solib_event_breakpoint_1 instead of calling
	insert_breakpoint_locations manually.
	(update_global_location_list): Change parameter type from boolean
	to enum ugll_insert_mode.  All callers adjusted.  Adjust to use
	breakpoints_should_be_inserted_now and handle UGLL_INSERT.
	(update_global_location_list_nothrow): Change parameter type from
	boolean to enum ugll_insert_mode.
	(_initialize_breakpoint): "breakpoint always-inserted" option is
	now a boolean command.  Update help text.
	* breakpoint.h (breakpoints_always_inserted_mode): Delete declaration.
	(breakpoints_should_be_inserted_now): New declaration.
	* infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>:
	Remove breakpoints_always_inserted_mode check.
	(normal_stop): Adjust to use breakpoints_should_be_inserted_now.
	* remote.c (remote_start_remote): Likewise.

gdb/doc/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Set Breaks): Document that "set breakpoint
	always-inserted off" is the default mode now.  Delete
	documentation of "set breakpoint always-inserted auto".

gdb/testsuite/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.threads/break-while-running.exp: New file.
	* gdb.threads/break-while-running.c: New file.
2014-09-22 10:07:04 +01:00
Doug Evans 2b4fd423cf New "producer" attribute of python gdb.Symtab.
gdb/ChangeLog:

	* NEWS: Mention new "producer" attribute of gdb.Symtab.
	* python/py-symtab.c (stpy_get_producer): New function.
	(symtab_object_getset): Add "producer" attribute.

gdb/doc/ChangeLog:

	* python.texi (Symbol Tables In Python): Document "producer"
	attribute of gdb.Symtab objects.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/symtab-producer.exp: New file.
2014-09-18 10:09:12 -07:00
Pedro Alves deb8ff2b7a Remove documention of dead "target vxworks"
"target vxworks" and friends have been removed 10 years ago already:

  commit e84ecc995d
  Author:     Andrew Cagney <cagney@redhat.com>
  AuthorDate: Sat Nov 13 23:10:02 2004 +0000

     2004-11-13  Andrew Cagney  <cagney@gnu.org>

         * configure.tgt: Delete i[34567]86-*-vxworks*, m68*-netx-*,
         m68*-*-vxworks*, mips*-*-vxworks*, powerpc-*-vxworks*, and
         sparc-*-vxworks*.
         * NEWS: Mention that vxworks was deleted.
     (...)
         * remote-vxmips.c, remote-vx.c: Delete.
         * remote-vx68.c: Delete.
     (...)

This removes related leftover cruft from the manual.

gdb/doc/
2014-09-16  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Starting) <run command>: Don't mention VxWorks.
	(Embedded OS): Remove VxWorks menu entry.
	(VxWorks): Remove node.
2014-09-16 16:38:12 +01:00
Doug Evans 81219e5358 New command queue-signal.
If I want to change the signalled state of multiple threads
it's a bit cumbersome to do with the "signal" command.
What you really want is a way to set the signal state of the
desired threads and then just do "continue".

This patch adds a new command, queue-signal, to accomplish this.
Basically "signal N" == "queue-signal N" + "continue".
That's not precisely true in that "signal" can be used to inject
any signal, including signals set to "nopass"; whereas "queue-signal"
just queues the signal as if the thread stopped because of it.
"nopass" handling is done when the thread is resumed which
"queue-signal" doesn't do.

One could add extra complexity to allow queue-signal to be used to
deliver "nopass" signals like the "signal" command.  I have no current
need for it so in the interests of incremental complexity, I have
left such support out and just have the code flag an error if one
tries to queue a nopass signal.

gdb/ChangeLog:

	* NEWS: Mention new "queue-signal" command.
	* infcmd.c (queue_signal_command): New function.
	(_initialize_infcmd): Add new queue-signal command.

gdb/doc/ChangeLog:

	* gdb.texinfo (Signaling): Document new queue-signal command.

gdb/testsuite/ChangeLog:

	* gdb.threads/queue-signal.c: New file.
	* gdb.threads/queue-signal.exp: New file.
2014-09-13 21:44:00 -07:00
Doug Evans faa42425cb PR 15276: Add $_caller_is, $_caller_matches, $_any_caller_is, $_any_caller_matches
gdb/ChangeLog:

	PR 15276
	* NEWS: Mention $_caller_is, $_caller_matches, $_any_caller_is,
	$_any_caller_matches.
	* data-directory/Makefile.in (PYTHON_FILE_LIST): Add caller_is.py.
	* python/lib/gdb/function/caller_is.py: New file.

gdb/testsuite/ChangeLog:

	PR 15276
	* gdb.python/py-caller-is.c: New file.
	* gdb.python/py-caller-is.exp: New file.

gdb/doc/ChangeLog:

	PR 15276
	* gdb.texinfo (Convenience Funs): Document $_caller_is,
	$_caller_matches, $_any_caller_is, $_any_caller_matches.
2014-09-06 09:15:44 -07:00
Justin Lebar 1a6a384be1 Improve Type.template_argument docs in Python API.
gdb/doc/ChangeLog:

	* python.texi (Types In Python): Type.template_argument(n) returns a
	gdb.Value or a gdb.Type and throws an exception if n is out of
	range.
2014-09-03 16:40:22 -07:00
Sasha Smundak 5f3b99cfed Add support for reading frame registers to Python API.
The ability to read registers is needed to use Frame Filter API to
display the frames created by JIT compilers.

gdb/ChangeLog:

2014-08-29  Sasha Smundak  <asmundak@google.com>

	* python/py-frame.c (frapy_read_register): New function.

gdb/doc/ChangeLog:

2014-08-26  Sasha Smundak  <asmundak@google.com>

	* python.texi (Frames in Python): Add read_register description.

gdb/testsuite/ChangeLog:

2014-08-26  Sasha Smundak  <asmundak@google.com>

	* gdb.python/py-frame.exp: Test Frame.read_register.
2014-09-03 16:34:47 -07:00
Tom Tromey 3cecbbbef1 make "set debug target" take effect immediately
Right now, "set debug target" acts a bit strangely.

Most target APIs only notice that it has changed when the target stack
is changed in some way.  This is because many methods implement the
setting using the special debug target.  However, a few spots do
change their behavior immediately -- any place explicitly checking
"targetdebug".

Some of this peculiar behavior is documented.  However, I think that
it just isn't very useful for it to work this way.  So, this patch
changes "set debug target" to take effect immediately in all cases.
This is done by simply calling update_current_target when the setting
is changed.

This required one small change in the test suite.  Here a test was
expecting the current behavior.

Built and regtested on x86-64 Fedora 20.

2014-08-04  Tom Tromey  <tromey@redhat.com>

	* target.c (set_targetdebug): New function.
	(initialize_targets): Pass set_targetdebug when creating "set
	debug target".

2014-08-04  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Debugging Output): Update for change to "set debug
	target".

2014-08-04  Tom Tromey  <tromey@redhat.com>

	* gdb.base/sss-bp-on-user-bp-2.exp: Expect output from "set debug
	target 0".
2014-08-04 08:07:53 -06:00
Masaki Muranaka 90debf20f4 [gdb/doc] Add target triplet to man files
After applying hash 43662968, gdb.1 and other man pages are not added
target triplet even if we configure with --target=.

It causes conflicts on some distributions.
And uninstall rules requires $(transform) variable.

gdb/doc/ChangeLog:

	* Makefile.in (transform): New variable.
	(install-man1, install-man5): Apply $(transform) to man file names.

Tested by installing both native and cross debugger.
2014-08-01 08:04:07 -07:00
Doug Evans ee7333ae06 PR guile/17177
* guile/lib/gdb.scm (pretty-printers): Export.
	(set-pretty-printers!): Export.
	* guile/lib/gdb/printing.scm (gdb module): Update.
	(prepend-pretty-printer!, append-pretty-printer!): Update.
	* guile/scm-pretty-print.c (pretty_printer_list_name): Delete.
	(pretty_printer_list_var): Delete.
	(pretty_printer_list): New static global.
	(gdbscm_pretty_printers): New function.
	(gdbscm_set_pretty_printers_x): New function.
	(ppscm_find_pretty_printer_from_gdb): Update.
	(pretty_printer_functions): Add pretty-printers, set-pretty-printers!.
	(gdbscm_initialize_pretty_printers): Update.

	doc/
	* guile.texi (Guile Pretty Printing API): Fix typo.
	Document set-pretty-printers!, pretty-printers.
	(Selecting Guile Pretty-Printers): Update.
	Mention program-space based pretty-printers.
2014-07-26 14:58:58 -07:00
Pedro Alves 705096250d Always pass signals to the right thread
Currently, GDB can pass a signal to the wrong thread in several
different but related scenarios.

E.g., if thread 1 stops for signal SIGFOO, the user switches to thread
2, and then issues "continue", SIGFOO is actually delivered to thread
2, not thread 1.  This obviously messes up programs that use
pthread_kill to send signals to specific threads.

This has been a known issue for a long while.  Back in 2008 when I
made stop_signal be per-thread (2020b7ab), I kept the behavior -- see
code in 'proceed' being removed -- wanting to come back to it later.
The time has finally come now.

The patch fixes this -- on resumption, intercepted signals are always
delivered to the thread that had intercepted them.

Another example: if thread 1 stops for a breakpoint, the user switches
to thread 2, and then issues "signal SIGFOO", SIGFOO is actually
delivered to thread 1, not thread 2, because 'proceed' first switches
to thread 1 to step over its breakpoint...  If the user deletes the
breakpoint before issuing "signal FOO", then the signal is delivered
to thread 2 (the current thread).

"signal SIGFOO" can be used for two things: inject a signal in the
program while the program/thread had stopped for none, bypassing
"handle nopass"; or changing/suppressing a signal the program had
stopped for.  These scenarios are really two faces of the same coin,
and GDB can't really guess what the user is trying to do.  GDB might
have intercepted signals in more than one thread even (see the new
signal-command-multiple-signals-pending.exp test).  At least in the
inject case, it's obviously clear to me that the user means to deliver
the signal to the currently selected thread, so best is to make the
command's behavior consistent and easy to explain.

Then, if the user is trying to suppress/change a signal the program
had stopped for instead of injecting a new signal, but, the user had
changed threads meanwhile, then she will be surprised that with:

  (gdb) continue
  Thread 1 stopped for signal SIGFOO.
  (gdb) thread 2
  (gdb) signal SIGBAR

... GDB actually delivers SIGFOO to thread 1, and SIGBAR to thread 2
(with scheduler-locking off, which is the default, because then
"signal" or any other resumption command resumes all threads).

So the patch makes GDB detect that, and ask for confirmation:

  (gdb) thread 1
  [Switching to thread 1 (Thread 10979)]
  (gdb) signal SIGUSR2
  Note:
    Thread 3 previously stopped with signal SIGUSR2, User defined signal 2.
    Thread 2 previously stopped with signal SIGUSR1, User defined signal 1.
  Continuing thread 1 (the current thread) with specified signal will
  still deliver the signals noted above to their respective threads.
  Continue anyway? (y or n)

All these scenarios are covered by the new tests.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-07-25  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention signal passing and "signal" command changes.
	* gdbthread.h (struct thread_suspend_state) <stop_signal>: Extend
	comment.
	* breakpoint.c (until_break_command): Adjust clear_proceed_status
	call.
	* infcall.c (run_inferior_call): Adjust clear_proceed_status call.
	* infcmd.c (proceed_thread_callback, continue_1, step_once)
	(jump_command): Adjust clear_proceed_status call.
	(signal_command): Warn if other thread that are resumed have
	signals that will be delivered.  Adjust clear_proceed_status call.
	(until_next_command, finish_command)
	(proceed_after_attach_callback, attach_command_post_wait)
	(attach_command): Adjust clear_proceed_status call.
	* infrun.c (proceed_after_vfork_done): Likewise.
	(proceed_after_attach_callback): Adjust comment.
	(clear_proceed_status_thread): Clear stop_signal if not in pass
	state.
	(clear_proceed_status_callback): Delete.
	(clear_proceed_status): New 'step' parameter.  Only clear the
	proceed status of threads the command being prepared is about to
	resume.
	(proceed): If passed in an explicit signal, override stop_signal
	with it.  Don't pass the last stop signal to the thread we're
	resuming.
	(init_wait_for_inferior): Adjust clear_proceed_status call.
	(switch_back_to_stepped_thread): Clear the signal if it should not
	be passed.
	* infrun.h (clear_proceed_status): New 'step' parameter.
	(user_visible_resume_ptid): Add comment.
	* linux-nat.c (linux_nat_resume_callback): Don't check whether the
	signal is in pass state.
	* remote.c (append_pending_thread_resumptions): Likewise.
	* mi/mi-main.c (proceed_thread): Adjust clear_proceed_status call.

gdb/doc/
2014-07-25  Pedro Alves  <palves@redhat.com>
	    Eli Zaretskii  <eliz@gnu.org>

	* gdb.texinfo (Signaling) <signal command>: Explain what happens
	with multi-threaded programs.

gdb/testsuite/
2014-07-25  Pedro Alves  <palves@redhat.com>

	* gdb.threads/signal-command-handle-nopass.c: New file.
	* gdb.threads/signal-command-handle-nopass.exp: New file.
	* gdb.threads/signal-command-multiple-signals-pending.c: New file.
	* gdb.threads/signal-command-multiple-signals-pending.exp: New file.
	* gdb.threads/signal-delivered-right-thread.c: New file.
	* gdb.threads/signal-delivered-right-thread.exp: New file.
2014-07-25 16:57:31 +01:00
Michael Eager 164224e96c Fix for remote G Packet message too long error for baremetal.
Prior to version MicroBlaze v8.10.a,EDK 13.1, XMD's gdbserver stub returned 57
registers in response to GDB's G request. Starting with version MicroBlaze
v8.10.a, EDK 13.1, XMD added the slr and shr register, for a count of 59
registers. This patch adds these registers to the expected G response. This patch
fixes the above problem for baremetal and also supports the backward compatibility.

ChangeLog:
2014-07-02  Ajit Agarwal  <ajitkum@xilinx.com>

	* microblaze-tdep.c (microblaze_register_names): Add
	the rshr and rslr register names.
	(microblaze_gdbarch_init): Use of tdesc_has_registers.
	Use of tdesc_find_feature. Use of tdesc_data_alloc.
	Use of tdesc_numbered_register. Use of
	microblaze_register_g_packet_guesses. Use of
	tdesc_use_registers. Use of set_gdbarch_register_type.
	(microblaze_register_g_packet_guesses): New.
	* microblaze-tdep.h (microblaze_reg_num): Add
	field MICROBLAZE_SLR_REGNUM MICROBLAZE_SHR_REGNUM
	MICROBLAZE_NUM_REGS and MICROBLAZE_NUM_CORE_REGS.
	(microblaze_frame_cache): Use of MICROBLAZE_NUM_REGS.
	* features/microblaze-core.xml: New file.
	* features/microblaze-stack-protect.xml: New file.
	* features/microblaze-with-stack-protect.c: New file.
	* features/microblaze-with-stack-protect.xml: New file.
	* features/microblaze.xml: New file.
	* features/microblaze.c: New file.
	* features/Makefile (microblaze-with-stack-protect): Add
	microblaze-with-stack-protect microblaze and
	microblaze-expedite.
	* regformats/microblaze-with-stack-protect.dat: New file.
	* regformats/microblaze.dat: New file.
	* doc/gdb.texinfo (MicroBlaze Features): New.

Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
2014-07-19 17:47:52 -07:00
Yao Qi b67a2c6fd4 Associate dummy_frame with ptid
This patch is to add ptid into dummy_frame and extend frame_id to
dummy_frame_id (which has a ptid field).  With this change, GDB uses
dummy_frame_id (thread ptid and frame_id) to find the dummy frames.

Currently, dummy frames are looked up by frame_id, which isn't
accurate in non-stop or multi-process mode.  The test case
gdb.multi/dummy-frame-restore.exp shows the problem and this patch can
fix it.

Test dummy-frame-restore.exp makes two inferiors stop at
different functions, say, inferior 1 stops at f1 while inferior 2
stops at f2.  Set a breakpoint to a function, do the inferior call
in two inferiors, and GDB has two dummy frames of the same frame_id.
When the inferior call is finished, GDB will look up a dummy frame
from its stack/list and restore the inferior's regcache.  Two
inferiors are finished in different orders, the inferiors' states are
restored differently, which is wrong.  Running dummy-frame-restore.exp
under un-patched GDB, we'll get two fails:

FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2
FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1

With this patch applied, GDB will choose the correct dummy_frame to
restore for a given inferior, because ptid is considered when looking up
dummy frames.  Two fails above are fixed.

Regression tested on x86_64-linux, both native and gdbserver.

gdb:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
	Change parameter type to 'struct thread_info *'.  Caller
	updated.
	* breakpoint.h (check_longjmp_breakpoint_for_call_dummy):
	Update declaration.
	* dummy-frame.c (struct dummy_frame_id): New.
	(dummy_frame_id_eq): New function.
	(struct dummy_frame) <id>: Change its type to 'struct
	dummy_frame_id'.
	(dummy_frame_push): Add parameter ptid and save it in
	dummy_frame_id.
	(pop_dummy_frame_bpt): Use ptid of dummy_frame instead of
	inferior_ptid.
	(pop_dummy_frame): Assert that the ptid of dummy_frame equals
	to inferior_ptid.
	(lookup_dummy_frame): Change parameter type to 'struct
	dummy_frame_id *'.  Callers updated.  Call dummy_frame_id_eq
	instead of frame_id_eq.
	(dummy_frame_pop): Add parameter ptid.  Callers updated.
	Update comments.  Compose dummy_frame_id and pass it to
	lookup_dummy_frame.
	(dummy_frame_discard): Add parameter ptid.
	(dummy_frame_sniffer): Compose dummy_frame_id and call
	dummy_frame_id_eq instead of frame_id_eq.
	(fprint_dummy_frames): Print ptid.
	* dummy-frame.h: Remove comments.
	(dummy_frame_push): Add ptid in declaration.
	(dummy_frame_pop, dummy_frame_discard): Likewise.

gdb/testsuite:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.multi/dummy-frame-restore.exp: New.
	* gdb.multi/dummy-frame-restore.c: New.

gdb/doc:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Maintenance Commands): Update the output of
	'maint print dummy-frames' command.
2014-06-27 20:06:56 +08:00
Eli Zaretskii f179cf97a0 Minor improvements in manual indexing.
* doc/gdb.texinfo (Screen Size): Add more index entries.
2014-06-24 19:28:40 +03:00
Gary Benson 992c7d700f Demangler crash handler
This commit wraps calls to the demangler with a segmentation fault
handler.  The first time a segmentation fault is caught a core file
is generated and the user is prompted to file a bug and offered the
choice to exit or to continue their GDB session.  A maintainence
option is provided to allow the user to disable the crash handler
if required.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* configure.ac [AC_CHECK_FUNCS] <sigaltstack>: New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* main.c (signal.h): New include.
	(setup_alternate_signal_stack): New function.
	(captured_main): Call the above.
	* cp-support.c (signal.h): New include.
	(catch_demangler_crashes): New flag.
	(SIGJMP_BUF): New define.
	(SIGSETJMP): Likewise.
	(SIGLONGJMP): Likewise.
	(gdb_demangle_jmp_buf): New static global.
	(gdb_demangle_attempt_core_dump): Likewise.
	(gdb_demangle_signal_handler): New function.
	(gdb_demangle): If catch_demangler_crashes is set, install the
	above signal handler before calling bfd_demangle, and restore
	the original signal handler afterwards.  Display the offending
	symbol and call demangler_warning the first time a segmentation
	fault is caught.
	(_initialize_cp_support): New maint set/show command.

gdb/doc/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document new
	"maint set/show catch-demangler-crashes" option.
2014-06-19 09:13:57 +01:00
Gary Benson 57fcfb1b20 Add new internal problem for demangler warnings
This commit adds a new category of internal problem for demangler
warnings.  Demangler warnings behave in much the same way as internal
warnings except that they do not create core files and no option to
change this is presented to the user.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* utils.h (demangler_vwarning): New declaration.
	(demangler_warning): Likewise.
	* utils.c (struct internal_problem)
	<user_settable_should_quit>: New field.
	<user_settable_should_dump_core>: Likewise
	(internal_error_problem): Add values for above new fields.
	(internal_warning_problem): Likewise.
	(demangler_warning_problem): New static global.
	(demangler_vwarning): New function.
	(demangler_warning): Likewise.
	(add_internal_problem_command): Selectively add commands.
	(_initialize_utils): New internal problem command.
	* maint.c (maintenance_demangler_warning): New function.
	(_initialize_maint_cmds): New command.

gdb/doc/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document new
	"maint demangler-warning" command and new
	"maint set/show demangler-warning" option.
2014-06-19 09:10:44 +01:00
Siva Chandra dd5d5494f4 Add space before the opening parenthesis in function descriptions.
gdb/doc
	* python.texi (Xmethod API): Add space before the opening
	parenthesis in function descriptions.
2014-06-09 07:19:28 -07:00
Doug Evans 25326a285b fix email address of previous checkins 2014-06-06 16:08:54 -07:00
Doug Evans d2929fdcf0 Add support for guile 2.0.5.
* guile/guile-internal.h (gdbscm_guile_major_version): Declare.
	(gdbscm_guile_minor_version, gdbscm_guile_micro_version): Declare.
	(gdbscm_guile_version_is_at_least): Declare.
	(gdbscm_scm_string_to_int): Declare.
	* guile/guile.c (gdbscm_guile_major_version): New global.
	(gdbscm_guile_minor_version, gdbscm_guile_micro_version): New globals.
	(guile_datadir): New static global.
	(gdbscm_guile_data_directory): New function.
	(initialize_scheme_side): Update.
	(misc_guile_functions): Add guile-data-directory.
	(initialize_gdb_module): Fetch guile version number.
	* guile/lib/gdb.scm: Remove call to add-to-load-path.
	* guile/lib/gdb/init.scm (%initialize!): Ditto.
	* guile/lib/gdb/boot.scm: Use guile-data-directory.
	* guile/scm-exception.c (gdbscm_print_exception_with_stack): Fix
	comments.
	* guile/scm-string.c (gdbscm_scm_string_to_int): New function.
	* guile/scm-utils.c (gdbscm_guile_version_is_at_least): New function.
	* guile/scm-value.c (gdbscm_value_to_string): Only call
	scm_port_conversion_strategy if Guile version >= 2.0.6.

	doc/
	* guile.texi (Guile Configuration): Document guile-data-directory.
2014-06-06 15:57:03 -07:00
xmj 0a770bb257 update ChangeLog 2014-06-06 17:51:30 +08:00