gdb/ChangeLog:
2015-02-27 Pedro Alves <palves@redhat.com>
* common/common-exceptions.h (exception_none): Declare.
* common/common-exceptions.c (exception_none): Moved from
exceptions.c.
(exceptions_state_mc_init): Use exception_none.
* exceptions.c (exception_none): Move to
common/common-exceptions.c.
* exceptions.h (exception_none): Move to
common/common-exceptions.h.
This commit includes common-exceptions.h in common-defs.h and removes
all other inclusions.
gdb/ChangeLog:
* common/common-defs.h: Include common-exceptions.h.
* exceptions.h: Do not include common-exceptions.h.
gdb/gdbserver/ChangeLog:
* server.h: Do not include common-exceptions.h.
This commit creates a new file, common/gdb_setjmp.h, to hold some
portability macros for setjmp/longjmp et al. that are used by the
exceptions subsystem and by the demangler crash catcher.
gdb/ChangeLog:
* common/gdb_setjmp.h: New file.
* Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h.
* configure.ac: Move sigsetjmp check...
* common/common.m4: ...here.
* configure: Regenerate.
* cp-support.c (SIGJMP_BUF): Delete.
(SIGSETJMP): Likewise.
(SIGLONGJMP): Likewise.
* exceptions.h (gdb_setjmp.h): Include.
(setjmp.h): Do not include.
(EXCEPTIONS_SIGJMP_BUF): Delete.
(EXCEPTIONS_SIGSETJMP): Likewise.
(EXCEPTIONS_SIGLONGJMP): Likewise.
Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros
from gdb_setjmp.h.
* exceptions.c: Likewise.
gdb/gdbserver/ChangeLog:
* config.in: Regenerate.
* configure: Likewise.
GDB and gdbserver have functions named "fatal" that are used in
completely different ways. In gdbserver "fatal" is used to handle
critical errors: it differs from "error" in that "fatal" causes
gdbserver to exit whereas "error" does not. In GDB "fatal" is used
to abort the current operation and return to the command level.
This is implemented by throwing a non-error "RETURN_QUIT" exception.
This commit removes GDB's "fatal" and "vfatal" functions entirely.
The exception-throwing function "throw_vfatal" is renamed as
"throw_vquit", and a new convenience function "throw_quit" is added.
The small number of calls to "fatal" are replaced with calls to
"throw_quit", making what is happening more obvious.
This commit also modifies GDB's "throw_error" to call "throw_verror"
rather than calling "throw_it" directly. This change means the
assignment of RETURN_ERROR as the exception type now happens in
precisely one place in GDB rather than two.
gdb/
2014-07-24 Gary Benson <gbenson@redhat.com>
* exceptions.h (throw_vfatal): Renamed to...
(throw_vquit): New declaration.
(throw_quit): Likewise.
* exceptions.c (throw_vfatal): Renamed to...
(throw_vquit): New function.
(throw_quit): Likewise.
(throw_error): Call throw_verror rather than throw_it.
* utils.h (vfatal): Removed.
(fatal): Likewise.
* utils.c (vfatal): Removed.
(fatal): Likewise.
(internal_verror): Replaced call to fatal with call to throw_quit.
(quit): Replaced calls to fatal with calls to throw_quit.
We'll need to add error handling code to commands run before the event
loop starts (commands in .gdbinit, -ex commands, etc.). Turns out
those are run through catch_command_errors, and, catch_command_errors
is used nowhere else. Move it (and the _const variant) to main.c, so
that we can further specialize it freely.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
* exceptions.c (catch_command_errors, catch_command_errors_const):
Moved to main.c.
* exceptions.h (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved to main.c.
(catch_command_errors, catch_command_errors_const): Delete
declarations.
* main.c (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved here from exceptions.h.
(catch_command_errors, catch_command_errors_const)): Moved here
from exceptions.c and make static.
Although we can tell upfront whether a remote target supports target
side commands, we can only tell whether the target supports that in
combination with a given breakpoint kind (software, hardware,
watchpoints, etc.) when we go and try to insert such a breakpoint kind
the first time. It's not desirable to make remote_insert_breakpoint
simply return -1 in this case, because if the breakpoint was set in a
shared library, insert_bp_location will assume that the breakpoint
insertion failed because the library wasn't mapped in.
insert_bp_location already handles errors/exceptions thrown from the
target_insert_xxx methods, exactly so the backend can tell the user
the detailed reason the insertion of hw breakpoints failed. But, in
the case of software breakpoints, it discards the detailed error
message.
So the patch makes insert_bp_location use the error's message for SW
breakpoints too, and, introduces a NOT_SUPPORTED_ERROR error code so
that insert_bp_location doesn't confuse the error for failure due to a
shared library disappearing.
The result is:
(gdb) c
Warning:
Cannot insert breakpoint 2: Target doesn't support breakpoints that have target side commands.
2014-01-09 Pedro Alves <palves@redhat.com>
Hui Zhu <hui@codesourcery.com>
PR gdb/16101
* breakpoint.c (insert_bp_location): Rename hw_bp_err_string to
bp_err_string. Don't mark the location shlib_disabled if the
error thrown wasn't a generic or memory error. Catch errors
thrown while inserting breakpoints in overlayed code. Output
error message of software breakpoints.
* remote.c (remote_insert_breakpoint): If this breakpoint has
target-side commands but this stub doesn't support Z0 packets,
throw NOT_SUPPORTED_ERROR error.
* exceptions.h (enum errors) <NOT_SUPPORTED_ERROR>: New error.
* target.h (target_insert_breakpoint): Extend comment.
(target_insert_hw_breakpoint): Add comment.
I have a case that could use an exception for "unsupported feature".
I found UNSUPPORTED_ERROR, but looking deeper, I think as is, reusing
it for other things would be fragile. E.g., if the Python script
sourced by source_script_from_stream triggers any other missing
functionality that would result in UNSUPPORTED_ERROR being propagated
out to source_script_from_stream, that would confuse the error for
Python not being built into GDB.
This patch thus redoes things a little. Instead of using an exception
for the "No Python" scenario, check whether Python is configured in
before actually trying to source the file. It adds a new function
instead of using #ifdef HAVE_PYTHON directly, as that is better at
avoiding bitrot, as both Python and !Python paths are visible to the
compiler this way.
Tested on Fedora 17, with and without Python.
gdb/
2013-12-12 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (source_script_from_stream) Use have_python
instead of catching UNSUPPORTED_ERROR.
* exceptions.h (UNSUPPORTED_ERROR): Delete.
* python/python.c (source_python_script) [!HAVE_PYTHON]: Internal
error if called.
* python/python.h (have_python): New static inline function.
In order to catch <optimized out> errors like we catch <unavailable>
errors, this adds a new OPTIMIZED_OUT_ERROR error code, and throws it
in various places.
gdb/ChangeLog
2013-12-06 Andrew Burgess <aburgess@broadcom.com>
Pedro Alves <palves@redhat.com>
* exceptions.h (errors): Add OPTIMIZED_OUT_ERROR.
* dwarf2loc.c (write_pieced_value): Throw OPTIMIZED_OUT_ERROR.
* frame.c (frame_unwind_register): Throw OPTIMIZED_OUT_ERROR.
* spu-tdep.c (spu_software_single_step): Throw
OPTIMIZED_OUT_ERROR.
* valops.c (value_assign): Throw OPTIMIZED_OUT_ERROR.
... when trying to execute an undefined GDB/MI command. When trying
to execute a GDB/MI command which does not exist, the current error
result record looks like this:
-unsupported
^error,msg="Undefined MI command: unsupported"
The only indication that the command does not exist is the error
message. It would be a little fragile for a consumer to rely solely
on the contents of the error message in order to determine whether
a command exists or not.
This patch improves the situation by adding concept of error
code, starting with one well-defined error code ("undefined-command")
identifying errors due to a non-existant command. Here is the new
output:
-unsupported
^error,msg="Undefined MI command: unsupported",code="undefined-command"
This error code is only displayed when the corresponding error
condition is met. Otherwise, the error record remains unchanged.
For instance:
-symbol-list-lines foo.adb
^error,msg="-symbol-list-lines: Unknown source file name."
For frontends to be able to know whether they can rely on this
variable, a new entry "undefined-command-error-code" has been
added to the "-list-features" command. Another option would be
to always generate an error="..." variable (for the default case,
we could decide for instance that the error code is the empty string).
But it seems more efficient to provide that info in "-list-features"
and then only add the error code when meaningful.
gdb/ChangeLog:
(from Pedro Alves <palves@redhat.com>)
(from Joel Brobecker <brobecker@adacore.com>)
* exceptions.h (enum_errors) <UNDEFINED_COMMAND_ERROR>: New enum.
* mi/mi-parse.c (mi_parse): Throw UNDEFINED_COMMAND_ERROR instead
of a regular error when the GDB/MI command does not exist.
* mi/mi-main.c (mi_cmd_list_features): Add
"undefined-command-error-code".
(mi_print_exception): Print an "undefined-command"
error code if EXCEPTION.ERROR is UNDEFINED_COMMAND_ERROR.
* NEWS: Add entry documenting the new "code" variable in
"^error" result records.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI Result Records): Fix the syntax of the
"^error" result record concerning the error message. Document
the error code that may also be part of that result record.
(GDB/MI Miscellaneous Commands): Document the
"undefined-command-error-code" element in the output of
the "-list-features" GDB/MI command.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-undefined-cmd.exp: New testcase.
This fixes PR python/15816.
The bug here is that python-selftest.exp can fail:
No symbol "RETURN_MASK_ALL" in current context.
RETURN_MASK_ALL is a macro, so if macros do not end up in the
debuginfo (very typical) then the test fails.
It seemed simplest to me to simply turn the RETURN_MASK_ defines into
enum constants. This way they end up in the debuginfo and all is
well.
PR python/15816:
* exceptions.h (return_mask): Now an enum.
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL): Now
enum constants.
Built and regtested on x86-64 Fedora 18.
A following patch will want to make the "gdbinit" global array const.
As usual, that forces in a cascading series of const additions. This
patch preemptively does those. I went all the way up to constifying
catch_command_errors, but then that would require constifying
execute_command as well (which is a much more significant effort). So
as stop point, I found the cleanest would be to add a variant of
catch_command_errors that takes const args, and use that in the few
spots that needed it due to the the get_init_files constification.
gdb/
2013-07-01 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (source_script): Make 'file' parameter const.
* cli/cli-cmds.h (source_script): Likewise.
* exceptions.c (catch_command_errors_const): New function.
* exceptions.h (catch_command_errors_const): Declare.
* main.c (get_init_files): Make parameters const, and adjust.
(captured_main): Make 'system_gdbinit', 'home_gdbinit' and
'local_gdbinit' locals const. Adjust to use
catch_command_errors_const.
(print_gdb_help): Make 'system_gdbinit', 'home_gdbinit' and
'local_gdbinit' locals const.
gdb/
2013-06-27 Pedro Alves <palves@redhat.com>
* exceptions.c (catch_command_errors): Remove spurious space.
* exceptions.h (catch_command_errors): Second parameter is "arg",
not "command".
* exceptions.h (enum errors): New entry TARGET_CLOSE_ERROR.
* remote.c (trace_error): Remove the special handling of '2'.
(readchar) <SERIAL_EOF>
(readchar) <SERIAL_ERROR>
(getpkt_or_notif_sane_1): Use TARGET_CLOSE_ERROR for them.
(remote_get_trace_status): Call throw_exception if EX is
TARGET_CLOSE_ERROR.
* utils.c (perror_with_name): Rename to ...
(throw_perror_with_name): ... here. New parameter errcode, describe it
in the function comment.
(perror_with_name): New function wrapper.
* utils.h (enum errors): New stub declaration.
(throw_perror_with_name): New declaration.
gdb/testsuite/
* gdb.server/server-kill.c: New file.
* gdb.server/server-kill.exp: New file.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
Implement basic support for DW_TAG_GNU_call_site.
* block.c: Include gdbtypes.h and exceptions.h.
(call_site_for_pc): New function.
* block.h (call_site_for_pc): New declaration.
* defs.h: Include hashtab.h.
(make_cleanup_htab_delete, core_addr_hash, core_addr_eq): New
declarations.
* dwarf2-frame.c (dwarf2_frame_ctx_funcs): Install
ctx_no_push_dwarf_reg_entry_value.
* dwarf2expr.c (read_uleb128, read_sleb128): Support R as NULL.
(dwarf_block_to_dwarf_reg): New function.
(execute_stack_op) <DW_OP_GNU_entry_value>: Implement it.
(ctx_no_push_dwarf_reg_entry_value): New function.
* dwarf2expr.h (struct dwarf_expr_context_funcs): New field
push_dwarf_reg_entry_value.
(ctx_no_push_dwarf_reg_entry_value, dwarf_block_to_dwarf_reg): New
declarations.
* dwarf2loc.c: Include gdbcmd.h.
(dwarf_expr_ctx_funcs): New forward declaration.
(entry_values_debug, show_entry_values_debug, call_site_to_target_addr)
(dwarf_expr_reg_to_entry_parameter)
(dwarf_expr_push_dwarf_reg_entry_value): New.
(dwarf_expr_ctx_funcs): Install dwarf_expr_push_dwarf_reg_entry_value.
(dwarf2_evaluate_loc_desc_full): Handle NO_ENTRY_VALUE_ERROR.
(needs_dwarf_reg_entry_value): New function.
(needs_frame_ctx_funcs): Install it.
(_initialize_dwarf2loc): New function.
* dwarf2loc.h (entry_values_debug): New declaration.
* dwarf2read.c (struct dwarf2_cu): New field call_site_htab.
(read_call_site_scope): New forward declaration.
(process_full_comp_unit): Copy call_site_htab.
(process_die): Support DW_TAG_GNU_call_site.
(read_call_site_scope): New function.
(dwarf2_get_pc_bounds): Support NULL HIGHPC.
(dwarf_tag_name): Support DW_TAG_GNU_call_site.
(cleanup_htab): Delete.
(write_psymtabs_to_index): Use make_cleanup_htab_delete instead of it.
* exceptions.h (enum errors): New NO_ENTRY_VALUE_ERROR.
* gdb-gdb.py (StructMainTypePrettyPrinter): Support
FIELD_LOC_KIND_DWARF_BLOCK.
* gdbtypes.h (enum field_loc_kind): New entry
FIELD_LOC_KIND_DWARF_BLOCK.
(struct main_type): New loc entry dwarf_block.
(struct call_site, FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK)
(TYPE_FIELD_DWARF_BLOCK): New.
* python/py-type.c: Include dwarf2loc.h.
(check_types_equal): Support FIELD_LOC_KIND_DWARF_BLOCK. New
internal_error call on unknown FIELD_LOC_KIND.
* symtab.h (struct symtab): New field call_site_htab.
* utils.c (do_htab_delete_cleanup, make_cleanup_htab_delete)
(core_addr_hash, core_addr_eq): New functions.
gdb/testsuite/
Implement basic support for DW_TAG_GNU_call_site.
* gdb.arch/Makefile.in (EXECUTABLES): Add amd64-entry-value.
* gdb.arch/amd64-entry-value.cc: New file.
* gdb.arch/amd64-entry-value.exp: New file.
* exceptions.c (struct catcher): Remove saved_uiout field.
(exceptions_state_mc_init): Remove the `func_uiout' parameter, and
no longer save/resvore the global ui_out builder.
(catch_exceptions_with_msg): Save/override/restore the global
ui_out builder manually instead of relying on TRY_CATCH to do it.
(catch_errors): Save/restore the global ui_out builder manually
instead of relying on TRY_CATCH to do it.
* exceptions.h (exceptions_state_mc_init): Remove the `func_uiout'
parameter.
(TRY_CATCH): Adjust.
* cli/cli-interp.c (safe_execute_command): Save/override/restore
the global ui_out builder manually instead of relying on TRY_CATCH
to do it.
* exceptions.h (NOT_AVAILABLE_ERROR): New error.
* value.c: Include "exceptions.h".
(require_available): Throw NOT_AVAILABLE_ERROR instead of a
generic error.
* cp-abi.c: Include gdb_assert.h.
(baseclass_offset): Add `embedded_offset' and `val' parameters.
Assert the method is implemented. Wrap NOT_AVAILABLE_ERROR
errors.
* cp-abi.h (baseclass_offset): Add `embedded_offset' and `val'
parameters. No longer returns -1 on error.
(struct cp_abi_ops) <baseclass_offset>: Add `embedded_offset' and
`val' parameters.
* cp-valprint.c: Include exceptions.h.
(cp_print_value): Handle NOT_AVAILABLE_ERROR errors when fetching
the baseclass_offset. Handle unavailable base classes. Use
val_print_invalid_address.
* p-valprint.c: Include exceptions.h.
(pascal_object_print_value): Handle NOT_AVAILABLE_ERROR errors
when fetching the baseclass_offset. No longer expect
baseclass_offset returning -1. Handle unavailable base classes.
Use val_print_invalid_address.
* valops.c (dynamic_cast_check_1): Rename `contents' parameter to
`valaddr' parameter, and change its type to gdb_byte pointer. Add
`embedded_offset' and `val' parameters. Adjust.
(dynamic_cast_check_2): Rename `contents' parameter to `valaddr'
parameter, and change its type to gdb_byte pointer. Add
`embedded_offset' and `val' parameters. Adjust. No longer expect
baseclass_offset returning -1.
(value_dynamic_cast): Use value_contents_for_printing rather than
value_contents. Adjust.
(search_struct_field): No longer expect baseclass_offset returning
-1.
(search_struct_method): If reading memory from the target is
necessary, wrap it in a new value to pass to baseclass_offset. No
longer expect baseclass_offset returning -1.
(find_method_list): No longer expect baseclass_offset returning
-1. Use value_contents_for_printing rather than value_contents.
* valprint.c (val_print_invalid_address): New function.
* valprint.h (val_print_invalid_address): Declare.
* gdbtypes.c (is_unique_ancestor_worker): New `embedded_offset'
and `val' parameters. No longer expect baseclass_offset returning
-1. Adjust.
* gnu-v2-abi.c: Include "exceptions.h".
(gnuv2_baseclass_offset): Add `embedded_offset' and `val'
parameters. Handle unavailable memory. Recurse through
gnuv2_baseclass_offset directly, rather than through
baseclass_offset. No longer returns -1 on not found, instead
throw an error.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Add `embedded_offset' and
`val' parameters. Adjust.
gdb/testsuite/
* gdb.trace/unavailable.cc (class Base, class Middle, class
Derived): New types.
(derived_unavail, derived_partial, derived_whole): New globals.
(virtual_partial): New global.
(virtualp): Point at virtual_partial.
* gdb.trace/unavailable.exp (gdb_collect_globals_test): Add tests
related to unavailable vptr.
* exceptions.h (exception_fprintf): Declare.
(exception_print): Drop pre_print parameter.
* mi/mi-main.c (mi_execute_command): Update exception_print call.
* cli/cli-interp.c (safe_execute_command): Update exception_print
call.
* remote.c (remote_open_1): Instead of passing an error prefix to
catch_exceptions, use catch_exceptions and exception_fprintf.
(remote_start_remote): Change return type to void.
* breakpoint.c (insert_bp_location): Instead of passing an error
prefix to catch_exceptions, use catch_exceptions and
exception_fprintf.
(insert_catchpoint): Change return type to void.
(break_command_1): Update exception_print call.
* exceptions.c (exception_fprintf): New function.
(print_exception): New function.
(exception_print): Use print_exception.