aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2018-09-18[OBVIOUS] ChangeLog for obvious enable frame-filter help fix.Philippe Waroquiers1-0/+5
ChangeLog for 62b1765c90ddce54c04a97caac86425d50f2cc56
2018-09-18[OBVIOUS] enable frame-filter short help uses disable instead of enablePhilippe Waroquiers1-1/+1
Without the patch: (gdb) apropos able frame-filter disable frame-filter -- GDB command to disable the specified frame-filter enable frame-filter -- GDB command to disable the specified frame-filter With the patch: (gdb) apropos able frame-filter disable frame-filter -- GDB command to disable the specified frame-filter enable frame-filter -- GDB command to enable the specified frame-filter Pushed as obvious
2018-09-17Do not pass -DNDEBUG to Python compilations in development modeTom Tromey3-2/+16
The Python CFLAGS include -DNDEBUG. This was apparently done intentionally -- setting the flags is done manually because, according to a comment, python-config passes too many things to the compiler (which is true). Per PR python/20445, this patch changes configure so that -DNDEBUG is only used by release builds. This probably doesn't have very much effect in practice, but I did see that some Python headers use assert, so perhaps it will give some safety. Tested by rebuilding and re-running gdb.python/*.exp on x86-64 Fedora 28. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> PR python/20445: * configure: Rebuild. * configure.ac: Conditionally use -DNDEBUG for Python.
2018-09-17Check for gmp when checking for mpfrTom Tromey3-2/+8
There was a report on irc that the gdb check for mpfr failed when only static libraries are available. The issue is that mpfr depends on gmp, but this is not handled explicitly by gdb. Ideally upstream would switch to pkg-config. Or even more ideally, we would incorporate pkg-config into the compiler and not mess with any of this. Meanwhile, this changes gdb's configure to add gmp to the link line when checking for mpfr. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Use gmp as a library dependency when checking for mpfr.
2018-09-17[gdb/Python] Eliminate find_inferior_objectPedro Alves2-14/+4
Commit 00431a78b28f ("Use thread_info and inferior pointers more throughout") removed the declaration of find_inferior_object, but missed removing the definition. gdb/ChangeLog: 2018-09-17 Pedro Alves <palves@redhat.com> * python/py-inferior.c (find_inferior_object): Delete.
2018-09-17Fix use-after-move in compile/compile-cplus-types.cSimon Marchi2-2/+8
Patch d82b3862f12 ("compile: Remove non-const reference parameters") introduced a regression in compile/compile-cplus-types.c. The new_scope variable in compile_cplus_instance::enter_scope is used after it was std::moved. This patch fixes it by referring to the back of the vector where it was moved instead. gdb/ChangeLog: * compile/compile-cplus-types.c (compile_cplus_instance::enter_scope): Don't use new_scope after std::move.
2018-09-17Update get_standard_cache_dir for macOSTom Tromey5-8/+35
On macOS the usual cache directory is ~/Library/Caches. This patch changes get_standard_cache_dir to use that instead of XDG. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * common/pathstuff.c (get_standard_cache_dir): Use ~/Library/Caches on macOS. * common/pathstuff.h (get_standard_cache_dir): Update comment. gdb/doc/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * gdb.texinfo (Index Files): Update for cache directory change on macOS.
2018-09-17python: Make gdb.execute("show commands") work (PR 23669)Simon Marchi14-36/+98
Since commit 56bcdbea2bed ("Let gdb.execute handle multi-line commands") trying to use a command like gdb.execute("show commands") in Python fails. GDB ends up trying to run the "commands" command. The reason is that GDB gets confused with the special "commands" command. In process_next_line, the lookup_cmd_1 function returns the cmd_list_element representing the "commands" sub-command of "show". Lower, we check the cmd_list_element to see if it matches various control commands by name, including the "commands" command. This is where we wrongfully conclude that the executed command must be "commands", when in reality it was "show commands". The fix proposed in this patch removes the comparisons by name, instead comparing the cmd_list_element object by pointer with the objects created at initialization time. Tested on the buildbot, though on a single builder (Fedora-x86_64-m64). gdb/ChangeLog: PR python/23669 * breakpoint.c (commands_cmd_element): New. (_initialize_breakpoint): Assign commands_cmd_element. * breakpoint.h (commands_cmd_element): New. * cli/cli-script.c (while_cmd_element, if_command, define_cmd_element): New. (command_name_equals): Remove. (process_next_line): Compare commands by pointer, not by name. (_initialize_cli_script): Assign the various cmd_list_element variables. * compile/compile.c (compile_cmd_element): New. (_initialize_compile): Assign compile_cmd_element. * compile/compile.h (compile_cmd_element): New. * guile/guile.c (guile_cmd_element): New. (install_gdb_commands): Assign guile_cmd_element. * guile/guile.h (guile_cmd_element): New. * python/python.c (python_cmd_element): New. (_initialize_python): Assign python_cmd_element. * python/python.h (python_cmd_element): New. * tracepoint.c (while_stepping_cmd_element): New. (_initialize_tracepoint): Assign while_stepping_cmd_element. * tracepoint.h (while_stepping_cmd_element): New. gdb/testsuite/ChangeLog: PR python/23669 * gdb.python/python.exp: Test gdb.execute("show commands").
2018-09-17Make save_infcall_*_state return unique pointersTom Tromey3-10/+19
Simon pointed out that save_infcall_suspend_state and save_infcall_control_state could return unique pointers. This patch implements this idea. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * infrun.c (save_infcall_suspend_state): Return infcall_suspend_state_up. (save_infcall_control_state): Return infcall_control_state_up. * inferior.h (save_infcall_suspend_state) (save_infcall_control_state): Declare later. Return unique pointers.
2018-09-17Remove release_stop_context_cleanupTom Tromey2-41/+44
This removes release_stop_context_cleanup, replacing it with a stop_context destructor. It also mildly c++-ifies this struct. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * infrun.c (struct stop_context): Declare constructor, destructor, "changed" method. (stop_context::stop_context): Rename from save_stop_context. (stop_context::~stop_context): Rename from release_stop_context_cleanup. (normal_stop): Update. (stop_context::changed): Rename from stop_context_changed. Return bool.
2018-09-17Remove two infrun cleanupsTom Tromey4-55/+55
This removes a couple of cleanups from infrun by introducing a couple of unique_ptr specializations. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * inferior.h (struct infcall_suspend_state_deleter): New. (infcall_suspend_state_up): New typedef. (struct infcall_control_state_deleter): New. (infcall_control_state_up): New typedef. (make_cleanup_restore_infcall_suspend_state) (make_cleanup_restore_infcall_control_state): Don't declare. * infcall.c (call_function_by_hand_dummy): Update. * infrun.c (do_restore_infcall_suspend_state_cleanup) (make_cleanup_restore_infcall_suspend_state): Remove. (do_restore_infcall_control_state_cleanup) (make_cleanup_restore_infcall_control_state): Remove.
2018-09-17Use new and delete for struct infcall_control_stateTom Tromey5-26/+47
This changes infrun.c to use new and delete for infcall_control_state. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * gdbthread.h (struct thread_control_state): Add initializer. (class thread_info) <control>: Remove initializer. * inferior.h (struct inferior_control_state): Add initializer. (class inferior) <control>: Remove initializer. (exit_inferior_1): Update. * infrun.c (struct infcall_control_state): Add constructors. (save_infcall_control_state): Use new. (restore_infcall_control_state, discard_infcall_control_state): Use delete.
2018-09-17Remove cleanup from infrun.cTom Tromey2-18/+20
This removes a cleanup from infrun.c by taking advantage of the previous patch to introduce a use of unique_xmalloc_ptr. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * infrun.c (struct infcall_suspend_state) <registers>: Now a unique_ptr. <siginfo_data>: Now a unique_xmalloc_ptr. (save_infcall_suspend_state, restore_infcall_suspend_state) (discard_infcall_suspend_state) (get_infcall_suspend_state_regcache): Update.
2018-09-17Use new and delete for struct infcall_suspend_stateTom Tromey3-11/+19
This changes infrun.c to use new and delete for infcall_suspend_state. This enables the coming cleanups. gdb/ChangeLog 2018-09-17 Tom Tromey <tom@tromey.com> * gdbthread.h (struct thread_suspend_state): Add initializers. (class thread_info) <suspend>: Remove initializer. * infrun.c (struct infcall_suspend_state): Add initializers. (save_infcall_suspend_state): Use new. (discard_infcall_suspend_state): Use delete.
2018-09-16Don't steal references in the gdb Python codeTom Tromey3-16/+17
Some Python APIs steal references from their caller, and the refcount checker supports this via an attribute. However, in gdb with C++ we have a better idiom available: we can use std::move on a gdbpy_ref<> instead. This makes the semantics obvious at the point of call, and is safer at runtime as well, because the callee's gdbpy_ref<> will be emptied. This patch changes the reference-stealing code in gdb to use rvalue references instead. Tested on x86-64 Fedora 28. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/python-internal.h (CPYCHECKER_STEALS_REFERENCE_TO_ARG): Remove. * python/py-varobj.c (py_varobj_iter_ctor): Change pyiter to rvalue reference. Remove CPYCHECKER_STEALS_REFERENCE_TO_ARG. (py_varobj_iter_new): Likewise. (py_varobj_get_iterator): Use gdbpy_ref.
2018-09-16Simplify uses of thread_to_thread_objectTom Tromey3-17/+14
An review by Simon of an earlier showed a few spots related to thread_to_thread_object that could be simplified. This also detected a latent bug, where thread_to_thread_object was inconsistent about setting the Python exception before a NULL return. Tested on x86-64 Fedora 28. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/py-threadevent.c (py_get_event_thread): Simplify. * python/py-inferior.c (infpy_thread_from_thread_handle): Return immediately after calling thread_to_thread_object. Use Py_RETURN_NONE. (thread_to_thread_object): Set the exception on a NULL return.
2018-09-16Sort objects in gdb and gdbserver MakefilesSimon Marchi4-4/+14
Tom mentioned this a while ago, as a way to give you a cheap sense of progression in your build, as all object files will be built alphabetically (including the directory part). I tried it and I think it's nice. gdb/ChangeLog: * Makefile.in (LIBGDB_OBS): Sort COMMON_OBS. gdb/gdbserver/ChangeLog: * Makefile.in (gdbserver$(EXEEXT)): Sort OBS. (gdbreplay$(EXEEXT)): Sort GDBREPLAY_OBS. ($(IPA_LIB)): Sort IPA_OBJS.
2018-09-16gdbserver/Makefile.in: Remove ADD_DEPSSimon Marchi2-2/+6
ADD_DEPS is defined nowhere, so I presume it's not useful. If I'm wrong and this is actually used, there should be a comment explaining where it comes from. gdb/gdbserver/ChangeLog: * Makefile.in: Remove references to $(ADD_DEPS).
2018-09-16Remove CPYCHECKER_RETURNS_BORROWED_REFTom Tromey2-8/+8
CPYCHECKER_RETURNS_BORROWED_REF is not used, and I think should never be used. This patch removes it. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/python-internal.h (CPYCHECKER_RETURNS_BORROWED_REF): Remove.
2018-09-16Change thread_to_thread_object to return a new referenceTom Tromey8-47/+50
This changes thread_to_thread_object to return a new reference and fixes up all the callers. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/python-internal.h (thread_to_thread_object): Change return type. * python/py-inferior.c (thread_to_thread_object): Return a new reference. (infpy_thread_from_thread_handle): Update. * python/py-infthread.c (gdbpy_selected_thread): Update. * python/py-stopevent.c (create_stop_event_object): Update. * python/py-threadevent.c (py_get_event_thread): Return a new reference. (py_get_event_thread): Update. * python/py-event.h (py_get_event_thread): Change return type. * python/py-continueevent.c (create_continue_event_object): Update.
2018-09-16Change objfile_to_objfile_object to return a new referenceTom Tromey9-51/+51
This changes objfile_to_objfile_object to return a new references and fixes up all the uses. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/py-progspace.c (pspy_get_objfiles): Update. * python/python-internal.h (objfile_to_objfile_object): Change return type. * python/py-newobjfileevent.c (create_new_objfile_event_object): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/python.c (gdbpy_get_current_objfile): Update. (gdbpy_objfiles): Update. * python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile): Update. (objfile_to_objfile_object): Return a new reference. * python/py-symtab.c (stpy_get_objfile): Update. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Update.
2018-09-16Change pspace_to_pspace_object to return a new referenceTom Tromey9-39/+47
This changes pspace_to_pspace_object to return a new reference and fixes up all the callers. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/py-inferior.c (infpy_get_progspace): Update. * python/python-internal.h (pspace_to_pspace_object): Change return type. * python/py-newobjfileevent.c (create_clear_objfiles_event_object): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/python.c (gdbpy_get_current_progspace): Update. (gdbpy_progspaces): Update. * python/py-progspace.c (pspace_to_pspace_object): Return a new reference. * python/py-objfile.c (objfpy_get_progspace): Update. * python/py-prettyprint.c (find_pretty_printer_from_progspace): Update.
2018-09-16Add more methods to gdb.ProgspaceTom Tromey8-170/+250
There are a number of global functions in the gdb Python module which really should be methods on Progspace. This patch adds new methods to Progspace and then redefines these globals in terms of these new methods. This version has been rebased on the related changes that Simon recently put in. Built and regtested on x86-64 Fedora 28. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/lib/gdb/__init__.py (current_progspace, objfiles) (solib_name, block_for_pc, find_pc_line): New functions. (execute_unwinders): Update. * python/py-block.c (gdbpy_block_for_pc): Remove. * python/py-inferior.c (infpy_get_progspace): New function. (inferior_object_getset) <progspace>: Add. * python/py-progspace.c (pspy_objfiles): Rewrite. (pspy_solib_name, pspy_block_for_pc) (pspy_find_pc_line, pspy_is_valid): New functions. (progspace_object_methods): Add entries for solib_name, block_for_pc, find_pc_line, is_valid. * python/python-internal.h (gdbpy_block_for_pc) (build_objfiles_list): Don't declare. * python/python.c: Don't include solib.h. (gdbpy_solib_name, gdbpy_find_pc_line) (gdbpy_get_current_progspace, build_objfiles_list) (gdbpy_objfiles): Remove. (GdbMethods) <current_progspace, objfiles, block_for_pc, solib_name, find_pc_line>: Remove entries. gdb/doc/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python.texi (Basic Python): Update docs for find_pc_line, solib_name. (Progspaces In Python): Update docs for current_progspace. Document block_for_pc, find_pc_line, is_valid, nsolib_name. Move method documentation before example.
2018-09-16Use GNU style for metasyntactic variables in gdbserverTom Tromey3-2/+9
This changes a couple of places in gdbserver to use the GNU style for metasyntactic variables. gdb/gdbserver/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * remote-utils.c (remote_open): Use GNU style for metasyntactic variables. * gdbreplay.c (gdbreplay_usage): Use GNU style for metasyntactic variables.
2018-09-16Use GNU style for metasyntactic variables in gdbTom Tromey12-18/+48
I searched for other spots that did not use the GNU style for metasyntactic syntactic variables. This patch fixes most of the ones I found in gdb proper. There are a few remaining in MI, but I was unsure whether those should be touched. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * top.c (new_ui_command): Use GNU style for metasyntactic variables. * breakpoint.c (stopat_command): Use GNU style for metasyntactic variables. * maint.c (maintenance_translate_address): Remove "<>" around text. * interps.c (interpreter_exec_cmd): Use GNU style for metasyntactic variables. * nto-procfs.c (nto_procfs_target_info): Use GNU style for metasyntactic variables. * tracepoint.c (tfind_range_command): Use GNU style for metasyntactic variables. (tfind_outside_command): Likewise. (_initialize_tracepoint): Likewise. * remote.c (extended_remote_target::create_inferior): Use GNU style for metasyntactic variables. * sparc64-tdep.c (adi_examine_command): Use GNU style for metasyntactic variables. (adi_assign_command): Likewise. gdb/testsuite/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * gdb.base/new-ui.exp (do_execution_tests): Update. * gdb.base/dbx.exp (test_breakpoints): Update.
2018-09-16Expand "show disassembler-options" outputTom Tromey2-4/+15
I typed this: (gdb) help set disassembler-options Set the disassembler options. Usage: set disassembler-options OPTION [,OPTION]... See: 'show disassembler-options' for valid option values. ... so I tried what it said and got: (gdb) show disassembler-options The current disassembler options are '' This surprised me a little, so this patch adds some text to explain the situation when an architecture does not have disassembler options. While there I noticed one more spot where gdb was not using the GNU style for metasyntactic variables. This patch fixes this as well. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * disasm.c (show_disassembler_options_sfunc): Use GNU style for metasyntactic variables. Print message if no disassembler options are available.
2018-09-15Change get_inferior_args to return const char *Tom Tromey5-4/+11
I noticed that get_inferior_args should return const char *, because it is just returning a reference to something owned by the inferior. I'm checking this in. gdb/ChangeLog 2018-09-15 Tom Tromey <tom@tromey.com> * infcmd.c (get_inferior_args): Return const char *. * inferior.h (get_inferior_args): Return type now const. * linux-tdep.c (linux_fill_prpsinfo): Update. * procfs.c (procfs_target::make_corefile_notes): Update.
2018-09-14Fix possible exception leak in python.cTom Tromey2-15/+23
In the Python code, gdb exceptions may not leak into the Python core. execute_gdb_command was calling bpstat_do_actions outside of a TRY/CATCH; which seemed risky. I don't have a test case for this, but if bpstat_do_actions could ever throw, it could crash gdb. This patch introduces a new scope in order to preserve the current semantics, so it is looks a bit bigger than it really is. Tested on x86-64 Fedora 28. gdb/ChangeLog 2018-09-07 Tom Tromey <tom@tromey.com> * python/python.c (execute_gdb_command): Call bpstat_do_actions inside the TRY.
2018-09-14Provide type_align gdbarch function for nios2.Sandra Loosemore2-0/+16
2018-09-14 Sandra Loosemore <sandra@codesourcery.com> gdb/ * nios2-tdep.c (nios2_type_align): New. (nios2_gdb_arch_init): Install type_align hook.
2018-09-14gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOCAndrew Burgess4-22/+57
This patch started as an observation from valgrind that GDB appeared to be loosing track of some memory associated with types. An example valgrind stack would be: 24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361 at 0x4C2EA1E: calloc (vg_replace_malloc.c:711) by 0x623D26: xcalloc (common-utils.c:85) by 0x623D65: xzalloc(unsigned long) (common-utils.c:95) by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510) by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521) by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439) by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230) by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313) by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542) by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121) by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207) by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794) When we look in make_function_type we find a call to TYPE_ZALLOC (inside the INIT_FUNC_SPECIFIC macro). It is this call to TYPE_ZALLOC that is allocating memory with xcalloc, that is then getting lost. The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently allocates memory from either the objfile obstack or by using malloc. The problem with this is that types are allocated either on the objfile obstack, or on the gdbarch obstack. As a result, if we discard a type associated with an objfile then auxiliary data allocated with TYPE_(Z)ALLOC will be correctly discarded. But, if we were ever to discard a gdbarch then any auxiliary type data would be leaked. Right now there are very few places in GDB where a gdbarch is ever discarded, but it shouldn't hurt to close down these bugs as we spot them. This commit ensures that auxiliary type data is allocated from the same obstack as the type itself, which should reduce leaked memory. The one problem case that I found with this change was in eval.c, where in one place we allocate a local type structure, and then used TYPE_ZALLOC to allocate some space for the type. This local type is neither object file owned, nor gdbarch owned, and so the updated TYPE_ALLOC code is unable to find an objstack to allocate space on. My proposed solution for this issue is that the space should be allocated with a direct call to xzalloc. We could extend TYPE_ALLOC to check for type->gdbarch being null, and then fall back to a direct call to xzalloc, however, I think that making this rare case of a local type require special handling is not a bad thing, this serves to highlight that clearing up the memory will require special handling too. This special case of a local type is interesting as the types owner field (contained within the main_type) is completely null. While reflecting on this I looked at how types use the get_type_arch function. It seems clear that, based on how this is used, it is never intended that null will be returned from this function. This only goes to reinforce, how locally alloctaed types, with no owner, are both special, and need to be handled carefully. To help spot errors earlier, I added an assert into get_type_arch that the returned arch is not null. Inside gdbarch.c I found a few other places where auxiliary type data was being allocated directly on the heap rather than on the types obstack. I have fixed these to call TYPE_ALLOC now. Finally, it is worth noting that as we don't clean up our gdbarch objects yet, then this will not make much of an impact on the amount of memory reported as lost at program termination time. Memory allocated for auxiliary type information is still not freed, however, it is now on the correct obstack. If we do ever start freeing our gdbarch structures then the associated type data will be cleaned up correctly. Tested on X86-64 GNU/Linux with no regressions. gdb/ChangeLog: * eval.c (fake_method::fake_method): Call xzalloc directly for a type that is neither object file owned, nor gdbarch owned. * gdbtypes.c (get_type_gdbarch): Add an assert that returned gdbarch is non-NULL. (alloc_type_instance): Allocate non-objfile owned types on the gdbarch obstack. (copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA using TYPE_ALLOC to ensure memory is allocated on the correct obstack. * gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile obstack, or the gdbarch obstack. (TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
2018-09-14Remove an unnecessary block in call_function_by_hand_dummyTom Tromey2-39/+40
I noticed that call_function_by_hand_dummy has a block that only exists to declare a variable, like: { int i; for (i = ...0) ... } This patch removes the unnecessary and the extra indentation by moving the declaration into the "for". gdb/ChangeLog 2018-09-14 Tom Tromey <tom@tromey.com> * infcall.c (call_function_by_hand_dummy): Remove unnecessary block.
2018-09-14Make variable in get_startup_shell non-staticTom Tromey2-3/+5
I noticed that a variable in get_startup_shell is "static". However, I couldn't see any reason it ought to be, so this removes the "static". gdb/ChangeLog 2018-09-14 Tom Tromey <tom@tromey.com> * nat/fork-inferior.c (get_startup_shell): Remove "static".
2018-09-14Testsuite: Add gdb_simple_compileAlan Hayward2-170/+89
Simplfy gdb.exp by adding a function that will attempt to compile a piece of code, then clean up, leaving the created object. gdb/testsuite * lib/gdb.exp (gdb_simple_compile): Add proc. (is_elf_target): Use gdb_simple_compile. (skip_altivec_tests): Likewise. (skip_vsx_tests): Likewise. (skip_tsx_tests): Likewise. (skip_btrace_tests): Likewise. (skip_btrace_pt_tests): Likewise. (gdb_can_simple_compile): Likewise. (gdb_has_argv0): Likewise. (gdb_target_symbol_prefix): Likewise. (target_supports_scheduler_locking): Likewise.
2018-09-13Generate more tags in gdb/testsuite/MakefileTom Tromey2-1/+8
I noticed that the TAGS target in gdb/testsuite/Makefile does not pick up Tcl procs defined with proc_with_prefix or gdb_caching_proc. This patch fixes this by updating the regexp. Tested in Emacs. gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * Makefile.in (TAGS): Recognize proc_with_prefix and gdb_caching_proc.
2018-09-13Make infpy_thread_from_thread_handle staticTom Tromey2-1/+6
I noticed that infpy_thread_from_thread_handle is not static, but should be. This patch changes it. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * python/py-inferior.c (infpy_thread_from_thread_handle): Now static.
2018-09-13Remove cleanup from try_open_exec_fileTom Tromey2-6/+9
This removes a cleanup from try_open_exec_file, using std::string to manage the storage instead. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * exec.c (try_open_exec_file): Use std::string.
2018-09-13Return std::string from gdb_bfd_errmsgTom Tromey5-23/+18
This changes gdb_bfd_errmsg to return a std::string, removing a cleanup. This approach may be slightly less efficient than the previous code, but I don't believe this is very important in this situation. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * utils.h (gdb_bfd_errmsg): Return std::string. * exec.c (exec_file_attach): Update. * compile/compile-object-load.c (compile_object_load): Update. * utils.c (gdb_bfd_errmsg): Return std::string.
2018-09-13Remove cleanup from procfs.cTom Tromey2-10/+19
This removes the last remaining cleanup from procfs.c, replacing it with a unique_ptr specialization. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * procfs.c (struct procinfo_deleter): New. (procinfo_up): New typedef. (do_destroy_procinfo_cleanup): Remove. (procfs_target::info_proc): Use procinfo_up. Remove cleanups.
2018-09-13Remove cleanup from add_pathTom Tromey2-9/+11
This removes a cleanup from add_path, replacing it with a use of gdb::unique_xmalloc_ptr. Note that this declaration had to be hoisted somewhat, to avoid inteference from the "goto"s in this function. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * source.c (add_path): Use gdb::unique_xmalloc_ptr.
2018-09-13python: Fix erroneous doc about gdb.objfiles()Simon Marchi2-4/+8
The code implementing gdb.objfiles() returns a list of objfiles for the current program space (the program space of the selected inferior). The documentation for the gdb.objfiles() Python method, however, states: Return a sequence of all the objfiles current known to GDB. That sounds wrong to me. I tried to phrase to be more precise. gdb/doc/ChangeLog: * python.texi (Objfiles In Python): Update gdb.objfiles() doc.
2018-09-13python: Add Progspace.objfiles methodSimon Marchi9-14/+122
This patch adds an objfiles method to the Progspace object, which returns a sequence of the objfiles associated to that program space. I chose a method rather than a property for symmetry with gdb.objfiles(). gdb/ChangeLog: * python/py-progspace.c (PSPY_REQUIRE_VALID): New macro. (pspy_get_objfiles): New function. (progspace_object_methods): New. (pspace_object_type): Add tp_methods callback. * python/python-internal.h (build_objfiles_list): New declaration. * python/python.c (build_objfiles_list): New function. (gdbpy_objfiles): Implement using build_objfiles_list. * NEWS: Mention the Progspace.objfiles method. gdb/doc/ChangeLog: * python.texi (Program Spaces In Python): Document the Progspace.objfiles method. (Objfiles In Python): Mention that gdb.objfiles() is identical to gdb.selected_inferior().progspace.objfiles(). gdb/testsuite/ChangeLog: * gdb.python/py-progspace.exp: Test the Progspace.objfiles method.
2018-09-13python: Add Inferior.progspace propertySimon Marchi7-1/+56
This patch adds a progspace property to the gdb.Inferior type, which allows getting the gdb.Progspace object associated to that inferior. In conjunction with the following patch, this will allow scripts iterate on objfiles associated with a particular inferior. gdb/ChangeLog: * python/py-inferior.c (infpy_get_progspace): New function. (inferior_object_getset): Add progspace property. * NEWS: Mention the new property. gdb/doc/ChangeLog: * python.texi (Inferiors In Python): Document Inferior.progspace. (Program Spaces In Python): Document that gdb.current_progspace() is the same as gdb.selected_inferior().progspace. gdb/testsuite/ChangeLog: * gdb.python/py-inferior.exp: Add tests for Inferior.progspace and a few other Inferior properties when the Inferior is no longer valid.
2018-09-13Make Rust error message mention the field nameTom Tromey4-2/+14
I noticed a spot in rust-lang.c where the placeholder "foo" was used instead of the actual field name. This patch fixes the bug. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23650: * rust-lang.c (rust_evaluate_subexp): Use field name, not "foo". gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23650: * gdb.rust/simple.exp: Add test for enum field access error.
2018-09-13Fix crash with empty Rust enumTom Tromey5-1/+72
While testing my Rust compiler patch to fix the DWARF representation of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found a gdb crash coming from one of the Rust test cases. The bug here is that the new variant support in gdb does not handle the case where there are no variants in the enum. This patch fixes the problem in a straightforward way. Note that the new tests are somewhat lax because I did not want to try to fully fix this corner case for older compilers. If you think that's unacceptable, let meknow. Tested on x86-64 Fedora 28 using several versions of the Rust compiler. I intend to push this to the 8.2 branch as well. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * rust-lang.c (rust_enum_variant): Now static. (rust_empty_enum_p): New function. (rust_print_enum, rust_evaluate_subexp, rust_print_struct_def): Handle empty enum. gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * gdb.rust/simple.rs (EmptyEnum): New type. (main): Use it. * gdb.rust/simple.exp (test_one_slice): Add empty enum test.
2018-09-13python: Provide textual representation for Inferior and ObjfileSimon Marchi9-4/+81
Printing a GDB Python object is notoriously not helpful: >>> print(gdb.selected_inferior()) <gdb.Inferior object at 0x7fea59aed198> >>> print(gdb.objfiles()) [<gdb.Objfile object at 0x7fea59b57c90>] This makes printing debug traces more difficult than it should be. This patch provides some repr() implementation for these two types (more to come if people agree with the idea, but I want to test the water first). Here's the same example as above, but with this patch: >>> print(gdb.selected_inferior()) <gdb.Inferior num=1> >>> print(gdb.objfiles()) [<gdb.Objfile filename=/home/emaisin/build/binutils-gdb-gcc-git/gdb/test>] I implemented repr rather than str, because when printing a list (or another container I suppose), Python calls the repr method of the elements. This is useful when printing a list of inferiors or objfiles. The print(gdb.objfiles()) above would not have worked if I had implemented str. I found this post useful to understand the difference between repr and str: https://stackoverflow.com/questions/1436703/difference-between-str-and-repr gdb/ChangeLog: * python/py-inferior.c (infpy_repr): New. (inferior_object_type): Register infpy_repr. * python/py-objfile.c (objfpy_repr): New. (objfile_object_type): Register objfpy_repr. gdb/testsuite/ChangeLog: * gdb.python/py-inferior.exp: Test repr() of gdb.Inferior. * gdb.python/py-objfile.exp: Test repr() of gdb.Objfile. * gdb.python/py-symtab.exp: Update test printing an objfile. gdb/doc/ChangeLog: * python.texi (Basic Python): Mention the string representation of GDB Python objects.
2018-09-12Remove unused "tmp" variable.John Baldwin2-1/+4
gdb/ChangeLog: * fbsd-nat.c (fbsd_nat_target::info_proc): Remove unused variable.
2018-09-12Fix a typo in a comment.John Baldwin2-1/+6
gdb/ChangeLog: * aarch64-fbsd-tdep.h (AARCH64_FBSD_SIZEOF_GREGSET): Fix comment typo.
2018-09-12python: Add tests for trying to use an invalid Inferior objectSimon Marchi2-0/+18
This patch adds tests for trying to use property or methods on a gdb.Inferior object that represents an inferior that does not exist anymore. We expect an exception to be thrown. gdb/testsuite/ChangeLog: * gdb.python/py-inferior.exp: Test using an invalid gdb.Inferior object.
2018-09-12Move 'is_regular_file' from common-utils.c to filestuff.cSergio Durigan Junior5-37/+44
There is no reason for 'is_regular_file' to be in common-utils.c; it belongs to 'filestuff.c'. This commit moves the function definition and its prototype to the appropriate files. The motivation behind this move is a failure that happens on certain cross-compilation environments when compiling the IPA library, due to the way gnulib probes the need for a 'stat' call replacement. Because configure checks when cross-compiling are more limited, gnulib decides that it needs to substitute the 'stat' calls its own 'rpl_stat'; however, the IPA library doesn't link with gnulib, which leads to an error when compiling 'common-utils.c': ... /opt/x86-core2--musl--bleeding-edge-2018.09-1/bin/i686-buildroot-linux-musl-g++ -shared -fPIC -Wl,--soname=libinproctrace.so -Wl,--no-undefined -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -I. -I. -I./../common -I./../regformats -I./.. -I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized -DGDBSERVER \ -Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o common-utils-ipa.o errors-ipa.o format-ipa.o print-utils-ipa.o regcache-ipa.o remote-utils-ipa.o rsp-low-ipa.o tdesc-ipa.o tracepoint-ipa.o utils-ipa.o vec-ipa.o linux-i386-ipa.o linux-x86-tdesc-ipa.o arch/i386-ipa.o -ldl -pthread /opt/x86-core2--musl--bleeding-edge-2018.09-1/lib/gcc/i686-buildroot-linux-musl/8.2.0/../../../../i686-buildroot-linux-musl/bin/ld: common-utils-ipa.o: in function `is_regular_file(char const*, int*)': common-utils.c:(.text+0x695): undefined reference to `rpl_stat' collect2: error: ld returned 1 exit status Makefile:413: recipe for target 'libinproctrace.so' failed make[1]: *** [libinproctrace.so] Error 1 ... More details can also be found at: https://sourceware.org/ml/gdb-patches/2018-09/msg00304.html The most simple fix for this problem is to move 'is_regular_file' to 'filestuff.c', which is not used by IPA. This ends up making the files more logically organized as well, since 'is_regular_file' is a file operation. No regressions found. gdb/ChangeLog: 2018-09-12 Sergio Durigan Junior <sergiodj@redhat.com> * common/common-utils.c: Don't include '<sys/stat.h>'. (is_regular_file): Move to... * common/filestuff.c (is_regular_file): ... here. * common/common-utils.h (is_regular_file): Move to... * common/filestuff.h (is_regular_file): ... here.
2018-09-12Add debug output about skipping files and functionsSimon Marchi5-25/+103
While trying to create skips for libstdc++, I found myself debugging GDB quite a bit, mostly to find out what the exact function name to match is. I thought it would make sense to have this information as debug output. This patch adds "set debug skip on|off". gdb/ChangeLog: * skip.c (debug_skip): New variable. (skiplist_entry::do_skip_file_p): Add debug output. (skiplist_entry::do_skip_gfile_p): Likewise. (skiplist_entry::skip_function_p): Likewise. (_initialize_step_skip): Create debug command. * NEWS: Mention set/show debug skip. gdb/doc/ChangeLog: * gdb.texinfo (Skipping Over Functions and Files): Document set/show debug skip.