summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Support an "unlimited" number of user-defined argumentsusers/palves/cxx-eliminate-cleanups-v2Pedro Alves2016-10-174-92/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I recently wrote a user-defined command that would benefit from supporting an unlimited number of arguments: http://palves.net/list-active-signal-handlers-with-gdb/ However, we currently only support up to 10 arguments passed to user-defined commands ($arg0..$arg9). I can't find a good reason for that, other than "old code with hard coded limits". This patch removes that limit and modernizes the code along the way: - Makes the user_args struct a real C++ class that uses std::vector for storage. - Removes the "next" pointer from within user_args and uses a std::vector to maintain a stack instead. - Adds a new RAII-based scoped_user_args_level class to help push/pop user args in the stack instead of using a cleanup. I also needed a way to convert a number to a std::string, so I added a new utility for that, gdb::to_string. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * NEWS: Mention that user commands now accept an unlimited number of arguments. * cli/cli-script.c: Include <vector>. (struct string_view): New type. (MAXUSERARGS): Delete. (struct user_args): Now a C++ class. (user_args_stack): New. (struct scoped_user_args_level): New type. (execute_user_command): Use scoped_user_args_level. Adjust to call insert_user_args instead of insert_args. (arg_cleanup): Delete. (setup_user_args): Deleted, and refactored as ... (user_args::user_args): ... this new constructor. Limit of number of arguments removed. (insert_args): Delete. (insert_user_args) New. (user_args::insert_args): New, bits based on old insert_args with limit of number of arguments eliminated. * common/common-utils.h: Include <sstream>. (gdb::to_string): New. gdb/doc/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * gdb.texinfo (User-defined Commands): Limit on number of arguments passed to user-defined commands removed; update.
* Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_infoPedro Alves2016-10-174-43/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the previous patch, we end up with these two types with quite similar, and potentially confusing names: typedef gdb::unique_ptr<agent_expr> agent_expr_up; /* Pointer to an agent_expr structure. */ typedef struct agent_expr *agent_expr_p; The latter is only necessary to put agent_expr pointers in VECs. So just eliminate it and use std::vector instead. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * ax.h (agent_expr_p): Delete. (DEF_VEC_P (agent_expr_p)): Delete. * breakpoint.c (build_target_condition_list) (build_target_command_list): Adjust to use of std::vector. (bp_location_dtor): Remove now unnecessary VEC_free calls. * breakpoint.h: Include <vector>. (struct bp_target_info) <conditions, tcommands>: Now std::vector's. * remote.c (remote_add_target_side_condition): bp_tgt->conditions is now a std::vector; adjust. (remote_add_target_side_commands, remote_insert_breakpoint): bp_tgt->tcommands is now a std::vector; adjust.
* 'struct agent_expr *' -> unique_ptr<agent_expr>Pedro Alves2016-10-179-256/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the gen_* functions return a unique_ptr instead of raw pointer: typedef gdb::unique_ptr<agent_expr> agent_expr_up; and then adjusts the codebase throughout to stop using make_cleanup_free_agent_expr. The cond_bytecode and cmd_bytecode fields of struct bp_location are changed to be unique_ptr's instead of raw pointers, since these are owning pointers. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up. (gen_trace_for_var, gen_trace_for_expr, gen_eval_for_expr) (gen_trace_for_return_address, gen_printf): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (agent_eval_command_one, maint_agent_printf_command): Use agent_expr_up. Don't use make_cleanup_free_agent_expr. * ax-gdb.h (gen_trace_for_expr, gen_trace_for_var) (gen_trace_for_return_address, gen_eval_for_expr, gen_printf): Use agent_expr_up. * ax-general.c (new_agent_expr): Rename to ... (agent_expr::agent_expr): ... this, and now a constructor. (free_agent_expr): Rename to ... (agent_expr::~agent_exp): ... this, and now a destructor. (do_free_agent_expr_cleanup, make_cleanup_free_agent_expr): Delete. * ax.h (struct agent_expr): Add ctor/dtor. (agent_expr_up): New typedef. (new_agent_expr, free_agent_expr, make_cleanup_free_agent_expr): Delete declarations. * breakpoint.c (parse_cond_to_aexpr): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (build_target_condition_list): Adjust to use agent_expr_up. (parse_cmd_to_aexpr): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (build_target_command_list): Adjust to use agent_expr_up. (force_breakpoint_reinsertion): Adjust to use agent_expr_up. (bp_location_dtor): Remove unnecessary free_agent_expr and xfree calls. * breakpoint.h (struct bp_target_info) <cond_bytecode, cmd_bytecode>: Now agent_expr_up's. * remote.c (remote_download_tracepoint): Adjust to use agent_expr_up and remove use of make_cleanup_free_agent_expr. * tracepoint.c (validate_actionline, collect_symbol): Adjust to use agent_expr_up and remove uses of make_cleanup_free_agent_expr. (collection_list::~collection_list): Call delete instead of free_agent_expr. (encode_actions_1): Adjust to use agent_expr_up and remove uses of make_cleanup_free_agent_expr. (add_aexpr): Change parameter type to agent_expr_up; Return a raw agent_expr pointer.
* Use ui_file_as_string throughout morePedro Alves2016-10-1730-614/+479
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces most of the remaining ui_file_xstrdup calls with ui_file_as_string calls. Whenever a call was replaced, that led to a cascade of other necessary adjustments throughout, to make the code use std::string instead of raw pointers. And then whenever I added a std::string as member of a struct, I needed to adjust allocation/destruction of said struct to use new/delete instead of xmalloc/xfree. The stopping point was once gdb built again. These doesn't seem to be a way to reasonably split this out further. Maybe-not-obvious changes: - demangle_for_lookup returns a cleanup today. To get rid of that, and avoid unnecessary string dupping/copying, this introduces a demangle_result_storage type that the caller instantiates and passes to demangle_for_lookup. - Many methods returned a "char *" to indicate that the caller owns the memory and must free it. Those are switched to return a std::string instead. Methods that return a "view" into some internal string return a "const char *" instead. I.e., we only copy/allocate when necessary. gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * ada-lang.c (ada_name_for_lookup, type_as_string): Use and return std::string. (type_as_string_and_cleanup): Delete. (ada_lookup_struct_elt_type): Use type_as_string. * ada-lang.h (ada_name_for_lookup): Now returns std::string. * ada-varobj.c (ada_varobj_scalar_image): Return a std::string. (ada_varobj_describe_child): Make 'child_name' and 'child_path_expr' parameters std::string pointers. (ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child): Likewise, and use string_printf. (ada_varobj_describe_simple_array_child) (ada_varobj_describe_child): Likewise. (ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child) (ada_varobj_get_value_image) (ada_varobj_get_value_of_array_variable) (ada_varobj_get_value_of_variable, ada_name_of_variable) (ada_name_of_child, ada_path_expr_of_child) (ada_value_of_variable): Now returns std::string. Use string_printf. (ada_value_of_child): Adjust. * break-catch-throw.c (check_status_exception_catchpoint): Adjust to use std::string. * breakpoint.c (watch_command_1): Adjust to use std::string. * c-lang.c (c_get_string): Adjust to use std::string. * c-typeprint.c (print_name_maybe_canonical): Use std::string. * c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string operators. (c_name_of_variable): Now returns a std::string. (c_describe_child): The 'cname' and 'cfull_expression' output parameters are now std::string pointers. Adjust. (c_name_of_child, c_path_expr_of_child, c_value_of_variable) (cplus_number_of_children): Adjust to use std::string and string_printf. (cplus_name_of_variable): Now returns a std::string. (cplus_describe_child): The 'cname' and 'cfull_expression' output parameters are now std::string pointers. Adjust. (cplus_name_of_child, cplus_path_expr_of_child) (cplus_value_of_variable): Now returns a std::string. * cp-abi.c (cplus_typename_from_type_info): Return std::string. * cp-abi.h (cplus_typename_from_type_info): Return std::string. (struct cp_abi_ops) <get_typename_from_type_info>: Return std::string. * cp-support.c (inspect_type): Use std::string. (cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs) (cp_canonicalize_string): Return std::string and adjust. * cp-support.h (cp_canonicalize_string) (cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full): Return std::string. * dbxread.c (read_dbx_symtab): Use std::string. * dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string. * gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string. * gnu-v3-abi.c (gnuv3_get_typeid): Use std::string. (gnuv3_get_typename_from_type_info): Return a std::string and adjust. (gnuv3_get_type_from_type_info): Adjust to use std::string. * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use std::string. * infcmd.c (print_return_value_1): Adjust to use std::string. * linespec.c (find_linespec_symbols): Adjust to demangle_for_lookup API change. Use std::string. * mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format) (mi_cmd_var_info_type, mi_cmd_var_info_path_expression) (mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression) (mi_cmd_var_assign, varobj_update_one): Adjust to use std::string. * minsyms.c (lookup_minimal_symbol): Use std::string. * python/py-varobj.c (py_varobj_iter_next): Use new instead of XNEW. vitem->name is a std::string now, adjust. * rust-exp.y (convert_ast_to_type, convert_name): Adjust to use std::string. * stabsread.c (define_symbol): Adjust to use std::string. * symtab.c (demangle_for_lookup): Now returns 'const char *'. Add a demangle_result_storage parameter. Use it for storage. (lookup_symbol_in_language) (lookup_symbol_in_objfile_from_linkage_name): Adjust to new demangle_for_lookup API. * symtab.h (struct demangle_result_storage): New type. (demangle_for_lookup): Now returns 'const char *'. Add a demangle_result_storage parameter. * typeprint.c (type_to_string): Return std::string and use ui_file_as_string. * value.h (type_to_string): Change return type to std::string. * varobj-iter.h (struct varobj_item) <name>: Now a std::string. (varobj_iter_delete): Use delete instead of xfree. * varobj.c (create_child): Return std::string instead of char * in output parameter. (name_of_variable, name_of_child, my_value_of_variable): Return std::string instead of char *. (varobj_create, varobj_get_handle): Constify 'objname' parameter. Adjust to std::string fields. (varobj_get_objname): Return a const char * instead of a char *. (varobj_get_expression): Return a std::string. (varobj_list_children): Adjust to use std::string. (varobj_get_type): Return a std::string. (varobj_get_path_expr): Return a const char * instead of a char *. Adjust to std::string fields. (varobj_get_formatted_value, varobj_get_value): Return a std::string. (varobj_set_value): Change type of 'expression' parameter to std::string. Use std::string. (install_new_value): Use std::string. (delete_variable_1): Adjust to use std::string. (create_child): Change the 'name' parameter to a std::string reference. Swap it into the new item's name. (create_child_with_value): Swap item's name into the new child's name. Use string_printf. (new_variable): Use new instead of XNEW. (free_variable): Don't xfree fields that are now std::string. (name_of_variable, name_of_child): Now returns std::string. (value_of_root): Adjust to use std::string. (my_value_of_variable, varobj_value_get_print_value): Return and use std::string. (varobj_value_get_print_value): Adjust to use ui_file_as_string and std::string. * varobj.h (struct varobj) <name, path_expr, obj_name, print_value>: Now std::string's. <name_of_variable, name_of_child, path_expr_of_child, value_of_variable>: Return std::string. (varobj_create, varobj_get_handle): Constify 'objname' parameter. (varobj_get_objname): Return a const char * instead of a char *. (varobj_get_expression, varobj_get_type): Return a std::string. (varobj_get_path_expr): Return a const char * instead of a char *. (varobj_get_formatted_value, varobj_get_value): Return a std::string. (varobj_set_value): Constify 'expression' parameter. (varobj_value_get_print_value): Return a std::string.
* Use ui_file_as_string in gdb/language.cPedro Alves2016-10-171-5/+2
| | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * language.c (add_language): Adjust to use std::string.
* Use ui_file_as_string in gdb/rust-lang.cPedro Alves2016-10-171-37/+20
| | | | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * rust-lang.c (struct disr_info) <name>: Now a std::string. (rust_get_disr_info): Use ui_file_as_string and adjust to use std::string. (rust_val_print): Adjust to use std::string.
* Use ui_file_as_string in gdb/infrun.cPedro Alves2016-10-171-4/+2
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * infrun.c (print_target_wait_results): Use ui_file_as_string and std::string.
* Use ui_file_as_string in gdb/ada-lang.cPedro Alves2016-10-171-25/+6
| | | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * ada-lang.c (type_as_string): Use ui_file_as_string and return std::string. (type_as_string_and_cleanup): Delete. (ada_lookup_struct_elt_type): Use type_as_string.
* Use ui_file_as_string in gdbarch.sh/gdbarch.cPedro Alves2016-10-172-10/+6
| | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * gdbarch.sh (verify_gdbarch): Use ui_file_as_string and std::string. * gdbarch.c: Regenerate.
* Use ui_file_as_string in gdb/c-exp.yPedro Alves2016-10-171-6/+3
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * c-exp.y (OPERATOR NEW): Adjust to use ui_file_as_string and std::string.
* Use ui_file_as_string in gdb/compile/Pedro Alves2016-10-174-51/+46
| | | | | | | | | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * c-lang.h (c_compute_program): Now returns std::string. * compile/compile-c-support.c (c_compute_program): Now returns a std::string. Use ui_file_as_string. * compile/compile.c (get_new_file_names): Change output parameters to std::string pointers. Use string_printf. (compile_to_object): Change output parameters to std::string pointers. Use ui_file_as_string. (eval_compile_command): Use std::string. * language.h (struct language_defn) <la_compute_program>: Now returns std::string.
* Use ui_file_as_string in cli/cli-setshow.cPedro Alves2016-10-171-4/+3
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * cli/cli-setshow.c (do_show_command): Adjust to use ui_file_as_string and std::string.
* Use ui_file_as_string in remote.cPedro Alves2016-10-171-38/+16
| | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * remote.c (escape_buffer): Use ui_file_as_string and return std::string. (putpkt_binary, read_frame): Adjust to use std::string.
* Use ui_file_as_string in gdb/python/Pedro Alves2016-10-176-31/+19
| | | | | | | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * python/py-arch.c (archpy_disassemble): Use ui_file_as_string and std::string. * python/py-breakpoint.c (bppy_get_commands): Use ui_file_as_string and std::string. * python/py-frame.c (frapy_str): Likewise. * python/py-type.c (typy_str): Likewise. * python/py-unwind.c (unwind_infopy_str): Likewise. * python/py-value.c (valpy_str): Likewise.
* Use ui_file_as_string in printcmd.cPedro Alves2016-10-171-4/+2
| | | | | | | | | | Yet another cleanup eliminated. gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * printcmd.c (eval_command): Use ui_file_as_string and std::string.
* Use ui_file_as_string in top.cPedro Alves2016-10-171-6/+3
| | | | | | | | | Yet another cleanup is eliminated. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * top.c (quit_confirm): Use ui_file_as_string and std::string.
* Use ui_file_as_string in execute_command_to_stringPedro Alves2016-10-174-29/+15
| | | | | | | | | | | | | | | | ... and then return std::string and adjust all callers. gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * gdbcmd.h (execute_command_to_string): Now returns std::string. (lookup_struct_elt_type): Adjust to use std::string. * top.c (execute_command_to_string): Use ui_file_as_string and return std::string. * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use std::string. * python/python.c (execute_gdb_command): Adjust to use std::string.
* Use ui_file_as_string in gdb/guile/Pedro Alves2016-10-175-52/+26
| | | | | | | | | | | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use ui_file_as_string and adjust to use std::string. * guile/scm-disasm.c (gdbscm_arch_disassemble): Likewise. * guile/scm-frame.c (frscm_print_frame_smob): Likewise. * guile/scm-type.c (tyscm_type_name): Use ui_file_as_string and adjust to use std::string. Throw exception directly instead of returning it in EXCP output parameter. (tyscm_print_type_smob, gdbscm_type_print_name): Adjust to tyscm_type_name interface change. * guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print): Use ui_file_as_string and std::string.
* Use ui_file_as_string in utils.cPedro Alves2016-10-171-3/+2
| | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * utils.c (error_stream): Use ui_file_as_string and std::string.
* Use ui_file_as_string in ui-out.cPedro Alves2016-10-171-6/+3
| | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * ui-out.c (ui_out_field_stream): Use ui_file_as_string.
* Use ui_file_as_string in ada-valprint.cPedro Alves2016-10-171-26/+27
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * ada-valprint.c (ada_print_floating): Use ui_file_as_string and std::string.
* Use ui_file_as_string in xtensa-tdep.cPedro Alves2016-10-171-6/+3
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * xtensa-tdep.c (xtensa_verify_config): Use ui_file_as_string and std::string.
* Use ui_file_as_string in dwarf2_compute_namePedro Alves2016-10-171-8/+5
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * dwarf2read.c (dwarf2_compute_name): Use ui_file_as_string and std::string.
* Use ui_file_as_string in arm-tdep.cPedro Alves2016-10-171-3/+3
| | | | | | | | gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * arm-tdep.c (_initialize_arm_tdep): Use ui_file_as_string and std::string.
* Clean up tracepoint.h/c:collection_listPedro Alves2016-10-173-261/+236
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Noticed we could do this while working on the expression_up change. The main goal here was getting rid of the encode_actions_and_make_cleanup / do_clear_collection_list cleanups. While at it, uncrustify the code: - Make collection_list a C++ class, with data members private (and thus renamed m_...). - Make related functions be member methods. - Use std::vector instead of an open coding a vector implementation. - Use std::sort instead of qsort. - Rename the "list" member of collection_list, which is an incredibly obfuscating name. - Rename a couple other things here and there for clarify. - Use "bool" more. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * mi/mi-main.c (print_variable_or_computed): Constify 'expression' parameter. (mi_cmd_trace_frame_collected): Call encode_actions instead of encode_actions_and_make_cleanup. Adjust to use std::vector. * tracepoint.c (memrange_cmp): Delete. (memrange_comp): New. (memrange_sortmerge): Take a memrange vector as parameter instead of a collection_list. Use std::sort instead of qsort. (add_register): Now a method of collection_list. Adjust to m_ prefix of data fields. (add_memrange): Now a method of collection_list. Adjust to m_ prefix of data fields. Adjust to use std::vector. (collect_symbol): Now a method of collection_list. Adjust to m_ prefix of data fields. (do_collect_symbol): Adjust. Call add_wholly_collected instead of accessing the vector directly. (collection_list::add_wholly_collected): New. (add_local_symbols): Now a method of collection_list. (add_static_trace_data): Now a method of collection_list. Adjust to use bool. (clear_collection_list, do_clear_collection_list): Delete. (init_collection_list): Delete. (collection_list::collection_list): New. (collection_list::~collection_list): New. (stringify_collection_list): Rename to ... (collection_list::stringify): ... this and adjust to being a method of collection_list. Adjust to use of std::vector. (append_exp): Now a method of collection_list. Use ui_file_as_string. Adjust to std::vector. (collection_list::finish): New. (encode_actions_1): Adjust. (encode_actions_and_make_cleanup): Rename to ... (encode_actions)... this. No longer returns a cleanup. No longer call init_collection_list nor install do_clear_collection_list cleanups. Call collection_list::finish instead of memrange_sortmerge directly. (encode_actions_rsp): Adjust to call encode_actions instead of encode_actions_and_make_cleanup. Adjust to method renames. (add_aexpr): Now a method of collection_list. * tracepoint.h: Include <vector> and <string>. (struct memrange): Add constructors. (struct collection_list): Now a class. (class collection_list) <collection_list, ~collection_list, add_wholly_collected, append_exp, add_aexpr, add_register, add_memrange, collect_symbol, add_local_symbols, add_static_trace_data, finish, stringify, wholly_collected, and computed>: New methods. <regs_mask>: Rename to ... <m_regs_mask>: ... this. <listsize, next_memrange, list>: Delete fields. <m_memranges>: New field. <aexpr_listsize, next_aexpr_elt, aexpr_list>: Delete fields. <m_aexprs>: New field. <strace_data>: Rename to ... <m_strace_data>: ... this. Now a bool. <wholly_collected>: Rename to ... <m_wholly_collected>: ... this. Now a std::vector<std::string>. <computed>: Rename to ... <m_computed>: ... this. Now a std::vector<std::string>. (encode_actions_and_make_cleanup): Delete declaration. (encode_actions): New declaration.
* Introduce ui_file_as_stringPedro Alves2016-10-172-0/+26
| | | | | | | | | | | | | | | | | | ui_file_as_string is a variant of ui_file_xstrdup that returns a std::string instead of a xmalloc'ed char *. The idea is using the new function to eliminate "make_cleanup (xfree, ...)" cleanups throughout. Following patches will make use of this. gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * ui-file.c (ui_file_xstrdup): Return gdb::unique_xmalloc_ptr<char> instead of char *. (do_ui_file_as_string, ui_file_as_string): New functions. * ui-file.h: Include <string>. (ui_file_as_string): New declaration.
* 'struct parse_expression *' -> gdb::unique_ptr<expression>Pedro Alves2016-10-1722-309/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes parse_expression and friends return a unique_ptr instead of raw pointer [1]: typedef gdb::unique_malloc_ptr<expression> expression_up; and then adjusts the codebase throughout to stop using cleanups to manage lifetime of expression pointers. Whenever I found a structure storing an expression pointer, I made it store a unique_ptr instead, which then requires using new/delete of the holding structure, instead of XNEW/xfree. [1] - I'd like to set the rule that types named with an "_up" suffix are unique_ptr typedefs. Note I used gdb::unique_xmalloc_ptr instead of gdb::unique_ptr as the subject suggests, simply because we still use xmalloc instead of new to allocate expression objects. Once that's changed, all we need to do is change the expression_up typedef and the smart pointer will then call delete instead of xfree. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * ada-lang.c (ada_read_renaming_var_value): Use expression_up. (struct ada_catchpoint_location) <excep_cond_expr>: Now an expression_up. (ada_catchpoint_location_dtor): Reset excep_cond_expr instead of using xfree. (create_excep_cond_exprs): Use expression_up and gdb::move. (allocate_location_exception): Use new instead of XNEW. (should_stop_exception): Likewise. Adjust to use expression_up. (create_ada_exception_catchpoint): Use new instead of XNEW. * ax-gdb.c (agent_eval_command_one): Use expression_up instead of cleanups. (maint_agent_printf_command): Use expression_up. * break-catch-sig.c (create_signal_catchpoint): Use new instead of XNEW. * break-catch-syscall.c (create_syscall_event_catchpoint): Likewise. * break-catch-throw.c (handle_gnu_v3_exceptions): Use new instead of XCNEW. Use gdb::unique_ptr instead of cleanups. * breakpoint.c (set_breakpoint_condition, update_watchpoint) (parse_cmd_to_aexpr, watchpoint_check) (bpstat_check_breakpoint_conditions, watchpoint_locations_match): Adjust to use expression_up. (init_bp_location): Adjust. (free_bp_location): Use delete instead of xfree. (set_raw_breakpoint_without_location, set_raw_breakpoint) (add_solib_catchpoint, create_fork_vfork_event_catchpoint) (new_single_step_breakpoint, create_breakpoint_sal): Use new instead of XNEW. (find_condition_and_thread): Adjust to use expression_up. (create_breakpoint): Use new instead of XNEW. (dtor_watchpoint): Don't xfree expression pointers, they're unique_ptr's now. (insert_watchpoint, remove_watchpoint): Adjust. (watch_command_1): Use expression_up. Use new instead of XCNEW. (catch_exec_command_1): Use new instead of XNEW. (bp_location_dtor): Don't xfree expression pointers, they're unique_ptr's now. (base_breakpoint_allocate_location) (strace_marker_create_breakpoints_sal): Use new instead of XNEW. (delete_breakpoint): Use delete instead of xfree. * breakpoint.h (struct bp_location) <cond>: Now an unique_ptr<expression> instead of a raw pointer. (struct watchpoint) <exp, cond_exp>: Likewise. * cli/cli-script.c (execute_control_command): Use expression_up instead of cleanups. * dtrace-probe.c (dtrace_process_dof_probe): Use expression_up. * eval.c (parse_and_eval_address, parse_and_eval_long) (parse_and_eval, parse_to_comma_and_eval, parse_and_eval_type): Use expression_up instead of cleanups. * expression.h (expression_up): New typedef. (parse_expression, parse_expression_with_language, parse_exp_1): Change return type to expression_up. * mi/mi-main.c (mi_cmd_data_evaluate_expression) (print_variable_or_computed): Use expression_up. * objc-lang.c (print_object_command): Use expression_up instead of cleanups. * parse.c (parse_exp_1, parse_exp_in_context) (parse_exp_in_context_1, parse_expression) (parse_expression_with_language): Return an expression_up instead of a raw pointer. (parse_expression_for_completion): Use expression_up. * printcmd.c (struct display) <exp>: Now an expression_up instead of a raw pointer. (print_command_1, output_command_const, set_command, x_command): Use expression_up instead of cleanups. (display_command): Likewise. Use new instead of XNEW. (free_display): Use delete instead of xfree. (do_one_display): Adjust to use expression_up. * remote.c (remote_download_tracepoint): Likewise. * stack.c (return_command): Likewise. * tracepoint.c (validate_actionline, encode_actions_1): Use expression_up instead of cleanups. * typeprint.c (whatis_exp, maintenance_print_type): Likewise. * value.c (init_if_undefined_command): Likewise. * varobj.c (struct varobj_root) <exp>: Now an expression_up instead of a raw pointer. (varobj_create): Adjust. (varobj_set_value): Use an expression_up instead of cleanups. (new_root_variable): Use new instead of XNEW. (free_variable): Use delete instead of xfree. (value_of_root_1): Use std::swap.
* cli-script.c: Simplify using std::string, eliminate cleanupsPedro Alves2016-10-171-77/+33
| | | | | | | | | | | gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * cli/cli-script.c (execute_control_command): Use std::string instead of cleanups. (locate_arg): Constify return type. (insert_args): Constify paremeter. Simplify using std::string. Return a std::string.
* breakpoint.c:commands_command_1 constification and cleanupPedro Alves2016-10-172-26/+18
| | | | | | | | | | | | | | | | | | | | | This is constification needed for next patch. Adjust commands_command_1 to use std::string too because the "arg" parameter is currently overwritten and then passed to make_cleanup. The constification alone would trigger a compile error in the make_cleanup call otherwise (passing const char * to void * parameter). Using std::string gets rid of the cleanup in the first place, resulting in simpler code. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * breakpoint.c (struct commands_info) <arg>: Constify. (commands_command_1): Constify 'arg' parameter. Use std::string and string_printf. (commands_from_control_command): Constify 'arg' parameter. (map_breakpoint_numbers): Constify 'args' parameter. * breakpoint.h (commands_from_control_command): Constify 'arg' parameter.
* cli/cli-script.c: Remove some dead NULL checksPedro Alves2016-10-171-10/+0
| | | | | | | | | gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * cli/cli-script.c (execute_control_command): Assume insert_args never returns NULL. (insert_args): Assume xmalloc never returns NULL.
* Introduce string_printfPedro Alves2016-10-172-0/+36
| | | | | | | | | | | | This introduces the string_printf function. Like asprintf, but returns a std::string. gdb/ChangeLog: yyyy-mm-yy Pedro Alves <palves@redhat.com> * common/common-utils.c (string_printf): New function. * common/common-utils.h: Include <string>. (string_printf): Declare.
* Introduce gdb::unique_ptrPedro Alves2016-10-172-0/+363
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New in v4: - implict construction from NULL allowed too now, for: gdb::unique_ptr<foo> func (....) { return NULL; } - Rename unique_malloc_ptr to unique_xmalloc_ptr. New in v3: - Comment typos fixed. Detail things moved to detail namespace. New in v2: - considering a move to C++11, it no longer makes much sense to add a base class just for the one instance of the safe bool idiom. That's now inlined into unique_ptr directly. - added missing </<=/>/>= comparison operators. - simplified the implementation even further, by removing the "ref" class, and adding converting contructors instead. This actually fixes this use case: unique_ptr<Derived> func_returning_unique_ptr (.....); ... unique_ptr<Base> ptr = func_returning_unique_ptr (.....); Looks like GCC's std::auto_ptr is buggy in that respect, because that doesn't actually work with std::auto_ptr, despite the comments indicating otherwise, and I was copying the comment/bug. - comments updated/rewritten throughout, including the git commit log, to hopefully clarify things. I think that the code looks clearer and less "magic" now. I'd like to get this in soon to unblock Tromey's C++ series, and more. We can move along with the C++11 discussion / plan in parallel. Any objections? I'll be more than happy to remove this when we finally make C++11 a requirement. But I don't want to rush that. We should make sure that the buildbot's buildslaves are ready, for example. ~~~ Many make_cleanup uses in the code base are best eliminated by using a "owning" smart pointer to manage ownership of the resource automatically. The question is _which_ smart pointer. GDB currently supports building with a C++03 compiler. We have std::auto_ptr in C++03, but, as is collective wisdom by now, that's too easy to misuse, and has therefore been deprecated in C++11 and finally removed in C++17. It'd be nice to be able to use std::unique_ptr instead, which is the modern, safe std::auto_ptr replacement in C++11. In addition to extra safety -- moving (i.e., transfer of ownership of the managed pointer between smart pointers) must be explicit -- std::unique_ptr has (among others) one nice feature that std::auto_ptr doesn't --- ability to specify a custom deleter as template parameter. In gdb's context, that allows easily creating a smart pointer for memory allocated with xmalloc -- the smart pointer then knows to release with xfree instead of delete. This is particularly interesting when managing objects allocated in C libraries, and also, for C++-fying parts of GDB that interact with other parts that still return objects allocated with xmalloc. Since std::unique_ptr's API is quite nice, and eventually we'd like to move to C++11, this patch adds a C++03-compatible smart pointer that exposes the subset of the std::unique_ptr API that we're interested in. An advantage is that whenever we start requiring C++11, we won't have to learn a new API. Meanwhile, this allows continuing to support building with a C++03 compiler. Since C++03 doesn't support rvalue references (boost gets close to emulating them, but it's not fully transparent to user code), the C++03 std::unique_ptr emulation here doesn't try hard to prevent accidentally moving, which is where most of complication of a more thorough emulation would be. Instead, we rely on the fact that GDB will be usually compiled with a C++11 compiler, and use the real std::unique_ptr in that case to catch such accidental moves. IOW, the goal here is to allow code that would be correct using std::unique_ptr to be equally correct in C++03 mode, and, just as efficient. The C++03 version was originally based on GCC 7.0's std::auto_ptr and then heavily customized to behave more like C++11's std::unique_ptr: - Support for custom (stateless) deleters. (Support for stateful deleters could be added, if necessary.) - unique_ptr<T[]> partial specialization (auto_ptr<T> does not know to use delete[]). - Support for all of 'ptr != NULL', 'ptr == NULL' and 'if (ptr)' using the safe bool idiom. - Assignment from NULL. - Allow using all of 'ptr != NULL', 'ptr == NULL' and 'if (ptr)' using the safe bool idiom to emulate C++11's explicit bool conversion. - Variable names un-uglified (ie., no leading __ prefix everywhere). - Formatting made to follow GDB's coding conventions, including comment style. - Initialization and assignment from NULL (std::unique_ptr allows "ptr = nullptr" instead, while std::auto_ptr allows neither.) - Converting "move" constructors done differently in order to truly support: unique_ptr<Derived> func_returning_unique_ptr (.....); ... unique_ptr<Base> ptr = func_returning_unique_ptr (.....); At this point, it no longer shares much at all with the original file, but, that's the history. See comments in the code to find out more. I thought of putting the "emulation" / shim in the "std" namespace, so that when we start requiring C++11 at some point, no actual changes to users of the smart pointer throughout would be necessary. Putting things in the std namespace is technically undefined, however in practice it doesn't cause any issue with any compiler. However, thinking that people might be confused with seeing std::unique_ptr and thinking that we're actually requiring C++11 already, I put the new types in the "gdb" namespace instead. For managing xmalloc pointers, this adds a gdb::unique_xmalloc_ptr<T> "specialization" with a custom xfree deleter. No actual use of any smart pointer is introduced in this patch. That'll be done in following patches. Tested (along with the rest of the series) on: - NetBSD 5.1 (gcc70 on the compile farm), w/ gcc 4.1.3 - x86-64 Fedora 23, gcc 5.3.1 (gnu++03) - x86-64 Fedora 23, and gcc 7.0 (gnu++14) gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * common/common-defs.h: Include "gdb_unique_ptr.h". * common/gdb_unique_ptr.h: New.
* Update list of ELF machine numbers.Nick Clifton2016-10-174-11/+101
| | | | | | | | | | | | | | | | | | | | | include * elf/common.h (DT_SYMTAB_SHNDX): Define. (EM_CLOUDSHIELD, EM_COREA_1ST, EM_COREA_2ND, EM_OPEN8): Define. (EM_VIDEOCORE5, EM_56800EX, EM_BA1, EM_BA2, EM_XCORE): Define. (EM_MCHP_PIC, EM_KM32, EM_KMX32, EM_KMX16, EM_KMX8): Define. (EM_KVARC, EM_CDP, EM_COGE, EM_COOL, EM_NORC): Define. (EM_CSR_KALIMBA, EM_Z80, EM_AMDGPU, EM_RISCV): Define. (ELFOSABI_OPENVOS): Define. (GRP_MASKOS, GRP_MASKPROC): Define. binutils * readelf.c (get_dynamic_type): Add DT_SYMTAB_SHNDX. (get_machine_type): Add EM_CLOUDSHIELD, EM_COREA_1ST, EM_COREA_2ND, EM_OPEN8, EM_VIDEOCORE5, EM_56800EX, EM_BA1, EM_BA2, EM_XCORE, EM_MCHP_PIC, EM_KM32, EM_KMX32, EM_KMX16, EM_KMX8, EM_KVARC, EM_CDP, EM_COGE, EM_COOL, EM_NORC, EM_CSR_KALIMBA, EM_Z80, EM_AMDGPU, EM_RISCV. (get_osabi_name): Add ELFOSABI_CLOUDABI and ELFOSABI_OPENVS. (get_group_flags): Update to handle flags in the GRP_MASKOS and GRP_MASKPROC ranges.
* Sync libiberty sources with gcc mainline.Nick Clifton2016-10-175-31/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2016-09-19 Andrew Stubbs <ams@codesourcery.com> * pex-win32.c (argv_to_cmdline): Quote zero-length parameters. * testsuite/test-pexecute.c (main): Insert check for zero-length parameters. 2016-09-10 Mark Wielaard <mjw@redhat.com> * cp-demangle.c (d_substitution): Change struct demangle_component variable name from c to dc. 2016-08-12 Marek Polacek <polacek@redhat.com> PR c/7652 * cp-demangle.c (d_print_mod): Add FALLTHRU. 2016-08-04 Marcel B?hme <boehme.marcel@gmail.com> PR c++/71696 * cplus-dem.c: Prevent infinite recursion when there is a cycle in the referencing of remembered mangled types. (work_stuff): New stack to keep track of the remembered mangled types that are currently being processed. (push_processed_type): New method to push currently processed remembered type onto the stack. (pop_processed_type): New method to pop currently processed remembered type from the stack. (work_stuff_copy_to_from): Copy values of new variables. (delete_non_B_K_work_stuff): Free stack memory. (demangle_args): Push/Pop currently processed remembered type. (do_type): Do not demangle a cyclic reference and push/pop referenced remembered type.
* Automatic date update in version.inGDB Administrator2016-10-171-1/+1
|
* Automatic date update in version.inGDB Administrator2016-10-161-1/+1
|
* Regenerate spu_ovl.o_cAlan Modra2016-10-152-53/+57
| | | | | | | No real changes here. This is just so that we match current spu_ovl.o with .shstrtab moved. * emultempl/spu_ovl.o_c: Regenerate.
* Automatic date update in version.inGDB Administrator2016-10-151-1/+1
|
* FINAL/OVERRIDE: Define to empty on g++ < 4.7Pedro Alves2016-10-142-5/+24
| | | | | | | | | | | | | | final/override were only implemented in g++ 4.7. include/ChangeLog 2016-10-14 Pedro Alves <palves@redhat.com> * ansidecl.h [__cplusplus >= 201103 && GCC_VERSION < 4007] (FINAL, OVERRIDE): Define as empty. [__cplusplus < 201103 && GCC_VERSION < 4007] (FINAL): Define as __final. [__cplusplus < 201103 && GCC_VERSION >= 4007] (OVERRIDE): Define as empty.
* Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.hPedro Alves2016-10-142-6/+27
| | | | | | | | | | | | | | | | | | So that GDB and other projects that share the top level can use them. Bootstrapped with all default languages + jit on x86-64 Fedora 23. gcc/ChangeLog: 2016-10-14 Pedro Alves <palves@redhat.com> * coretypes.h (OVERRIDE, FINAL): Delete, moved to include/ansidecl.h. include/ChangeLog: 2016-10-14 Pedro Alves <palves@redhat.com> * ansidecl.h (GCC_FINAL): Delete. (OVERRIDE, FINAL): New, moved from gcc/coretypes.h.
* Fix typos in trace commands docSimon Marchi2016-10-142-2/+7
| | | | | | | gdb/doc/ChangeLog: * gdb.texinfo (Using Trace Files): Fix typo. (GDB/MI Tracepoint Commands): Likewise.
* Document -ctf switch of -trace-saveSimon Marchi2016-10-142-1/+10
| | | | | | | | | | The -trace-save MI command supports saving the trace in the CTF format, as its CLI counterpart, but it's not documented. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Tracepoint Commands): Document -ctf switch of -trace-save.
* Fix leftover remote test failures from PR binutils/19020Luis Machado2016-10-142-1/+7
| | | | | | | | | | | | | | | | | As pointed out in PR binutils/19020, those tests were still failing when doing remote testing. This is because the binary files weren't being copied over to the remote host for testing. FAIL: binutils-all/pr19020a FAIL: binutils-all/pr19020b This small patch fixes this up to make things pass. binutils/ChangeLog: 2016-10-14 Luis Machado <lgustavo@codesourcery.com> * testsuite/lib/utils-lib.exp (run_dump_test): Call remote_download to copy file to remote host.
* Fix set sysroot command on AIXUlrich Weigand2016-10-142-6/+22
| | | | | | | | | | | | | | | | set sysroot command on AIX has no effect if a program depends on shared library archives (.a). Fixed by using solib_find and solib_bfd_fopen instead of gdb_bfd_open in solib_aix_bfd_open. gdb/ 2016-10-14 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com> Ulrich Weigand <uweigand@de.ibm.com> * solib-aix.c (solib_aix_bfd_open): Call solib_find so that sysroot path is set properly if program has a dependency on .a archive and sysroot is set via set sysroot command. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
* Add separate debug info file sectionAlan Modra2016-10-142-0/+5
| | | | * scripttempl/DWARF.sc: Add .debug_addr.
* [ARC] Disassembler: fix LIMM detection for short instructions.Claudiu Zissulescu2016-10-149-2/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ARC (short) instructions are using a special register number to indicate is the instruction uses a long immediate (LIMM). In the case of short instruction, this LIMM indicator depends on the ISA version used. Thus, for ARCv1 processors, the LIMM indicator is 0x3E, the same value used in "long" instructions. However, for the ARCv2 processors, this LIMM indicator is 0x1E. This patch fixes the LIMM detection for ARCv1 ISA and adds two tests. gas/ 2016-10-13 Claudiu Zissulescu <claziss@synopsys.com> * testsuite/gas/arc/shortlimm_a7.d: New file. * testsuite/gas/arc/shortlimm_a7.s: Likewise. * testsuite/gas/arc/shortlimm_hs.d: Likewise. * testsuite/gas/arc/shortlimm_hs.s: Likewise. include/ 2016-10-13 Claudiu Zissulescu <claziss@synopsys.com> * opcode/arc.h (ARC_OPCODE_ARCV2): New define. opcodes/ 2016-10-13 Claudiu Zissulescu <claziss@synopsys.com> * arc-dis.c (find_format_from_table): Discriminate LIMM indicator usage on ISA basis.
* btrace: remove leftover commentMarkus Metzger2016-10-142-5/+4
| | | | | Remove a leftover comment on a function that was removed with commit 0568462bbf0f666d5bf9f720e16147da71eec46a.
* Include strings.h where availableEli Zaretskii2016-10-142-0/+8
| | | | | | | | | gdb/ChangeLog 2016-10-14 Eli Zaretskii <eliz@gnu.org> * common/common-defs.h [HAVE_STRINGS_H]: Include strings.h if available, to get prototypes of 'strcasecmp' and 'strncasecmp'.
* Automatic date update in version.inGDB Administrator2016-10-141-1/+1
|
* ARI: Remove true/false checksPedro Alves2016-10-132-21/+6
| | | | | | | | | These don't make sense with C++. gdb/ChangeLog: 2016-10-13 Pedro Alves <palves@redhat.com> * contrib/ari/gdb_ari.sh (boolean): Suggest bool instead. (false, true): Remove checks.