Simon Marchi
8d7493201c
Replace some xmalloc-family functions with XNEW-family ones
...
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 17:18:12 -04:00
Jan Kratochvil
e0619de699
PR symtab/18392
...
Initially there is some chain (let's say the longest one
but that doe snot matter). Consequently its elements from the middle are
being removed and there remains only some few unambiguous top and bottom ones.
The original idea why the comparison should be sharp ("<") was that if there
are multiple chains like (0xaddr show jmp instruction address):
main(0x100) -> a(0x200) -> d(0x400)
main(0x100) -> a(0x200) -> c(0x300) -> d(0x400)
then - such situation cannot exist - if two jmp instructions in "a" have the
same address they must also jump to the same address (*).
(*) jump to a computed address would be never considered for the DWARF
tail-call records.
So there could be:
main(0x100) -> a(0x200) -> d(0x400)
main(0x100) -> a(0x270) -> c(0x300) -> d(0x400)
But then "a" frame itself is ambiguous and it must not be displayed.
I did not realize that there can be self-tail-call:
main(0x100) -> a(0x200) -> d(0x400)
main(0x100) -> a(0x280) -> a(0x200) -> d(0x400)
which intersects to:
main(0x100) -> <???>? -> a(0x200) -> d(0x400)
And so if the first chain was chosen the
main(0x100) -> a(0x200) -> d(0x400)
then the final intersection has callers+callees==length.
> for example, if CALLERS is 3 and
> CALLEES is 2, what does the chain look like?
main(0x100) -> x(0x150) -> y(0x200) -> <???>? -> a(0x200) -> d(0x400)
And if LENGTH is 7 then:
call_site[0] = main(0x100)
call_site[1] = x(0x150)
call_site[2] = y(0x200)
call_site[3] = garbage
call_site[4] = garbage
call_site[5] = a(0x200)
call_site[6] = d(0x400)
gdb/ChangeLog
2015-06-01 Andreas Schwab <schwab@linux-m68k.org>
Jan Kratochvil <jan.kratochvil@redhat.com>
PR symtab/18392
* dwarf2-frame-tailcall.c (pretended_chain_levels): Correct
assertion.
* dwarf2loc.c (chain_candidate): Likewise.
gdb/testsuite/ChangeLog
2015-06-01 Jan Kratochvil <jan.kratochvil@redhat.com>
PR symtab/18392
* gdb.arch/amd64-tailcall-self.S: New file.
* gdb.arch/amd64-tailcall-self.c: New file.
* gdb.arch/amd64-tailcall-self.exp: New file.
2015-06-01 14:02:34 +02:00
Pedro Alves
492d29ea1c
Split TRY_CATCH into TRY + CATCH
...
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 15:14:14 +00: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
Gary Benson
c765fdb902
Remove spurious exceptions.h inclusions
...
defs.h includes utils.h, and utils.h includes exceptions.h. All GDB
.c files include defs.h as their first line, so no file other than
utils.h needs to include exceptions.h. This commit removes all such
inclusions.
gdb/ChangeLog:
* ada-lang.c: Do not include exceptions.h.
* ada-valprint.c: Likewise.
* amd64-tdep.c: Likewise.
* auto-load.c: Likewise.
* block.c: Likewise.
* break-catch-throw.c: Likewise.
* breakpoint.c: Likewise.
* btrace.c: Likewise.
* c-lang.c: Likewise.
* cli/cli-cmds.c: Likewise.
* cli/cli-interp.c: Likewise.
* cli/cli-script.c: Likewise.
* completer.c: Likewise.
* corefile.c: Likewise.
* corelow.c: Likewise.
* cp-abi.c: Likewise.
* cp-support.c: Likewise.
* cp-valprint.c: Likewise.
* darwin-nat.c: Likewise.
* dwarf2-frame-tailcall.c: Likewise.
* dwarf2-frame.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* eval.c: Likewise.
* event-loop.c: Likewise.
* event-top.c: Likewise.
* f-valprint.c: Likewise.
* frame-unwind.c: Likewise.
* frame.c: Likewise.
* gdbtypes.c: Likewise.
* gnu-v2-abi.c: Likewise.
* gnu-v3-abi.c: Likewise.
* guile/scm-auto-load.c: Likewise.
* guile/scm-breakpoint.c: Likewise.
* guile/scm-cmd.c: Likewise.
* guile/scm-frame.c: Likewise.
* guile/scm-lazy-string.c: Likewise.
* guile/scm-param.c: Likewise.
* guile/scm-symbol.c: Likewise.
* guile/scm-type.c: Likewise.
* hppa-hpux-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* inf-loop.c: Likewise.
* infcall.c: Likewise.
* infcmd.c: Likewise.
* infrun.c: Likewise.
* interps.c: Likewise.
* interps.h: Likewise.
* jit.c: Likewise.
* linespec.c: Likewise.
* linux-nat.c: Likewise.
* linux-thread-db.c: Likewise.
* m32r-rom.c: Likewise.
* main.c: Likewise.
* memory-map.c: Likewise.
* mi/mi-cmd-break.c: Likewise.
* mi/mi-cmd-stack.c: Likewise.
* mi/mi-interp.c: Likewise.
* mi/mi-main.c: Likewise.
* monitor.c: Likewise.
* nto-procfs.c: Likewise.
* objc-lang.c: Likewise.
* p-valprint.c: Likewise.
* parse.c: Likewise.
* ppc-linux-tdep.c: Likewise.
* printcmd.c: Likewise.
* probe.c: Likewise.
* python/py-auto-load.c: Likewise.
* python/py-breakpoint.c: Likewise.
* python/py-cmd.c: Likewise.
* python/py-finishbreakpoint.c: Likewise.
* python/py-frame.c: Likewise.
* python/py-framefilter.c: Likewise.
* python/py-function.c: Likewise.
* python/py-gdb-readline.c: Likewise.
* python/py-inferior.c: Likewise.
* python/py-infthread.c: Likewise.
* python/py-lazy-string.c: Likewise.
* python/py-linetable.c: Likewise.
* python/py-param.c: Likewise.
* python/py-prettyprint.c: Likewise.
* python/py-symbol.c: Likewise.
* python/py-type.c: Likewise.
* python/py-value.c: Likewise.
* python/python-internal.h: Likewise.
* python/python.c: Likewise.
* record-btrace.c: Likewise.
* record-full.c: Likewise.
* regcache.c: Likewise.
* remote-fileio.c: Likewise.
* remote-mips.c: Likewise.
* remote.c: Likewise.
* rs6000-aix-tdep.c: Likewise.
* rs6000-nat.c: Likewise.
* skip.c: Likewise.
* solib-darwin.c: Likewise.
* solib-dsbt.c: Likewise.
* solib-frv.c: Likewise.
* solib-ia64-hpux.c: Likewise.
* solib-spu.c: Likewise.
* solib-svr4.c: Likewise.
* solib.c: Likewise.
* spu-tdep.c: Likewise.
* stack.c: Likewise.
* stap-probe.c: Likewise.
* symfile-mem.c: Likewise.
* symmisc.c: Likewise.
* target.c: Likewise.
* thread.c: Likewise.
* top.c: Likewise.
* tracepoint.c: Likewise.
* tui/tui-interp.c: Likewise.
* typeprint.c: Likewise.
* utils.c: Likewise.
* valarith.c: Likewise.
* valops.c: Likewise.
* valprint.c: Likewise.
* value.c: Likewise.
* varobj.c: Likewise.
* windows-nat.c: Likewise.
* xml-support.c: Likewise.
2014-10-08 09:33:22 +01:00
Gary Benson
dccbb60975
Include gdb_assert.h in common-defs.h
...
This commit includes gdb_assert.h in common-defs.h and removes all
other inclusions.
gdb/
2014-08-07 Gary Benson <gbenson@redhat.com>
* common/common-defs.h: Include gdb_assert.h.
* aarch64-tdep.c: Do not include gdb_assert.h.
* addrmap.c: Likewise.
* aix-thread.c: Likewise.
* alpha-linux-tdep.c: Likewise.
* alpha-mdebug-tdep.c: Likewise.
* alphanbsd-tdep.c: Likewise.
* amd64-nat.c: Likewise.
* amd64-tdep.c: Likewise.
* amd64bsd-nat.c: Likewise.
* amd64fbsd-nat.c: Likewise.
* amd64fbsd-tdep.c: Likewise.
* amd64nbsd-nat.c: Likewise.
* amd64nbsd-tdep.c: Likewise.
* amd64obsd-nat.c: Likewise.
* amd64obsd-tdep.c: Likewise.
* arch-utils.c: Likewise.
* arm-tdep.c: Likewise.
* armbsd-tdep.c: Likewise.
* auxv.c: Likewise.
* bcache.c: Likewise.
* bfin-tdep.c: Likewise.
* blockframe.c: Likewise.
* breakpoint.c: Likewise.
* bsd-kvm.c: Likewise.
* bsd-uthread.c: Likewise.
* buildsym.c: Likewise.
* c-exp.y: Likewise.
* c-lang.c: Likewise.
* charset.c: Likewise.
* cleanups.c: Likewise.
* cli-out.c: Likewise.
* cli/cli-decode.c: Likewise.
* cli/cli-dump.c: Likewise.
* cli/cli-logging.c: Likewise.
* cli/cli-script.c: Likewise.
* cli/cli-utils.c: Likewise.
* coffread.c: Likewise.
* common/common-utils.c: Likewise.
* common/queue.h: Likewise.
* common/signals.c: Likewise.
* common/vec.h: Likewise.
* complaints.c: Likewise.
* completer.c: Likewise.
* corelow.c: Likewise.
* cp-abi.c: Likewise.
* cp-name-parser.y: Likewise.
* cp-namespace.c: Likewise.
* cp-support.c: Likewise.
* cris-tdep.c: Likewise.
* dbxread.c: Likewise.
* dictionary.c: Likewise.
* doublest.c: Likewise.
* dsrec.c: Likewise.
* dummy-frame.c: Likewise.
* dwarf2-frame-tailcall.c: Likewise.
* dwarf2-frame.c: Likewise.
* dwarf2expr.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* eval.c: Likewise.
* event-loop.c: Likewise.
* exceptions.c: Likewise.
* expprint.c: Likewise.
* f-valprint.c: Likewise.
* fbsd-nat.c: Likewise.
* findvar.c: Likewise.
* frame-unwind.c: Likewise.
* frame.c: Likewise.
* frv-tdep.c: Likewise.
* gcore.c: Likewise.
* gdb-dlfcn.c: Likewise.
* gdb_bfd.c: Likewise.
* gdbarch.c: Likewise.
* gdbarch.sh: Likewise.
* gdbtypes.c: Likewise.
* gnu-nat.c: Likewise.
* gnu-v3-abi.c: Likewise.
* go-lang.c: Likewise.
* guile/scm-exception.c: Likewise.
* guile/scm-gsmob.c: Likewise.
* guile/scm-lazy-string.c: Likewise.
* guile/scm-math.c: Likewise.
* guile/scm-pretty-print.c: Likewise.
* guile/scm-safe-call.c: Likewise.
* guile/scm-utils.c: Likewise.
* guile/scm-value.c: Likewise.
* h8300-tdep.c: Likewise.
* hppa-hpux-nat.c: Likewise.
* hppa-tdep.c: Likewise.
* hppanbsd-tdep.c: Likewise.
* hppaobsd-tdep.c: Likewise.
* i386-darwin-nat.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i386-nto-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* i386bsd-nat.c: Likewise.
* i386fbsd-tdep.c: Likewise.
* i386gnu-nat.c: Likewise.
* i386nbsd-tdep.c: Likewise.
* i386obsd-tdep.c: Likewise.
* i387-tdep.c: Likewise.
* ia64-libunwind-tdep.c: Likewise.
* ia64-tdep.c: Likewise.
* inf-ptrace.c: Likewise.
* inf-ttrace.c: Likewise.
* infcall.c: Likewise.
* infcmd.c: Likewise.
* infrun.c: Likewise.
* inline-frame.c: Likewise.
* interps.c: Likewise.
* jv-lang.c: Likewise.
* jv-typeprint.c: Likewise.
* linux-fork.c: Likewise.
* linux-nat.c: Likewise.
* linux-thread-db.c: Likewise.
* m32c-tdep.c: Likewise.
* m32r-linux-nat.c: Likewise.
* m32r-tdep.c: Likewise.
* m68k-tdep.c: Likewise.
* m68kbsd-nat.c: Likewise.
* m68kbsd-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* machoread.c: Likewise.
* macroexp.c: Likewise.
* macrotab.c: Likewise.
* maint.c: Likewise.
* mdebugread.c: Likewise.
* memory-map.c: Likewise.
* mep-tdep.c: Likewise.
* mi/mi-common.c: Likewise.
* microblaze-tdep.c: Likewise.
* mingw-hdep.c: Likewise.
* mips-linux-nat.c: Likewise.
* mips-linux-tdep.c: Likewise.
* mips-tdep.c: Likewise.
* mips64obsd-tdep.c: Likewise.
* mipsnbsd-tdep.c: Likewise.
* mn10300-linux-tdep.c: Likewise.
* mn10300-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* mt-tdep.c: Likewise.
* nat/linux-btrace.c: Likewise.
* nat/linux-osdata.c: Likewise.
* nat/linux-ptrace.c: Likewise.
* nat/mips-linux-watch.c: Likewise.
* nios2-linux-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* objc-lang.c: Likewise.
* objfiles.c: Likewise.
* obsd-nat.c: Likewise.
* opencl-lang.c: Likewise.
* osabi.c: Likewise.
* parse.c: Likewise.
* ppc-linux-nat.c: Likewise.
* ppc-sysv-tdep.c: Likewise.
* ppcfbsd-nat.c: Likewise.
* ppcfbsd-tdep.c: Likewise.
* ppcnbsd-nat.c: Likewise.
* ppcnbsd-tdep.c: Likewise.
* ppcobsd-nat.c: Likewise.
* ppcobsd-tdep.c: Likewise.
* printcmd.c: Likewise.
* procfs.c: Likewise.
* prologue-value.c: Likewise.
* psymtab.c: Likewise.
* python/py-lazy-string.c: Likewise.
* python/py-value.c: Likewise.
* regcache.c: Likewise.
* reggroups.c: Likewise.
* registry.c: Likewise.
* remote-sim.c: Likewise.
* remote.c: Likewise.
* rs6000-aix-tdep.c: Likewise.
* rs6000-tdep.c: Likewise.
* s390-linux-tdep.c: Likewise.
* score-tdep.c: Likewise.
* ser-base.c: Likewise.
* ser-mingw.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* solib-darwin.c: Likewise.
* solib-spu.c: Likewise.
* solib-svr4.c: Likewise.
* source.c: Likewise.
* sparc-nat.c: Likewise.
* sparc-sol2-tdep.c: Likewise.
* sparc-tdep.c: Likewise.
* sparc64-sol2-tdep.c: Likewise.
* sparc64-tdep.c: Likewise.
* sparc64fbsd-tdep.c: Likewise.
* sparc64nbsd-tdep.c: Likewise.
* sparc64obsd-tdep.c: Likewise.
* sparcnbsd-tdep.c: Likewise.
* sparcobsd-tdep.c: Likewise.
* spu-multiarch.c: Likewise.
* spu-tdep.c: Likewise.
* stabsread.c: Likewise.
* stack.c: Likewise.
* symfile.c: Likewise.
* symtab.c: Likewise.
* target-descriptions.c: Likewise.
* target-memory.c: Likewise.
* target.c: Likewise.
* tic6x-linux-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-linux-nat.c: Likewise.
* tilegx-tdep.c: Likewise.
* top.c: Likewise.
* tramp-frame.c: Likewise.
* tui/tui-out.c: Likewise.
* tui/tui-winsource.c: Likewise.
* ui-out.c: Likewise.
* user-regs.c: Likewise.
* utils.c: Likewise.
* v850-tdep.c: Likewise.
* valops.c: Likewise.
* value.c: Likewise.
* varobj.c: Likewise.
* vax-nat.c: Likewise.
* xml-syscall.c: Likewise.
* xml-tdesc.c: Likewise.
* xstormy16-tdep.c: Likewise.
* xtensa-linux-nat.c: Likewise.
* xtensa-tdep.c: Likewise.
gdb/gdbserver/
2014-08-07 Gary Benson <gbenson@redhat.com>
* server.h: Do not include gdb_assert.h.
2014-08-07 09:06:45 +01:00
Joel Brobecker
ecd75fc8ee
Update Copyright year range in all files maintained by GDB.
2014-01-01 07:54:24 +04:00
Jan Kratochvil
05c56a9d39
gdb/
...
Fix entry-values if the callee called a noreturn function.
* dwarf2-frame-tailcall.c (dwarf2_tailcall_sniffer_first): Use
get_frame_address_in_block. Add new comment.
gdb/testsuite/
Fix entry-values if the callee called a noreturn function.
* gdb.arch/amd64-tailcall-noret.S: New file.
* gdb.arch/amd64-tailcall-noret.c: New file.
* gdb.arch/amd64-tailcall-noret.exp: New file.
2013-03-10 18:06:26 +00:00
Joel Brobecker
28e7fd6234
Update years in copyright notice for the GDB files.
...
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.
2013-01-01 06:33:28 +00:00
Jan Kratochvil
193facb37d
gdb/
...
Code cleanup - rename 'inline' depth to 'artificial' depth.
* breakpoint.c (set_momentary_breakpoint): Rename at a caller to
frame_id_artificial_p, extend the comment.
* dwarf2-frame-tailcall.c (tailcall_frame_this_id): Rename at a user.
* frame.c (fprint_frame_id): Rename at a user, change debug output
text to "artificial=".
(skip_inlined_frames): Rename to ...
(skip_artificial_frames): ... here. Extend the comment.
(get_stack_frame_id, frame_unwind_caller_id): Rename at a caller.
(frame_id_inlined_p): Rename to ...
(frame_id_artificial_p): ... here. Rename at a user.
(frame_id_eq, frame_id_inner, frame_unwind_caller_pc)
(frame_unwind_caller_pc_if_available, frame_unwind_caller_arch): Rename
at a user.
* frame.h (struct frame_id): Rename inline_depth to artificial_depth.
Extend the comment.
(frame_id_inlined_p): Rename to ...
(frame_id_artificial_p): ... here.
* inline-frame.c (inline_frame_this_id): Rename at a user.
2012-09-17 07:03:14 +00:00
Sergio Durigan Junior
22e048c9dd
2012-05-18 Sergio Durigan Junior <sergiodj@redhat.com>
...
* ada-lang.c:
* ada-tasks.c:
* ada-varobj.c:
* amd64-darwin-tdep.c:
* arm-symbian-tdep.c:
* arm-tdep.c:
* avr-tdep.c:
* ax-gdb.c:
* bfin-linux-tdep.c:
* breakpoint.c:
* c-valprint.c:
* cli/cli-cmds.c:
* coffread.c:
* cp-support.c:
* cris-tdep.c:
* dwarf2-frame-tailcall.c:
* dwarf2-frame.c:
* dwarf2expr.c:
* dwarf2loc.c:
* dwarf2read.c:
* elfread.c:
* eval.c:
* expprint.c:
* f-valprint.c:
* frv-tdep.c:
* h8300-tdep.c:
* hppa-hpux-tdep.c:
* hppa-tdep.c:
* hppanbsd-tdep.c:
* i386-nto-tdep.c:
* i386-tdep.c:
* i387-tdep.c:
* ia64-tdep.c:
* jit.c:
* linespec.c:
* linux-tdep.c:
* lm32-tdep.c:
* m2-valprint.c:
* m32c-tdep.c:
* m32r-rom.c:
* m32r-tdep.c:
* m68k-tdep.c:
* m68klinux-tdep.c:
* mi/mi-main.c:
* microblaze-tdep.c:
* mips-linux-tdep.c:
* mips-tdep.c:
* mn10300-tdep.c:
* p-valprint.c:
* parse.c:
* ppc-linux-tdep.c:
* ppc-sysv-tdep.c:
* printcmd.c:
* python/py-finishbreakpoint.c:
* python/py-inferior.c:
* python/py-infthread.c:
* python/py-type.c:
* python/python.c:
* remote-fileio.c:
* remote-m32r-sdi.c:
* remote-mips.c:
* reverse.c:
* rl78-tdep.c:
* rs6000-aix-tdep.c:
* rs6000-tdep.c:
* s390-tdep.c:
* score-tdep.c:
* sh64-tdep.c:
* skip.c:
* solib-darwin.c:
* solib-dsbt.c:
* solib-frv.c:
* sparc-tdep.c:
* spu-multiarch.c:
* spu-tdep.c:
* stack.c:
* symfile.c:
* symtab.c:
* tic6x-tdep.c:
* tracepoint.c:
* v850-tdep.c:
* valarith.c:
* valprint.c:
* value.c:
* xcoffread.c:
* xtensa-tdep.c:
* ada-lang.c:
* ada-tasks.c:
* ada-varobj.c:
* amd64-darwin-tdep.c:
* arm-symbian-tdep.c:
* arm-tdep.c: Delete unused variables.
2012-05-18 21:02:52 +00:00
Joel Brobecker
0b30217134
Copyright year update in most files of the GDB Project.
...
gdb/ChangeLog:
Copyright year update in most files of the GDB Project.
2012-01-04 08:17:56 +00:00
Jan Kratochvil
13294f7d62
gdb/
...
* dwarf2-frame-tailcall.c: Include dwarf2-frame.h.
(dwarf2_tailcall_prev_register_first): Use dwarf2_frame_cfa.
(dwarf2_tailcall_sniffer_first): Remove variable pc_regnum. Replace
gdbarch_pc_regnum and frame_unwind_register_unsigned by
gdbarch_unwind_pc.
2011-10-20 23:57:23 +00:00
Jan Kratochvil
e1b16eb466
gdb/
...
Add forgotten gdb/dwarf2-frame-tailcall.c.
Add forgotten gdb/dwarf2-frame-tailcall.h.
2011-10-09 20:21:48 +00:00