aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2019-03-06Remove cleanup from solib-svr4.cTom Tromey2-30/+15
This removes a cleanup from solib-svr4.c, replacing it with make_scope_exit. 2019-03-06 Tom Tromey <tom@tromey.com> * solib-svr4.c (disable_probes_interface): Remove parameter. (svr4_handle_solib_event): Use make_scope_exit.
2019-03-06Remove last cleanup from gdbserverTom Tromey2-5/+11
This removes the last cleanup from gdbserver, replacing it with SCOPE_EXIT. This could perhaps be done in a different way, but this approach was direct and obviously correct. 2019-03-06 Tom Tromey <tom@tromey.com> * server.c (detach_or_kill_for_exit_cleanup): Remove parameter. (captured_main): Use SCOPE_EXIT.
2019-03-06C++ify remote notification codeTom Tromey4-99/+59
This C++ifies the remote notification code -- replacing function pointers with virtual methods and using unique_ptr. This allows for the removal of some cleanups. 2019-03-06 Tom Tromey <tom@tromey.com> * remote.c (struct stop_reply_deleter): Remove. (stop_reply_up): Update. (struct stop_reply): Derive from notif_event. Don't typedef. <regcache>: Now a std::vector. (stop_reply_xfree): Remove. (stop_reply::~stop_reply): Rename from stop_reply_dtr. (remote_notif_stop_alloc_reply): Return a unique_ptr. Use new. (remote_target::discard_pending_stop_replies): Use delete. (remote_target::remote_parse_stop_reply): Update. (remote_target::process_stop_reply): Update. * remote-notif.h (struct notif_event): Add virtual destructor. Remove "dtr" member. (struct notif_client) <alloc_event>: Return a unique_ptr. (notif_event_xfree): Don't declare. (notif_event_up): New typedef. * remote-notif.c (remote_notif_ack, remote_notif_parse): Update. (notif_event_xfree, do_notif_event_xfree): Remove. (remote_notif_state_xfree): Update.
2019-03-06Change displaced_step_clear_cleanup to a forward_scope_exitTom Tromey2-19/+18
This changes displaced_step_clear_cleanup to be a forward_scope_exit and updates the callers. gdb/ChangeLog 2019-03-06 Tom Tromey <tom@tromey.com> * infrun.c (displaced_step_clear_cleanup): Now a forward_scope_exit type. (displaced_step_prepare_throw): Update. (displaced_step_fixup): Update.
2019-03-06Update two cleanup commentsTom Tromey3-2/+7
This updates another couple of comments to remove mentions of cleanups. gdb/ChangeLog 2019-03-06 Tom Tromey <tom@tromey.com> * inferior.h (class inferior): Update comment. * gdbthread.h (class thread_info): Update comment.
2019-03-06Remove cleanups from coffread.cTom Tromey4-109/+72
This removes the remaining cleanups from coffread.c. Tested by the buildbot and also some manual testing. This version includes the fix provided by Joel. gdb/ChangeLog 2019-03-06 Joel Brobecker <brobecker@adacore.com> Tom Tromey <tom@tromey.com> * stabsread.h (struct stab_section_list): Remove. (coffstab_build_psymtabs): Update. * dbxread.c (symbuf_sections): Now a std::vector. (sect_idx): New global. (fill_symbuf): Update. (coffstab_build_psymtabs): Change type of stabsects parameter. Update. * coffread.c (struct coff_symfile_info) <stabsects>: Now a std::vector. (linetab, linetab_offset, linetab_size, stringtab): Move earlier. (coff_locate_sections): Update. (coff_symfile_read): Remove cleanups. Update. (init_stringtab): Add storage parameter. (free_stringtab, free_stringtab_cleanup): Remove. (init_lineno): Add storage parameter. (free_linetab, free_linetab_cleanup): Remove.
2019-03-06Eliminate fork_info::clobber_regsPedro Alves2-44/+45
All fork_save_infrun_state callers pass '1' as CLOBBER_REGS nowadays. The larger hunk in fork_save_infrun_state is just a reindentation. gdb/ChangeLog: 2019-03-06 Pedro Alves <palves@redhat.com> * linux-fork.c (fork_info::clobber_regs): Delete. (fork_load_infrun_state): Remove reference to 'clobber_regs'. (fork_save_infrun_state): Remove 'clobber_regs' parameter. Update comment. Adjust. (scoped_switch_fork_info::scoped_switch_fork_info) (checkpoint_command, linux_fork_context): Adjust fork_save_infrun_state calls.
2019-03-06linux-fork.c: rewrite inf_has_multiple_threadsPedro Alves2-20/+15
There's no need to iterate over all threads of all inferiors here. gdb/ChangeLog: 2019-03-06 Pedro Alves <palves@redhat.com> * linux-fork.c (inf_has_multiple_thread_cb): Delete. (inf_has_multiple_threads): Return 'bool' and rewrite using inferior_info::threads().
2019-03-06C++ify fork_info, use std::listPedro Alves2-153/+125
- Convert new_fork and free_fork to fork_info ctor/dtor. - Use std::list. gdb/ChangeLog: 2019-03-06 Pedro Alves <palves@redhat.com> * linux-fork.c: Include <list>. (fork_list): Now a std::list instance. (fork_info): Add ctor, dtor, and in-class initialize all fields. (forks_exist_p, find_last_fork): Adjust. (new_fork): Delete. (one_fork_p): New. (add_fork): Adjust. (free_fork): Delete, folded into fork_info::~fork_info(). (delete_fork, find_fork_ptid, find_fork_id, find_fork_pid): Adjust. (init_fork_list): Delete. (linux_fork_killall, linux_fork_mourn_inferior) (linux_fork_detach, info_checkpoints_command): Adjust. (_initialize_linux_fork): No longer call init_fork_list.
2019-03-06Make "checkpoint" not rely on inferior_ptidPedro Alves3-17/+37
Don't rely on "inferior_ptid" deep within add_fork. In the multi-target branch, I'm forcing inferior_ptid to null_ptid early in infrun event handling to make sure we don't inadvertently rely on the current thread/target when we shouldn't, and that caught some bad or unnecessary assumptions throughout. gdb/ChangeLog: 2019-03-06 Pedro Alves <palves@redhat.com> * linux-fork.c (new_fork): New, split out of ... (add_fork): ... this. Return void. Move "first fork" special case from here, to ... (checkpoint_command): ... here. * linux-linux.h (add_fork): Return void.
2019-03-06gdb/fortran: Handle older TYPE*SIZE typenamesAndrew Burgess4-0/+33
This patch adds support for the older TYPE*SIZE typenames that are still around in older code. For implementation this currently reuses the kind mechanism, as under gFortran the kind number is equivalent to the size, however, this is not necessarily true for all compilers. If the rules for other compilers are better understood then this code might need to be improved slightly to allow for a distinction between size and kind, however, adding this extra complexity now seems pointless. gdb/ChangeLog: * f-exp.y (direct_abs_decl): Handle TYPE*SIZE type names. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp: Extend to cover TYPE*SIZE cases.
2019-03-06gdb/fortran: Add support for the ABS intrinsic functionAndrew Burgess5-1/+70
Adds support for the abs intrinsic function, this requires adding a new pattern to the Fortran parser. Currently only float and integer argument types are supported to ABS, complex is still not supported, this can be added later if needed. gdb/ChangeLog: * f-exp.y: New token, UNOP_INTRINSIC. (exp): New pattern using UNOP_INTRINSIC token. (f77_keywords): Add 'abs' keyword. * f-lang.c: Add 'target-float.h' and 'math.h' includes. (value_from_host_double): New function. (evaluate_subexp_f): Support UNOP_ABS. gdb/testsuite/ChangeLog: * gdb.fortran/intrinsics.exp: Extend to cover ABS.
2019-03-06gdb/fortran: Use TYPE_CODE_CHAR for character typesAndrew Burgess4-2/+11
Switch to using TYPE_CODE_CHAR for character types. This appears to have little impact on the test results as gFortran uses the DW_TAG_string_type to represent all character variables (as far as I can see). The only place this has an impact is when the user casts a variable to a character type, in which case GDB does now use the CHAR type, and prints the variable as both a value and a character, for example, before: (gdb) p ((character) 97) $1 = 97 and after: (gdb) p ((character) 97) $1 = 97 'a' gdb/ChangeLog: * f-lang.c (build_fortran_types): Use TYPE_CODE_CHAR for character types. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp: Update expected results.
2019-03-06gdb/fortran: Add builtin 8-byte integer type with (kind=8) supportAndrew Burgess6-0/+18
Add a new builtin type, an 8-byte integer, and allow GDB to parse 'integer (kind=8)', returning the new 8-byte integer. gdb/ChangeLog: * f-exp.y (convert_to_kind_type): Handle integer (kind=8). * f-lang.c (build_fortran_types): Setup builtin_integer_s8. * f-lang.h (struct builtin_f_type): Add builtin_integer_s8 field. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp: Test new integer type kind.
2019-03-06gdb/fortran: Expand the set of types that support (kind=N)Andrew Burgess4-1/+87
Expand the number of types that can be adjusted with a (kind=N) type extension. gdb/ChangeLog: * f-exp.y (convert_to_kind_type): Handle more type kinds. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp (test_cast_1_to_type_kind): New function. (test_basic_parsing_of_type_kinds): Expand types tested. (test_parsing_invalid_type_kinds): New function.
2019-03-06gdb/fortran: Add Fortran 'kind' intrinsic and keywordAndrew Burgess11-4/+249
The 'kind' keyword has two uses in Fortran, it is the name of a builtin intrinsic function, and it is also a keyword used to create a type of a specific kind. This commit adds support for using kind as an intrinsic function, and also adds some initial support for using kind to create types of a specific kind. This commit only allows the creation of the type 'character(kind=1)', however, it will be easy enough to extend this in future to support more type kinds. The kind of any expression can be queried using the kind intrinsic function. At the moment the kind returned corresponds to the size of the type, this matches how gfortran handles kinds. However, the correspondence between kind and type size depends on the compiler and/or the specific target, so this might not be correct for everyone. If we want to support different compilers/targets in future the code to compute the kind from a type will need to be updated. gdb/ChangeLog: * expprint.c (dump_subexp_body_standard): Support UNOP_KIND. * f-exp.y: Define 'KIND' token. (exp): New pattern for KIND expressions. (ptype): Handle types with a kind extension. (direct_abs_decl): Extend to spot kind extensions. (f77_keywords): Add 'kind' to the list. (push_kind_type): New function. (convert_to_kind_type): New function. * f-lang.c (evaluate_subexp_f): Support UNOP_KIND. * parse.c (operator_length_standard): Likewise. * parser-defs.h (enum type_pieces): Add tp_kind. * std-operator.def: Add UNOP_KIND. gdb/testsuite/ChangeLog: * gdb.fortran/intrinsics.exp: New file. * gdb.fortran/intrinsics.f90: New file. * gdb.fortran/type-kinds.exp: New file.
2019-03-06gdb/fortran: Enable debugging of the Fortran parserAndrew Burgess2-0/+6
This commit allows 'set debug parser on' to work for the Fortran parser. gdb/ChangeLog: * f-exp.y (f_parse): Set yydebug.
2019-03-06gdb/fortran: Add new function to evaluate Fortran expressionsAndrew Burgess2-1/+28
This is an initial restructure, it adds a new function in which Fortran specific expressions can be evaluated. No Fortran specific expressions are added with this commit though, so for now, the new function just forwards all expressions to the default expression handler, as such, there should be no user visible changes after this commit. However, the new function will be useful in later commits. gdb/ChangeLog: * f-lang.c (evaluate_subexp_f): New function. (exp_descriptor_f): New global. (f_language_defn): Use exp_descriptor_f instead of exp_descriptor_standard.
2019-03-06gdb/fortran: Simplify handling of Fortran dot operations and keywordsAndrew Burgess4-52/+189
Use strncasecmp to compare Fortran dot operations (like .AND.) and for the keywords list. This allows for some duplication to be removed from the token arrays. I've also performed whitespace cleanup around the code I've changed. I have added some tests to ensure that upper and lowercase dot operations are correctly tested. The keywords list remains always lowercase for now. There should be no user visible changes after this commit. gdb/ChangeLog: * f-exp.y (struct token): Add comments. (dot_ops): Remove uppercase versions and the end marker. (f77_keywords): Likewise. (yylex): Use ARRAY_SIZE to iterate over dot_ops, assert all entries in the dot_ops array are case insensitive, and use strncasecmp to compare strings. Also some whitespace cleanup in this area. Similar for the f77_keywords array, except entries in this list might be case sensitive. gdb/testsuite/ChangeLog: * gdb.fortran/dot-ops.exp: New file.
2019-03-06gdb/fortran: Cleanup code for parsing logical constantsAndrew Burgess4-17/+36
This patch cleans up the code used for parsing the Fortran logical constants '.TRUE.' and '.FALSE.'. Instead of listing both upper and lowercase versions of these strings we now use strncasecmp. I've also switched to use ARRAY_SIZE for the array iteration, and I've cleaned up whitespace in the vicinity of the code I've changed. Finally, I've added a test to ensure that both the upper and lower case versions of the logical constants are understood by GDB, something that was missing previously. There should be no user visible changes after this commit. gdb/ChangeLog: * f-exp.y (struct f77_boolean_val): Add comments. (boolean_values): Remove uppercase versions, and end marker. (yylex): Use ARRAY_SIZE for iterating over boolean_values array, and use strncasecmp to achieve case insensitivity. Additionally, perform whitespace cleanup around this code. gdb/testsuite/ChangeLog: * gdb.fortran/types.exp (test_logical_literal_types_accepted): Check upper and lower case logical literals.
2019-03-06gdb/fortran: Remove some duplicate testsAndrew Burgess2-4/+5
Make the test names unique in gdb.fortran/types.exp by removing a few duplicate tests. gdb/testsuite/ChangeLog: * gdb.fortran/types.exp (test_float_literal_types_accepted): Remove duplicate tests.
2019-03-06Fix remote-sim.c build after warn-unused-result changeTom Tromey2-3/+7
John Darrington pointed out that commit 18cb7c9f3 ("Introduce ATTRIBUTE_UNUSED_RESULT and use it") broke the build: /home/john/binutils-gdb/gdb/remote-sim.c: In function 'void gdbsim_target_open(const char*, int)': /home/john/binutils-gdb/gdb/remote-sim.c:765:18: error: ignoring return value of 'char** gdb_argv::release()', declared with attribute warn_unused_result [-Werror=unused-result] This patch fixes the problem by arranging to use the result of the release method. Tested by rebuilding with a simulator enabled. gdb/ChangeLog 2019-03-06 Tom Tromey <tromey@adacore.com> * remote-sim.c (gdbsim_target_open): Use result of gdb_argv::release.
2019-03-06Testsuite: Ensure changing directory does not break the log fileAlan Hayward2-2/+43
get_compiler_info switches to a new log file before checking the compiler to ensure the checks are not logged. Afterwards it restores back to using the original log file. However, the logfile uses a relative path name - if the current test has changed the current directory then all further output for the test will be lost. This can confuse the code that collates the main gdb.log file at the end of a FORCE_PARALLEL run. fullpath-expand.exp calls gdb_compile after changing the current directory. The "Ensure stack protection is off for GCC" patch added a call to get_compiler_info from inside of gdb_compile, causing log file collection to break for FORCE_PARALLEL runs. The ideal solution would be to ensure the log file is always created using an absolute path name. However, this is set at multiple points in Makefile.in and in some instances just relies on dejagnu common code to set the log file directory to "." The simpler and safer solution is to override the builtin cd function. The new function checks the current log file and if the path is relative, then it resets the logging using an absolute path. Finally it calls the builtin cd. This ensures get_compiler_info (and any other code) can correctly backup and restore the current log file. gdb/testsuite/ChangeLog: * lib/gdb.exp (builtin_cd): rename of cd. (cd): Override builtin.
2019-03-06Fortran function calls with argumentsRichard Bunt8-3/+457
Prior to this patch, calling functions on the inferior with arguments and then using these arguments within a function resulted in an invalid memory access. This is because Fortran arguments are typically passed as pointers to values. It is possible to call Fortran functions, but memory must be allocated in the inferior, so a pointer can be passed to the function, and the language must be set to C to enable C-style casting. This is cumbersome and not a pleasant debug experience. This patch implements the GNU Fortran argument passing conventions with caveats. Firstly, it does not handle the VALUE attribute as there is insufficient DWARF information to determine when this is the case. Secondly, functions with optional parameters can only be called with all parameters present. Both these cases are marked as KFAILS in the test. Since the GNU Fortran argument passing convention has been implemented, there is no guarantee that this patch will work correctly, in all cases, with other compilers. Despite these limitations, this patch improves the ease with which functions can be called in many cases, without taking away the existing approach of calling with the language set to C. Regression tested on x86_64, aarch64 and POWER9 with GCC 7.3.0. Regression tested with Ada on x86_64. Regression tested with native-extended-gdbserver target board. gdb/ChangeLog: * eval.c (evaluate_subexp_standard): Call Fortran argument wrapping logic. * f-lang.c (struct value): A value which can be passed into a Fortran function call. (fortran_argument_convert): Wrap Fortran arguments in a pointer where appropriate. (struct type): Value ready for a Fortran function call. (fortran_preserve_arg_pointer): Undo check_typedef, the pointer is needed. * f-lang.h (fortran_argument_convert): Declaration. (fortran_preserve_arg_pointer): Declaration. * infcall.c (value_arg_coerce): Call Fortran argument logic. gdb/testsuite/ChangeLog: * gdb.fortran/function-calls.exp: New file. * gdb.fortran/function-calls.f90: New test.
2019-03-05Remove some Python 3 #ifsTom Tromey3-14/+7
A recent patch from Kevin Buettner taught me that the PyBytes API is available on Python 2. This patch removes a couple of related #ifs in the Python code. Tested on x86-64 Fedora 29, using both Python 3.7 and Python 2.7. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * python/py-prettyprint.c (print_string_repr): Remove #if. * python/py-utils.c (unicode_to_encoded_string): Remove #if.
2019-03-05Change the_dummy_target to be a globalTom Tromey2-5/+12
While debugging gdb, I printed the target stack and got: (top-gdb) p g_target_stack $10 = { m_top = thread_stratum, m_stack = {0x142b0b0, 0x13da600 <exec_ops>, 0x1c70690, 0x13d63b0 <ravenscar_ops>, 0x0, 0x0, 0x0} } (This is clearly from before the change to make ravenscar multi-target-capable.) Here, 0x142b0b0 is the singleton dummy target. It seems to me that since this is always a singleton, it would be a bit nicer if it were a global, so that it would be noted in the above. This patch implements this idea, and now I get: (top-gdb) p g_target_stack $2 = { m_top = dummy_stratum, m_stack = {0x1f1b040 <the_dummy_target>, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} } I did not do the same for the debug target. It didn't seem as useful to me. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * target.c (the_dummy_target): Move later. Change type to "dummy_target". (initialize_targets): Don't initialize the_dummy_target.
2019-03-05Small fix to gdb.Value constructor docSimon Marchi2-1/+6
The synopsis of the two-parameters form of the gdb.Value constructor is currently shown as Value.__init__ (val, [, type ]) in the documentation. First, there is an extra comma, which I think we can remove in any case. Then, since the type parameter is not optional, I would not put in between square brackets. Those usually indicate that something is optional. With this patch, it appears as: Value.__init__ (val, type) gdb/doc/ChangeLog: * python.texi (Values From Inferior): Change synopsys of the second form of Value.__init__.
2019-03-05Remove gdb_bfd_fdopenrTom Tromey3-15/+5
I noticed that gdb_bfd_fdopenr is no longer used, so this patch removes it. Tested by rebuilding and by grep. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * gdb_bfd.c (gdb_bfd_fdopenr): Remove. * gdb_bfd.h (gdb_bfd_fdopenr): Don't declare.
2019-03-05Remove excess calls to gdb_flushTom Tromey25-58/+38
A customer noticed some mildly odd MI output, where CLI output was split into multiple MI strings at unusual boundaries, like this: ~"$1 = (b => true" ~", p => 0x407260" This is technically correct according to the MI spec, but still unusual, in that there's no particular reason for the string to be split where it is. I tracked this down to a call to gdb_flush in generic_val_print. Then, I went through all calls to gdb_flush and removed the ones I thought were superfluous. In particular: * Any call in the value-printing code; * Likewise the type-printing code (just a single call); and * Any call that immediately followed a printf that obviously ended with a newline, my belief being that gdb's standard output streams are line buffered (by inheriting the behavior from stdio) Regression tested on x86-64 Fedora 29. I didn't add a new test case. I tend to think we don't necessarily want to specify this behavior in the tests. Let me know what you think of this. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat_target::attach) (windows_nat_target::detach): Don't call gdb_flush. * valprint.c (generic_val_print, val_print, val_print_string): Don't call gdb_flush. * utils.c (defaulted_query): Don't call gdb_flush. * typeprint.c (print_type_scalar): Don't call gdb_flush. * target.c (target_announce_detach): Don't call gdb_flush. * sparc64-tdep.c (adi_print_versions): Don't call gdb_flush. * remote.c (extended_remote_target::attach): Don't call gdb_flush. * procfs.c (procfs_target::detach): Don't call gdb_flush. * printcmd.c (do_examine): Don't call gdb_flush. (info_display_command): Don't call gdb_flush. * p-valprint.c (pascal_val_print): Don't call gdb_flush. * nto-procfs.c (nto_procfs_target::attach): Don't call gdb_flush. * memattr.c (info_mem_command): Don't call gdb_flush. * mdebugread.c (mdebug_build_psymtabs): Don't call gdb_flush. * m2-valprint.c (m2_val_print): Don't call gdb_flush. * infrun.c (follow_exec, handle_command): Don't call gdb_flush. * inf-ptrace.c (inf_ptrace_target::attach): Don't call gdb_flush. * hppa-tdep.c (unwind_command): Don't call gdb_flush. * gnu-nat.c (gnu_nat_target::attach): Don't call gdb_flush. (gnu_nat_target::detach): Don't call gdb_flush. * f-valprint.c (f_val_print): Don't call gdb_flush. * darwin-nat.c (darwin_nat_target::attach): Don't call gdb_flush. * cli/cli-script.c (read_command_lines): Don't call gdb_flush. * cli/cli-cmds.c (shell_escape, print_disassembly): Don't call gdb_flush. * c-valprint.c (c_val_print): Don't call gdb_flush. * ada-valprint.c (ada_print_scalar): Don't call gdb_flush.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::releaseTom Tromey5-10/+18
This applies ATTRIBUTE_UNUSED_RESULT to ref_ptr::release and updates a few spots to comply. I believe one use in install_default_visualizer was in error, fixed by this patch. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * varobj.c (update_dynamic_varobj_children): Update. (install_default_visualizer): Use reset, not release. * value.c (set_internalvar): Update. * dwarf2loc.c (value_of_dwarf_reg_entry): Update. * common/gdb_ref_ptr.h (class ref_ptr) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::releaseTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * remote.c (class scoped_remote_fd) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to macro_bufferTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to macro_buffer::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * macroexp.c (struct macro_buffer) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_mmapTom Tromey3-7/+10
This applies ATTRIBUTE_UNUSED_RESULT to scoped_mmap::release and fixes a couple of spots to comply. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * nat/linux-btrace.c (linux_enable_bts, linux_enable_pt): Update. * common/scoped_mmap.h (class scoped_mmap) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to scoped_fdTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to scoped_fd::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * common/scoped_fd.h (class scoped_fd) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Add ATTRIBUTE_UNUSED_RESULT to parser_stateTom Tromey2-1/+6
This applies ATTRIBUTE_UNUSED_RESULT to parser_state::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * parser-defs.h (struct parser_state) <release>: Add ATTRIBUTE_UNUSED_RESULT.
2019-03-05Introduce ATTRIBUTE_UNUSED_RESULT and use itTom Tromey3-1/+13
This introduces the new ATTRIBUTE_UNUSED_RESULT define, and applies it to gdb_argv::release. gdb/ChangeLog 2019-03-05 Tom Tromey <tromey@adacore.com> * utils.h (class gdb_argv) <release>: Add ATTRIBUTE_UNUSED_RESULT. * common/common-defs.h (ATTRIBUTE_UNUSED_RESULT): Define.
2019-03-04Use '$enable_unittest' instead of '$development' on gdbserver/configure.srv ↵Sergio Durigan Junior2-1/+7
(for 'aarch64*-*-linux*' case) On commit 8ecfd7bd4acd69213c06fac6de9af38299123547 ("Add parameter to allow enabling/disabling selftests via configure") it seems that I forgot to use the proper '$enable_unittest' variable when checking to see whether to add selftest-related objects to 'srv_regobj'. This causes a build failure on Aarch64 when 'development=false' (which is the case for the 8.3 branch) and 'enable_unittest=true'. This patch fixes the problem by using '$enable_unittest' instead of '$development' when performing the check. As a reminder, it's important to notice that '$enable_unittest's default value (i.e., when the option '--enable-unit-tests' is not passed to configure) is the same as '$development', so this patch doesn't affect the current build. I'd like to install this patch both on master and on the 8.3 branch. OK? gdb/gdbserver/ChangeLog: 2019-03-04 Sergio Durigan Junior <sergiodj@redhat.com> * configure.srv: Use '$enable_unittest' instead of '$development' when checking whether to fill 'srv_regobj' on 'aarch64*-*-linux*' case.
2019-03-04gdbserver short-circuit-argument-list failuresRichard Bunt3-26/+89
This patch fixes test case failures observed when running short-circuit-argument-list.exp with gdb server boards. Thanks to Sergio Durigan Junior for pointing this out. Assertions failed with the native{,-extended}-gdbserver boards as the standard output from the test program appears in a different location than observed on non-gdbserver boards. This standard output was used to determine whether a function, which had been logically short-circuited, was called or not. Since the location of the standard out cannot be relied upon to verify this, a new mechanism was needed. The test program now records function calls in variables named the same as the function with a "_called" suffix. These variables can then be queried from the test case to verify the occurrence of a call. A method to reset the call counts has been included in the test case, so that any future assertions added to this test can ensure a fresh set of initial values before proceeding. Not resetting values between groups of assertions creates a dependency between them, which increases the likelihood that a single failure causes subsequent assertions to fail. Regression tested on x86_64, aarch64 and ppc64le. Regression tested with Ada on x86_64. Regression tested with the native{,-extended}-gdbserver boards on x86_64.
2019-03-02Fix documentation of styles.Eli Zaretskii2-6/+15
gdb/doc/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * gdb.texinfo (Output Styling): Fix typos. Document the default foreground colors of the available styles.
2019-03-02Avoid compilation warnings on MinGW.Eli Zaretskii3-2/+10
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * xml-syscall.c (xml_list_syscalls_by_group): Drop 'struct' from for-loop range, to avoid compiler warnings. * tui/tui.c (tui_enable) [__MINGW32__]: Don't declare 'cap', to avoid compiler warnings about unused variables.
2019-03-02GDB no longer supports Windows before XP.Eli Zaretskii2-0/+8
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> * NEWS: Mention end of support for native debugging on MS-Windows before XP.
2019-03-02Fix GDB compilation on MinGW (PR gdb/24292)Eli Zaretskii6-10/+39
gdb/ChangeLog: 2019-03-02 Eli Zaretskii <eliz@gnu.org> PR gdb/24292 * common/netstuff.c: * gdbserver/gdbreplay.c * gdbserver/remote-utils.c: * ser-tcp.c: * unittests/parse-connection-spec-selftests.c [USE_WIN32API]: Include ws2tcpip.h instead of wsiapi.h and winsock2.h. Redefine _WIN32_WINNT to 0x0501 if defined to a smaller value, as 'getaddrinfo' and 'freeaddrinfo' were not available before Windows XP, and mingw.org's MinGW headers by default define _WIN32_WINNT to 0x500.
2019-03-01Fix coff_start_symtab resource leak found by CoverityGary Benson2-4/+5
This commit fixes a resource leak found by Coverity, where coff_start_symtab performs an xstrdup that is now performed within start_symtab by buildsym_compunit::buildsym_compunit. gdb/ChangeLog: * coffread.c (coff_start_symtab): Remove unnecessary xstrdup.
2019-02-28Testsuite: Catch gdbserver socket listen errorsAlan Hayward2-1/+6
When launching gdbserver, the testsuite checks for binding failure but does not check for failure to listen to socket error (which can happen due to another gdbserver binding to the socket at the same time). When this error occurs, the test will ignore the error and connect GDB to the failed port. This may succeed and GDB will now be connected to the gdbserver from another test. This eventually causes both tests to fail. When running the tests suite with native-gdbserver across many cores, this issue may happen once or twice, each causing random failures for two .exp testscripts. Example gdb.log output for the failure: The testsuite sucessfully notices a failure to connect to port 2348. It launches again with port 2349, which also fails. The testsuite ignores this error and uses gdb to connect to the port - which succeeds. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2348 /work/build/gdb/testsuite/outputs/gdb.ada/arrayidx/p^M Can't bind address: Address already in use.^M Exiting^M Port 2348 is already in use. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2349 /work/build/gdb/testsuite/outputs/gdb.ada/arrayidx/p^M Can't listen on socket: Address already in use.^M Exiting^M target remote localhost:2349^M Remote debugging using localhost:2349^M Reading /lib/ld-linux-aarch64.so.1 from remote target...^M warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.^M Reading /lib/ld-linux-aarch64.so.1 from remote target...^M Reading symbols from target:/lib/ld-linux-aarch64.so.1...^M Reading /lib/ld-2.23.so from remote target...^M Reading /lib/.debug/ld-2.23.so from remote target...^M Reading /work/build/install/lib/debug//lib/ld-2.23.so from remote target...^M Reading /work/build/install/lib/debug/lib//ld-2.23.so from remote target...^M Reading target:/work/build/install/lib/debug/lib//ld-2.23.so from remote target...^M (No debugging symbols found in target:/lib/ld-linux-aarch64.so.1)^M 0x0000ffffbf6d2cc0 in ?? () from target:/lib/ld-linux-aarch64.so.1^M (gdb) continue^M Continuing.^M Reading /lib/aarch64-linux-gnu/libc.so.6 from remote target...^M Reading /lib/aarch64-linux-gnu/libc-2.23.so from remote target...^M Reading /lib/aarch64-linux-gnu/.debug/libc-2.23.so from remote target...^M Reading /work/build/install/lib/debug//lib/aarch64-linux-gnu/libc-2.23.so from remote target...^M Reading /work/build/install/lib/debug/lib/aarch64-linux-gnu//libc-2.23.so from remote target...^M Reading target:/work/build/install/lib/debug/lib/aarch64-linux-gnu//libc-2.23.so from remote target...^M [Inferior 1 (process 35351) exited normally]^M (gdb) FAIL: gdb.ada/arrayidx.exp: can't run to main Meanwhile, at the same time, in another test, gdbserver successfully connects to port 2349. GDB then tries to connect to the port, but it times out because the GDB in the test above has already connected to it. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2348 /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo^M Can't bind address: Address already in use.^M Exiting^M Port 2348 is already in use. spawn /work/build/gdb/testsuite/../gdbserver/gdbserver --once localhost:2349 /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo^M Process /work/build/gdb/testsuite/outputs/gdb.ada/rdv_wait/foo created; pid = 65162^M Listening on port 2349^M Remote debugging from host 127.0.0.1, port 45154^M target remote localhost:2349^M localhost:2349: Connection timed out.^M (gdb) ^CQuit^M (gdb) task 2^M Cannot inspect Ada tasks when program is not running^M gdb/testsuite/ChangeLog: * lib/gdbserver-support.exp (gdbserver_start): Check for listen failure.
2019-02-28Can't interrupt process without controlling terminal on Solaris (PR gdb/8527)Rainer Orth5-0/+170
If gdb attaches to a process that either has no controlling terminal, or the controlling terminal differs from the one gdb is running under, break/^C doesn't interrupt the debugged process on Solaris. Fixed as follows, analogous to what all all other targets do. Patch from the PR, recently re-submitted by Brian Vandenberg. Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. 2019-02-28 Brian Vandenberg <phantall@gmail.com> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gdb: PR gdb/8527 * procfs.c (proc_wait_for_stop): Wrap write of PCWSTOP in set_sigint_trap, clear_sigint_trap. gdb/testsuite: PR gdb/8527 * gdb.base/interrupt-daemon-attach.c, gdb.base/interrupt-daemon-attach.exp: New test.
2019-02-27Fix regcache leak, and avoid possible regcache access after detach.Philippe Waroquiers2-1/+17
Valgrind reports leaks like the below in various tests, e.g. gdb.threads/attach-slow-waitpid.exp, gdb.ada/task_switch_in_core.exp, ... Fix the leak by clearing the regcache when detaching from an inferior. Note that these leaks are 'created' when GDB exits, when the regcache::current_regcache is destroyed : the elements of the forward_list are pointers, and the 'pointed to' memory is not deleted by the forward_list destructor. Nevertheless, fixing this leak is good as it makes a bunch of tests 'leak clean'. Also, it seems strange to keep a register cache for a process from which GDB detached : it is not clear if this cache is still valid after detach. And effectively, when clearing only the regcache, (and not the frame cache), then the frame cache was still 'pointing' at this regcache and was used when switching to the child process in the test gdb.threads/watchpoint-fork.exp, which seems strange. So, we solve the leak and avoid possible accesses to the regcache and frame cache of the detached inferior, by clearing both the regcache and the frame cache. Tested on debian/amd64, natively, under Valgrind, and with make check RUNTESTFLAGS="--target_board=native-gdbserver". ==27679== VALGRIND_GDB_ERROR_BEGIN ==27679== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,942 of 3,400 ==27679== at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344) ==27679== by 0x5CDF71: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330) ==27679== by 0x5CE12A: get_thread_regcache (regcache.c:366) ==27679== by 0x5CE12A: get_current_regcache() (regcache.c:372) ==27679== by 0x4FF63D: post_create_inferior(target_ops*, int) (infcmd.c:452) ==27679== by 0x43AF62: core_target_open(char const*, int) (corelow.c:458) ==27679== by 0x408B68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1892) ... gdb/ChangeLog 2019-02-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * target.c (target_detach): Clear the regcache and the frame cache.
2019-02-27Handle \r\n in gdbreplayTom Tromey2-2/+22
I tried gdbreplay yesterday, but the remotelogfile I received was made on Windows, so the lines were terminated with \r\n rather than plain \n. This patch changes gdbreplay to allow \r\n line termination when reading the log file. gdb/gdbserver/ChangeLog 2019-02-27 Tom Tromey <tromey@adacore.com> * gdbreplay.c (logchar): Handle \r\n.
2019-02-27Test "set width/height -1"Pedro Alves2-0/+7
As a follow up to the previous commit, add a test for "set width/height -1", to make sure we don't overflow in readline with negative values either. gdb/testsuite/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * gdb.base/page.exp: Add tests for "set width/height -1".
2019-02-27Make 'show width/height' display "unlimited" when capped for readlinePedro Alves4-2/+42
When we cap the height/width sizes before passing to readline, tweak the corresponding command variable to show "unlimited": (gdb) set height 0x8000 (gdb) show height Number of lines gdb thinks are in a page is unlimited. Instead of the current output: (gdb) set height 0x8000 (gdb) show height Number of lines gdb thinks are in a page is 32768. gdb/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * utils.c (set_screen_size): When we cap the height/width sizes, tweak the corresponding command variable to show "unlimited": gdb/testsuite/ChangeLog: 2019-02-27 Pedro Alves <palves@redhat.com> * gdb.base/page.exp: Add tests for "set/show width/height" with "infinite" values.
2019-02-27Prevent overflow in rl_set_screen_sizeSaagar Jha2-4/+23
GDB calls rl_set_screen_size in readline with the current screen size, measured in rows and columns. To represent "infinite" sizes, GDB passes in INT_MAX; however, since rl_set_screen_size internally multiplies the number of rows and columns, this causes a signed integer overflow. To prevent this we can instead pass in the approximate square root of INT_MAX (which is still reasonably large), so that even when the number of rows and columns is "infinite" we don't overflow. gdb/ChangeLog: 2019-02-27 Saagar Jha <saagar@saagarjha.com> Pedro Alves <palves@redhat.com> * utils.c (set_screen_size): Reduce "infinite" rows and columns before calling rl_set_screen_size.