aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2014-09-10print PTR.all where PTR is an Ada thin pointerJoel Brobecker5-1/+194
Consider the following declaration: type Array_Type is array (Natural range <>) of Integer; type Array_Ptr is access all Array_Type; for Array_Ptr'Size use 64; Three_Ptr : Array_Ptr := new Array_Type'(1 => 1, 2 => 2, 3 => 3); This creates a pointer to an array where the bounds are stored in a memory region just before the array itself (aka a "thin pointer"). In DWARF, this is described as a the usual pointer type to an array whose subrange has dynamic values for its bounds: <1><25>: Abbrev Number: 4 (DW_TAG_array_type) <26> DW_AT_name : foo__array_type [...] <2><3b>: Abbrev Number: 5 (DW_TAG_subrange_type) [...] <40> DW_AT_lower_bound : 5 byte block: 97 38 1c 94 4 (DW_OP_push_object_address; DW_OP_lit8; DW_OP_minus; DW_OP_deref_size: 4) <46> DW_AT_upper_bound : 5 byte block: 97 34 1c 94 4 (DW_OP_push_object_address; DW_OP_lit4; DW_OP_minus; DW_OP_deref_size: 4) GDB is currently printing the value of the array incorrectly: (gdb) p foo.three_ptr.all $1 = (26629472 => 1, 2, value.c:819: internal-error: value_contents_bits_eq: [...] The dereferencing (".all" operator) is done by calling ada_value_ind, which itself calls value_ind. It first produces a new value where the bounds of the array were correctly resolved to their actual value, but then calls readjust_indirect_value_type which replaces the resolved type by the original type. The problem starts when ada_value_print does not take this situation into account, and starts using the type of the resulting value, which has unresolved array bounds, instead of using the value's enclosing type. After fixing this issue, the debugger now correctly prints: (gdb) p foo.three_ptr.all $1 = (1, 2, 3) gdb/ChangeLog: * ada-valprint.c (ada_value_print): Use VAL's enclosing type instead of VAL's type. gdb/testsuite/ChangeLog: * gdb.dwarf2/dynarr-ptr.c: New file. * gdb.dwarf2/dynarr-ptr.exp: New file.
2014-09-10Add <sys/uio.h> #include back in amd64-linux-nat.c.Joel Brobecker2-0/+5
This include is needed to access the definition of "struct iovec". gdb/ChangeLog: * amd64-linux-nat.c: Add <sys/uio.h> #include.
2014-09-09PR guile/17367Doug Evans4-7/+58
gdb/ChangeLog: * acinclude.m4 (GDB_GUILE_PROGRAM_NAMES): Pass guile version as last parameter to pkg-config, not first. * configure.ac: Pass --with-guile provided pkg-config path to GDB_GUILE_PROGRAM_NAMES. * configure: Regenerate.
2014-09-10Add myself as write-after-approval GDB maintainer.Gabriel Krisman Bertazi2-0/+6
gdb/ChangeLog: * MAINTAINERS (Write After Approval): Add "Gabriel Krisman Bertazi".
2014-09-10MIPS: Don't infer IRIX OS ABI from generic section namesMaciej W. Rozycki2-6/+16
There are `.MIPS.abiflags', `.MIPS.options' and `.MIPS.stubs' sections also present in Linux executables, so we can't infer IRIX OS ABI solely from the existence of these sections. This is not going to be a problem as there are bound to be other sections whose names start with `.MIPS.' in IRIX executables and this selection only matters for a non-default OS ABI in a multiple-target GDB executable. As a last resort the automatic selection can be overridden with `set osabi'. * mips-irix-tdep.c (mips_irix_elf_osabi_sniff_abi_tag_sections): Exclude `.MIPS.abiflags', `.MIPS.options' and `.MIPS.stubs' from the list of sections determining GDB_OSABI_IRIX.
2014-09-09Add myself as write-after-approval GDB maintainerJames Hogan2-0/+5
gdb/ChangeLog: * MAINTAINERS (Write After Approval): Add "James Hogan".
2014-09-09GDB/testsuite: Correct gdb.base/watchpoint-solib.exp timeout tweakMaciej W. Rozycki2-5/+20
Similarly to the previous changes to gdb.reverse/sigall-reverse.exp and gdb.reverse/until-precsave.exp this corrects the timeout tweak in gdb.base/watchpoint-solib.exp. This test case executes a large amount of code with a software watchpoint enabled. This means single-stepping all the way through and takes a lot of time, e.g. for an ARMv7 Panda board and a `-march=armv5te' multilib: PASS: gdb.base/watchpoint-solib.exp: continue to foo again elapsed: 714 for the same board and a `-mthumb -march=armv5te' multilib: PASS: gdb.base/watchpoint-solib.exp: continue to foo again elapsed: 1275 and for QEMU in the system emulation mode and a `-march=armv4t' multilib: PASS: gdb.base/watchpoint-solib.exp: continue to foo again elapsed: 115 (values in seconds) -- all of which having the default timeout of 60s, set based on the requirement of the remaining test cases (other than gdb.reverse ones). Here again the timeout extension to have a meaning should be calculated by scaling rather than using an arbitrary constant, and a larger factor of 30 will do, leaving some margin. Hopefully for everyone or otherwise we'll probably have to come up with a smarter solution. OTOH the other test cases in this script do not require the extension so they can be moved outside its umbrella so as to avoid unnecessary delays if something goes wrong and a genuine timeout triggers. * gdb.base/watchpoint-solib.exp: Increase the timeout by a factor of 30 rather than hardcoding 120 for a slow test case. Take the `gdb,timeout' target setting into account for this calculation. Don't extend the timeout for the test cases that don't need it.
2014-09-09GDB/testsuite: Add/correct gdb.reverse timeout tweaksMaciej W. Rozycki3-3/+29
There are three cases in two scripts in the gdb.reverse subset that take a particularly long time. Two of them are already attempted to take care of by extending the timeout from the default. The remaining one has no precautions taken. The timeout extension is ineffective though, it is done by adding a constant rather than by scaling and as a result while it may work for target boards that get satisfied with the detault test timeout of 10s, it does not serve its purpose for slower ones. Here are indicative samples of execution times (in seconds) observed for these cases respectively, for an ARMv7 Panda board running Linux and a `-march=armv5te' multilib: PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit elapsed: 385 PASS: gdb.reverse/until-precsave.exp: run to end of main elapsed: 4440 PASS: gdb.reverse/until-precsave.exp: save process recfile elapsed: 965 for the same board and a `-mthumb -march=armv5te' multilib: PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit elapsed: 465 PASS: gdb.reverse/until-precsave.exp: run to end of main elapsed: 4191 PASS: gdb.reverse/until-precsave.exp: save process recfile elapsed: 669 and for QEMU in the system emulation mode and a `-march=armv4t' multilib: PASS: gdb.reverse/sigall-reverse.exp: continue to signal exit elapsed: 45 PASS: gdb.reverse/until-precsave.exp: run to end of main elapsed: 433 PASS: gdb.reverse/until-precsave.exp: save process recfile elapsed: 104 Based on the performance of other tests these two test configurations have their default timeout set to 450s and 60s respectively. The remaining two multilibs (`-mthumb -march=armv4t' and `-mthumb -march=armv7-a') do not produce test results usable enough to have data available for these cases. Based on these results I have tweaked timeouts for these cases as follows. This, together with a suitable board timeout setting, removes timeouts for these cases. Note that for the default timeout of 10s the new setting for the first case in gdb.reverse/until-precsave.exp is compatible with the old one, just a bit higher to keep the convention of longer timeouts to remain multiples of 30s. The second case there does not need such a high setting so I have lowered it a bit to avoid an unnecessary delay where this test case genuinely times out. * gdb.reverse/sigall-reverse.exp: Increase the timeout by a factor of 2 for a slow test case. Take the `gdb,timeout' target setting into account for this calculation. * gdb.reverse/until-precsave.exp: Increase the timeout by a factor of 15 and 3 respectively rather than adding 120 for a pair of slow test cases. Take the `gdb,timeout' target setting into account for this calculation.
2014-09-09GDB/testsuite: Avoid timeout loweringMaciej W. Rozycki2-40/+23
The recent change to introduce `gdb_reverse_timeout' turned out ineffective for board setups that set the `gdb,timeout' target variable. A lower `gdb,timeout' setting takes precedence and defeats the effect of `gdb_reverse_timeout'. This is because the global timeout is overridden in gdb_test_multiple and then again in gdb_expect. Three timeout variables are taken into account in these two places, in this precedence: 1. The `gdb,timeout' target variable. 2. The caller's local `timeout' variable (upvar timeout) 3. The global `timeout' variable. This precedence is obeyed by gdb_test_multiple strictly. OTOH gdb_expect will select the higher of the two formers and will only take the latter into account if none of the formers is present. However the two timeout selections are conceptually the same and gdb_test_multiple does its only for the purpose of passing it down to gdb_expect. Therefore I decided there is no point to keep carrying on this duplication and removed the sequence from gdb_test_multiple, however retaining the `upvar timeout' variable definition. This way gdb_expect will still access gdb_test_multiple's caller `timeout' variable (if any) via its own `upvar timeout' reference. Now as to the sequence in gdb_expect. In addition to the three variables described above it also takes a timeout argument into account, as the fourth value to choose from. It is currently used if it is higher than the timeout selected from the variables as described above. With the timeout selection code from gdb_test_multiple gone, gone is also the most prominent use of this timeout argument, it's now used in a couple of places only, mostly within this test framework library code itself for preparatory commands or suchlike. With this being the case this timeout selection code can be simplified as follows: 1. Among the three timeout variables, the highest is always chosen. This is so that a test case doesn't inadvertently lower a high value timeout needed by slow target boards. This is what all test cases use. 2. Any timeout argument takes precedence. This is for special cases such as within the framework library code, e.g. it doesn't make sense to send `set height 0' with a timeout of 7200 seconds. This is a local command that does not interact with the target and setting a high timeout here only risks a test suite run taking ages if it goes astray for some reason. 3. The fallback timeout of 60s remains. * lib/gdb.exp (gdb_test_multiple): Remove code to select the timeout, don't pass one down to gdb_expect. (gdb_expect): Rework timeout selection.
2014-09-09Remove trad_frame_set_reg_unknown declarationJames Hogan2-2/+4
The trad_frame_set_reg_unknown declaration was added in commit 0db9b4b70969 (March 2004), but apparently never defined or referenced. gdb/ChangeLog: * trad-frame.h (trad_frame_set_reg_unknown): Remove declaration.
2014-09-09gdbserver-support: Handle gdbserver start failuresMaciej W. Rozycki3-6/+36
As it happens we have a board that fails a gdb.base/gcore-relro.exp test case reproducibly and moreover the case appears to trigger a kernel bug making the it less than usable. Specifically the board remains responsive to some extent, however processes do not appear to be able to successfully complete termination anymore and perhaps more importantly further gdbserver processes can be started, but they never reach the stage of listening on the RSP socket. This change handles timeouts in gdbserver start properly, by throwing a TCL error exception when gdbserver does not report listening on the RSP socket in time. This is then caught at the outer level and reported, and 2 rather than 1 is returned so that the caller may tell the failure to start gdbserver and other issues apart and act accordingly (or do nothing). I thought letting the exception unwind further on might be a good idea for any test harnesses out there to break outright where a gdbserver start error is silently ignored right now, however I figured out the calls to gdbserver-support.exp are buried down too deep in the GDB test suite for such a change to be made easily. I think returning a distinct return value is good enough (the API says "non-zero", so 2 is as good as 1) and we can always make the error harder in a later step if required. With config/gdbserver.exp being used this change remains transparent to the target board, the return value is passed up by gdb_reload and the error exception unwinds through gdbserver_gdb_load and is caught and handled by mi_gdb_target_load. A call to perror is still made, reporting the timeout, and in the case of mi_gdb_target_load the procedure returns a value denoting unsuccessful completion. An unsuccessful completion of gdb_reload is already handled elsewhere. An alternative gdbserver board configuration can interpret the return value in its gdb_reload implementation and catch the error in gdbserver_gdb_load in an attempt to recover a target board that has gone astray, for example by rebooting the board somehow. This has proved effective with our failing board, that now completes the remaining test cases with no further hiccups. * lib/gdbserver-support.exp (gdbserver_start): Throw an error exception on timeout. (gdbserver_run): Catch any `gdbserver_spawn' error exceptions. (gdbserver_start_extended): Catch any `gdbserver_start' error exceptions. (gdbserver_start_multi, mi_gdbserver_start_multi): Likewise. * lib/mi-support.exp (mi_gdb_target_load): Catch any `gdbserver_gdb_load' error exceptions.
2014-09-09GDB/testsuite: Extend the time gdbserver is waited forMaciej W. Rozycki2-0/+6
Gdbserver support code uses the global timeout value to determine when to stop waiting for a gdbserver process being started to respond before continuing anyway. This timeout is usually as low as 10s and may not be enough in this context, for example on the first run where the filesystem cache is cold, even if it is elsewhere. E.g. I observe this reliably with gdbserver started the first time in QEMU running in the system emulation mode: (gdb) file .../gdb.base/advance Reading symbols from .../gdb.base/advance...done. (gdb) delete breakpoints (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break main Breakpoint 1 at 0x87f8: file .../gdb.base/advance.c, line 41. (gdb) set remotetimeout 15 (gdb) kill The program is not being run. (gdb) [...] .../bin/gdbserver --once :6014 advance target remote localhost:6014 Remote debugging using localhost:6014 Remote communication error. Target disconnected.: Connection reset by peer. (gdb) continue The program is not being run. (gdb) Process advance created; pid = 999 Listening on port 6014 FAIL: gdb.base/advance.exp: Can't run to main -- notice how the test harness proceeded with the `target remote ...' command even though gdbserver hasn't completed its startup yet. A while later when it's finally ready it's too late already. I checked the timing here and it takes gdbserver roughly 25 seconds to start in this scenario. Subsequent gdbserver starts in the same test run take less time and usually complete within 10 seconds although occasionally `target remote ...' precedes the corresponding `Listening on port...' message again. Therefore I have fixed this problem by setting an explicit timeout to 120s on the expect call in question. If this turns out too arbitrary sometime, then perhaps a separate `gdbserver_timeout' setting might be due. * lib/gdbserver-support.exp (gdbserver_start): Set timeout to 120 on waiting for the TCP socket to open.
2014-09-09Fix missing "struct iovec" definition on some x86-linux.Joel Brobecker3-0/+6
The following patch... commit 3116063bd617de56fbc3bad046a692b1fb363a9d Date: Fri Jun 27 09:52:29 2014 +0100 Subject: Tidy #include lists ... introduced a build failure on certain x86 GNU/Linux distributions (reproduced on SuSE 10 and RHES4) due to "struct iovec" not being defined. This struct is defined in <sys/uio.h>, which used to be explicitly included, but no longer is after the commit above was applied. [...]/i386-linux-nat.c: In function 'fetch_xstateregs': [...]/i386-linux-nat.c:325:16: error: storage size of 'iov' isn't known [...]/i386-linux-nat.c: In function 'store_xstateregs': [...]/i386-linux-nat.c:348:16: error: storage size of 'iov' isn't known make[2]: *** [i386-linux-nat.o] Error 1 It seems to be working on newer GNU/Linux distros thanks to indirect inclusion of <sys/uio.h>, but it does not work on some other versions of the same distros. This is why indirect includes of public APIs should be avoided if at all possible. This patch fixes the issue by adding the explicit include back. gdb/ChangeLog: * i386-linux-nat.c, x86-linux-nat.c: Add <sys/uio.h> #include.
2014-09-08Fix regression in default.exp caused by _caller_is, etc.Doug Evans2-0/+9
gdb/testsuite/ChangeLog: * gdb.base/default.exp (show_conv_list): Add _caller_is, _caller_matches, _any_caller_is, _any_caller_matches.
2014-09-08Fix for PR 17247: Block SIGCHLD while initializing Guile.Doug Evans5-68/+53
The problem here is that if a thread other than gdb's main thread gets a SIGCHLD (it's an asynchronous signal so the kernel will essentially pick a random thread) then gdb will hang if it is in sigsuspend when the SIGCHLD is delivered. The other thread will see the signal and the sigsuspend won't "wake up". Guile and libgc should be blocking SIGCHLD in their threads, but we need to work with Guile 2.0 and libgc 7.4. The problem first shows up in libgc 7.4 because it is the first release that enables multiple marker threads by default. gdb/ChangeLog: PR 17247 * guile.c: #include <signal.h>. (_initialize_guile): Block SIGCHLD while initializing Guile. Replaces the following, which is reverted. 2014-07-26 Doug Evans <xdje42@gmail.com> PR 17185 * configure.ac: Add check for header gc/gc.h. Add check for function setenv. * configure: Regenerate. * config.in: Regenerate. * guile/guile.c (_initialize_guile): Add workaround for libgc 7.4.0.
2014-09-08gdb.guile/scm-error.exp: Handle guile 2.2 backtrace output.Doug Evans2-1/+5
gdb/testsuite/ChangeLog: * gdb.guile/scm-error.exp: Handle guile 2.2 backtrace output.
2014-09-08Replace use of magic number with named constant.Doug Evans3-2/+8
gdb/ChangeLog: * guile/scm-cmd.c (gdbscm_parse_command_name): Replace magic number with named constant. Fix style of pointer comparison. * python/py-cmd.c (gdbpy_parse_command_name): Ditto.
2014-09-09Set print symbol off in mi-var-display.expYao Qi2-0/+7
Hi, I see the following fail on arm-none-eabi target, -var-evaluate-expression -f nat foo^M ^done,value="0x3 <_ftext+2>"^M (gdb) ^M FAIL: gdb.mi/mi-var-display.exp: eval variable -f nat foo the "<_ftext+2>" isn't expected in the test, so "set print symbol off" can prevent printing it. It is obvious and I'll commit it in three days if no comments. gdb/testsuite: 2014-09-09 Yao Qi <yao@codesourcery.com> * gdb.mi/mi-var-display.exp: Set print symbol off.
2014-09-08Fix ppc_collect/supply_ptrace_register() routinesEdjunior Barbosa Machado2-9/+42
This patch fixes the routines to collect and supply ptrace registers on ppc64le gdbserver. Originally written for big endian arch, they were causing several issues on little endian. With this fix, the number of unexpected failures in the testsuite dropped from 263 to 72 on ppc64le. gdb/gdbserver/ChangeLog * linux-ppc-low.c (ppc_collect_ptrace_register): Adjust routine to take endianness into account. (ppc_supply_ptrace_register): Likewise.
2014-09-07Fix PR gdb/17035: "show user" doesn't list user-defined commands thatGabriel Krisman Bertazi9-5/+67
have empty bodies. User-defined commands that have empty bodies weren't being shown because the print function returned too soon. Now, it prints the command's name before checking if it has any body at all. This also fixes the same problem on "show user <myemptycommand>", which wasn't being printed due to a similar reason. gdb/Changelog: * cli/cli-cmds.c (show_user): Use cli_user_command_p to decide whether we display the command on "show user". * cli/cli-script.c (show_user_1): Only verify cmdlines after printing command name. * cli/cli-decode.h (cli_user_command_p): Declare new function. * cli/cli-decode.c (cli_user_command_p): Create helper function to verify whether cmd_list_element is a user-defined command. gdb/testsuite/Changelog: * gdb.base/commands.exp: Add tests to verify user-defined commands with empty bodies. * gdb.python/py-cmd.exp: Test that we don't show user-defined python commands in `show user command`. * gdb.python/scm-cmd.exp: Test that we don't show user-defined scheme commands in `show user command`.
2014-09-07Fix crash on Python frame filters with unreadable argJan Kratochvil7-15/+467
https://bugzilla.redhat.com/show_bug.cgi?id=1126177 ERROR: AddressSanitizer: SEGV on unknown address 0x000000000050 (pc 0x000000992bef sp 0x7ffff9039530 bp 0x7ffff9039540 T0) #0 0x992bee in value_type .../gdb/value.c:925 #1 0x87c951 in py_print_single_arg python/py-framefilter.c:445 #2 0x87cfae in enumerate_args python/py-framefilter.c:596 #3 0x87e0b0 in py_print_args python/py-framefilter.c:968 It crashes because frame_arg::val is documented it may contain NULL (frame_arg::error is then non-NULL) but the code does not handle it. Another bug is that py_print_single_arg() calls goto out of its TRY_CATCH which messes up GDB cleanup chain crashing GDB later. It is probably 7.7 regression (I have not verified it) due to the introduction of Python frame filters. gdb/ChangeLog PR python/17355 * python/py-framefilter.c (py_print_single_arg): Handle NULL FA->VAL. Fix goto out of TRY_CATCH. gdb/testsuite/ChangeLog PR python/17355 * gdb.python/amd64-py-framefilter-invalidarg.S: New file. * gdb.python/py-framefilter-invalidarg-gdb.py.in: New file. * gdb.python/py-framefilter-invalidarg.exp: New file. * gdb.python/py-framefilter-invalidarg.py: New file.
2014-09-06Add missing author to previous entry (PR 15276).Doug Evans1-0/+1
2014-09-06PR 15276: Add $_caller_is, $_caller_matches, $_any_caller_is, ↵Doug Evans9-0/+366
$_any_caller_matches gdb/ChangeLog: PR 15276 * NEWS: Mention $_caller_is, $_caller_matches, $_any_caller_is, $_any_caller_matches. * data-directory/Makefile.in (PYTHON_FILE_LIST): Add caller_is.py. * python/lib/gdb/function/caller_is.py: New file. gdb/testsuite/ChangeLog: PR 15276 * gdb.python/py-caller-is.c: New file. * gdb.python/py-caller-is.exp: New file. gdb/doc/ChangeLog: PR 15276 * gdb.texinfo (Convenience Funs): Document $_caller_is, $_caller_matches, $_any_caller_is, $_any_caller_matches.
2014-09-06infcmd.c (program_info): Fix typo.Doug Evans2-1/+5
gdb/ChangeLog: * infcmd.c (program_info): Fix typo.
2014-09-05Fix for PR gdb/17235: possible bug extracting systemtap probe operandSergio Durigan Junior5-18/+103
This patch is a fix to PR gdb/17235. The bug is about an unused variable that got declared and set during one of the parsing phases of an SDT probe's argument. I took the opportunity to rewrite some of the code to improve the parsing. The bug was actually a thinko, because what I wanted to do in the code was to discard the number on the string being parsed. During this portion, the code identifies that it is dealing with an expression that begins with a sign ('+', '-' or '~'). This means that the expression could be: - a numeric literal (e.g., '+5') - a register displacement (e.g., '-4(%rsp)') - a subexpression (e.g., '-(2*3)') So, after saving the sign and moving forward 1 char, now the code needs to know if there is a digit followed by a register displacement prefix operand (e.g., '(' on x86_64). If yes, then it is a register operation. If not, then it will be handled recursively, and the code will later apply the requested operation on the result (either a '+', a '-' or a '~'). With the bug, the code was correctly discarding the digit (though using strtol unnecessarily), but it wasn't properly dealing with subexpressions when the register indirection prefix was '(', like on x86_64. This patch also fixes this bug, and includes a testcase. It passes on x86_64 Fedora 20.
2014-09-04parse_number("0") reads uninitialized memoryPedro Alves2-1/+6
valgrind caught that parse_number reads uninitialized memory when we parse literal "0": $ valgrind ./gdb -q -nx -ex "set height 0" (...) ==10378== Conditional jump or move depends on uninitialised value(s) ==10378== at 0x548A10: parse_number (c-exp.y:1828) ==10378== by 0x54A340: lex_one_token (c-exp.y:2638) ==10378== by 0x54B4BB: c_lex (c-exp.y:3089) ==10378== by 0x544951: c_parse_internal (c-exp.c:2208) ==10378== by 0x54BF8C: c_parse (c-exp.y:3260) ==10378== by 0x6502E7: parse_exp_in_context_1 (parse.c:1221) ==10378== by 0x650064: parse_exp_in_context (parse.c:1122) ==10378== by 0x65001F: parse_exp_1 (parse.c:1114) ==10378== by 0x650421: parse_expression (parse.c:1266) ==10378== by 0x5A74B7: parse_and_eval_long (eval.c:92) ==10378== by 0x501ABD: do_set_command (cli-setshow.c:302) ==10378== by 0x721059: execute_command (top.c:452) ==10378== (gdb) I've pushed the obvious fix. Tested on x86_64 Fedora 20. gdb/ChangeLog: * c-exp.y (parse_number): Skip handling base-switching prefixes if the input is only one character long.
2014-09-04Fix PR fortran/17237: bug in f-valprint.cSergio Durigan Junior5-1/+72
This commit fixes the PR mentioned in $subject. It is about a set but unused variable that refers to the output format of integer values printed in Fortran. This was probably a thinko (like most set-but-unused-vars), but it could cause an internal error depending on the scenario. I am sending a testcase which triggers this error as well. gdb/ChangeLog: 2014-09-04 Sergio Durigan Junior <sergiodj@redhat.com> PR fortran/17237 * f-valprint.c (f_val_print): Specify the correct print option to use when printing integer values. gdb/testsuite/ChangeLog: 2014-09-04 Sergio Durigan Junior <sergiodj@redhat.com> PR fortran/17237 * gdb.fortran/print-formatted.exp: New file. * gdb.fortran/print-formatted.f90: Likewise.
2014-09-04Remove code to cope with LWPs wrapped as PIDsGary Benson2-4/+8
Historically the Linux x86 watchpoint code did not cope with multi- threaded processes and LWP IDs were passed to it wrapped as PIDs. Not all entry points were converted when the Linux x86 watchpoint code was made multi-thread-aware, so a handler was left in place to cope with wrapped LWPs. Since then all such entry points have been converted to pass regular LWPs and the handler is now redundant. This commit removes the handler and adds assertions to ensure no wrapped LWPs are passed in future. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_dr_get, x86_linux_dr_set): Remove code to cope with LWPs wrapped as PIDs. Add assertions to ensure no wrapped LWPs are passed.
2014-09-04Regression for i686 gdb.dwarf2/pieces-optimized-out.expPedro Alves3-125/+125
Git 9a0dc9e3 regressed gdb.dwarf2/pieces-optimized-out.exp, visible on i686 (the test doesn't run on x86_64): (gdb) p s -$1 = {a = 5, b = <optimized out>, c = <optimized out>, d = <optimized out>} +$1 = {a = 5, b = <optimized out>, c = 0, d = 0} -(gdb) PASS: gdb.dwarf2/pieces-optimized-out.exp: print s +(gdb) FAIL: gdb.dwarf2/pieces-optimized-out.exp: print s The regression was caused by this removal in cp-valprint.c: @@ -293,12 +293,6 @@ cp_print_value_fields (struct type *type, struct type *real_type, { fputs_filtered (_("<synthetic pointer>"), stream); } - else if (!value_bits_valid (val, - TYPE_FIELD_BITPOS (type, i), - TYPE_FIELD_BITSIZE (type, i))) - { - val_print_optimized_out (val, stream); - } else { struct value_print_options opts = *options; The idea was that we'd just fallback to calling value_field_bitfield, which handles unavailable values (in unpack_value_bits_as_long_1) so should be able to handle optimized out values too. Alas, it doesn't. This is currently a bit too messy. Instead of teaching unpack_value_bits_as_long_1 about optimized out bits, let's bite the bullet and teach the value code to handle partially optimized out bitfield, by having it unpack a bitfield and then propagate the range metadata. Turns out the resulting code looks simpler and clearer. Tested on x86_64 Fedora 20, -m64/-m32. gdb/ChangeLog: * value.c (value_ranges_copy_adjusted): New function, factored out from ... (value_contents_copy_raw): ... here. (unpack_value_bits_as_long_1): Rename back to ... (unpack_bits_as_long): ... this. Remove 'original_value' and 'result' parameters. Change return type to LONGEST. (unpack_value_bits_as_long): Delete. (unpack_value_field_as_long_1): Delete. (unpack_value_field_as_long, unpack_field_as_long): Reimplement. (unpack_value_bitfield): New function. (value_field_bitfield): Reimplement using unpack_value_bitfield. (value_fetch_lazy): Use unpack_value_bitfield. * value.h (unpack_value_bits_as_long): Delete declaration.
2014-09-03Improve Type.template_argument docs in Python API.Justin Lebar2-4/+11
gdb/doc/ChangeLog: * python.texi (Types In Python): Type.template_argument(n) returns a gdb.Value or a gdb.Type and throws an exception if n is out of range.
2014-09-03Add support for reading frame registers to Python API.Sasha Smundak7-0/+77
The ability to read registers is needed to use Frame Filter API to display the frames created by JIT compilers. gdb/ChangeLog: 2014-08-29 Sasha Smundak <asmundak@google.com> * python/py-frame.c (frapy_read_register): New function. gdb/doc/ChangeLog: 2014-08-26 Sasha Smundak <asmundak@google.com> * python.texi (Frames in Python): Add read_register description. gdb/testsuite/ChangeLog: 2014-08-26 Sasha Smundak <asmundak@google.com> * gdb.python/py-frame.exp: Test Frame.read_register.
2014-09-03Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROLJames Hogan4-0/+12
PTRACE_PEEKUSER can return -1, which is usually used to determine whether a system call has reported an error, so errno must be used alone to determine whether an error occurred. However errno isn't modified by a successful system call so it must be reset to a known value (0) before the syscall call. Add the missing errno reset when reading the DSP_CONTROL register in the native MIPS Linux backend and the MIPS gdbserver backend. gdb/: * mips-linux-nat.c (mips_linux_read_description): Reset errno to 0 prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. gdb/gdbserver/: * linux-mips-low.c (mips_read_description): Reset errno to 0 prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call.
2014-09-03PR python/16699: GDB Python command completion with overriden complete vs. ↵Sergio Durigan Junior10-28/+359
completer class This PR came from a Red Hat bug that was filed recently. I checked and it still exists on HEAD, so here's a proposed fix. Although this is marked as a Python backend bug, this is really about the completion mechanism used by GDB. Since this code reminds me of my first attempt to make a good noodle, it took me quite some time to fix it in a non-intrusive way. The problem is triggered when one registers a completion method inside a class in a Python script, rather than registering the command using a completer class directly. For example, consider the following script: class MyFirstCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'myfirstcommand',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') class MySecondCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'mysecondcommand',gdb.COMMAND_USER) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') def complete(self,text,word): return gdb.COMPLETE_FILENAME MyFirstCommand () MySecondCommand () When one loads this into GDB and tries to complete filenames for both myfirstcommand and mysecondcommand, she gets: (gdb) myfirstcommand /hom<TAB> (gdb) myfirstcommand /home/ ^ ... (gdb) mysecondcommand /hom<TAB> (gdb) mysecondcommand /home ^ (The "^" marks the final position of the cursor after the TAB). So we see that myfirstcommand honors the COMPLETE_FILENAME class (as specified in the command creation), but mysecondcommand does not. After some investigation, I found that the problem lies with the set of word break characters that is used for each case. The set should be the same for both commands, but it is not. During the process of deciding which type of completion should be used, the code in gdb/completer.c:complete_line_internal analyses the command that requested the completion and tries to determine the type of completion wanted by checking which completion function will be called (e.g., filename_completer for filenames, location_completer for locations, etc.). This all works fine for myfirstcommand, because immediately after the command registration the Python backend already sets its completion function to filename_completer (which then causes the complete_line_internal function to choose the right set of word break chars). However, for mysecondcommand, this decision is postponed to when the completer function is evaluated, and the Python backend uses an internal completer (called cmdpy_completer). complete_line_internal doesn't know about this internal completer, and can't choose the right set of word break chars in time, which then leads to a bad decision when completing the "/hom" word. So, after a few attempts, I decided to create another callback in "struct cmd_list_element" that will be responsible for handling the case when there is an unknown completer function for complete_line_internal to work with. So far, only the Python backend uses this callback, and only when the user provides a completer method instead of registering the command directly with a completer class. I think this is the best option because it not very intrusive (all the other commands will still work normally), but especially because the whole completion code is so messy that it would be hard to fix this without having to redesign things. I have regtested this on Fedora 18 x86_64, without regressions. I also included a testcase. gdb/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * cli/cli-decode.c (set_cmd_completer_handle_brkchars): New function. (add_cmd): Set "completer_handle_brkchars" to NULL. * cli/cli-decode.h (struct cmd_list_element) <completer_handle_brkchars>: New field. * command.h (completer_ftype_void): New typedef. (set_cmd_completer_handle_brkchars): New prototype. * completer.c (set_gdb_completion_word_break_characters): New function. (complete_line_internal): Call "completer_handle_brkchars" callback from command. * completer.h: Include "command.h". (set_gdb_completion_word_break_characters): New prototype. * python/py-cmd.c (cmdpy_completer_helper): New function. (cmdpy_completer_handle_brkchars): New function. (cmdpy_completer): Adjust to use cmdpy_completer_helper. (cmdpy_init): Set completer_handle_brkchars to cmdpy_completer_handle_brkchars. gdb/testsuite/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * gdb.python/py-completion.exp: New file. * gdb.python/py-completion.py: Likewise.
2014-09-03x86 debug address register clarificationsGary Benson7-12/+27
The loop macro ALL_DEBUG_REGISTERS does not iterate over the status or control registers, so its name is misleading. This commit renames it as ALL_DEBUG_ADDRESS_REGISTERS and updates all uses. This commit also updates its loop conditions to an equivalent but better form, and makes two functions use it that had previously hardwired the loop. A comment on a related field in the x86_debug_reg_state structure is also updated to reflect that the field refers specifically to address registers only. gdb/ChangeLog: * nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as... (ALL_DEBUG_ADDRESS_REGISTERS): New macro. All uses updated. Loop conditions changed to equivalent form. (struct x86_debug_reg_state): Updated dr_ref_count comment. * x86-linux-nat.c (x86_linux_prepare_to_resume): Use ALL_DEBUG_ADDRESS_REGISTERS. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_prepare_to_resume): Use ALL_DEBUG_ADDRESS_REGISTERS.
2014-09-03Fix dwarf2loc.h::dwarf2_evaluate_property function description.Joel Brobecker2-2/+7
gdb/ChangeLog: * dwarf2loc.h (dwarf2_evaluate_property): Minor function description fix.
2014-09-02typeprint.c (find_global_typedef): Fix comment.Doug Evans2-2/+6
gdb/ChangeLog: * typeprint.c (find_global_typedef): Fix comment.
2014-09-02Rename 32- and 64-bit Intel files from "i386" to "x86"Gary Benson47-629/+664
This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-09-02Use XCNEW rather than xcalloc (1, ...) in linux-x86-low.cGary Benson2-2/+7
This commit replaces two uses of xcalloc (1, ...) with XCNEW. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_new_process): Use XCNEW. (x86_linux_new_thread): Likewise.
2014-09-01Move `_initialize_varobj' to the end of varobj.cMaciej W. Rozycki2-18/+22
* varobj.c (_initialize_varobj): Move to the end of file.
2014-08-29Use exceptions and cleanups in gdbserverGary Benson4-97/+125
This commit replaces the hacky "exception" system in gdbserver with the exceptions and cleanups subsystem from GDB. Only the catch/cleanup code in what was "main" has been updated to use the new system. Other parts of gdbserver can now be converted to use TRY_CATCH and cleanups on an as-needed basis. A side-effect of this commit is that some error messages will change slightly, and in cases with multiple errors the error messages will be printed in a different order. gdb/gdbserver/ChangeLog: * server.h (setjmp.h): Do not include. (toplevel): Do not declare. (common-exceptions.h): Include. (cleanups.h): Likewise. * server.c (toplevel): Do not define. (exit_code): New static global. (detach_or_kill_for_exit_cleanup): New function. (main): New function. Original main renamed to... (captured_main): New function. * utils.c (verror) [!IN_PROCESS_AGENT]: Use throw_verror.
2014-08-29Introduce common/common-exceptions.[ch]Gary Benson9-438/+570
This commit moves the exception throwing and catching code into gdb/common/. All exception printing code remains in gdb/exceptions.[ch]. gdb/ChangeLog: * common/common-exceptions.h: New file. * common/common-exceptions.c: Likewise. * Makefile.in (SFILES): Add common/common-exceptions.c. (HFILES_NO_SRCDIR): Add common/common-exceptions.h. (COMMON_OBS): Add common-exceptions.o. (common-exceptions.o): New rule. * exceptions.h (common-exceptions.h): Include. (gdb_setjmp.h): Do not include. (return_reason): Moved to common-exceptions.h. (enum return_reason): Likewise. (RETURN_MASK): Likewise. (typedef return_mask): Likewise. (enum errors): Likewise. (struct gdb_exception): Likewise. (exceptions_state_mc_init): Likewise. (exceptions_state_mc_action_iter): Likewise. (exceptions_state_mc_action_iter_1): Likewise. (TRY_CATCH): Likewise. (throw_exception): Likewise. (throw_verror): Likewise. (throw_vquit): Likewise. (throw_error): Likewise. (throw_quit): Likewise. * exceptions.c (enum catcher_state): Moved to common-exceptions.c. (enum catcher_action): Likewise. (struct catcher): Likewise. (current_catcher): Likewise. (catcher_list_size): Likewise. (exceptions_state_mc_init): Likewise. (catcher_pop): Likewise. (exceptions_state_mc): Likewise. (exceptions_state_mc_action_iter): Likewise. (exceptions_state_mc_action_iter_1): Likewise. (throw_exception): Likewise. (exception_messages): Likewise. (exception_messages_size): Likewise. (throw_it): Likewise. (throw_verror): Likewise. (throw_vquit): Likewise. (throw_error): Likewise. (throw_quit): Likewise. (prepare_to_throw_exception): New function. gdb/gdbserver/ChangeLog: * Makefile.in (SFILES): Add common/common-exceptions.c. (OBS): Add common-exceptions.o. (common-exceptions.o): New rule. * utils.c (prepare_to_throw_exception): New function.
2014-08-29Introduce common/gdb_setjmp.hGary Benson12-81/+148
This commit creates a new file, common/gdb_setjmp.h, to hold some portability macros for setjmp/longjmp et al. that are used by the exceptions subsystem and by the demangler crash catcher. gdb/ChangeLog: * common/gdb_setjmp.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h. * configure.ac: Move sigsetjmp check... * common/common.m4: ...here. * configure: Regenerate. * cp-support.c (SIGJMP_BUF): Delete. (SIGSETJMP): Likewise. (SIGLONGJMP): Likewise. * exceptions.h (gdb_setjmp.h): Include. (setjmp.h): Do not include. (EXCEPTIONS_SIGJMP_BUF): Delete. (EXCEPTIONS_SIGSETJMP): Likewise. (EXCEPTIONS_SIGLONGJMP): Likewise. Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros from gdb_setjmp.h. * exceptions.c: Likewise. gdb/gdbserver/ChangeLog: * config.in: Regenerate. * configure: Likewise.
2014-08-29Move cleanups.[ch] to commonGary Benson6-6/+31
This commit moves cleanups.[ch] into gdb/common/. The only change to the content of the files is that cleanups.c's include list was altered to match its new location. gdb/ChangeLog: * cleanups.h: Moved to... * common/cleanups.h: New file. * cleanups.c: Moved to... * common/cleanups.c: New file. Include common-defs.h and cleanups.h. Do not include defs.h. * Makefile.in (SFILES): Replace cleanups.c with common/cleanups.c. (HFILES_NO_SRCDIR): Replace cleanups.h with common/cleanups.h. (cleanups.o): New rule. gdb/gdbserver/ChangeLog: * Makefile.in (SFILES): Add common/cleanups.c. (OBS): cleanups.o. (cleanups.o): New rule.
2014-08-29Move internal_{,v}warning to common/errors.[ch]Gary Benson7-17/+51
This commit moves internal_warning and internal_vwarning into common/errors.[ch]. gdb/ChangeLog: * common/errors.h (internal_warning): New declaration. (internal_vwarning): Likewise. * common/errors.c (internal_warning): New function. * utils.h (internal_warning): Don't declare. (internal_vwarning): Likewise. * utils.c (internal_warning): Removed. gdb/gdbserver/ChangeLog: * utils.c (internal_vwarning): New function.
2014-08-29Unify startup and option-parsing warningsGary Benson2-21/+15
Various warnings are emitted during startup and option-parsing using fprintf_unfiltered. One warning is prefixed with the command name, the others are not. This commit replaces these hardwired warnings with calls to warning. It also sets warning_pre_print to prefix all warnings with the command name until option parsing is complete. gdb/ChangeLog: * main.c (captured_main): Use warning during startup. Prefix startup warning messages with command name.
2014-08-29Replace all usage errors with calls to errorGary Benson2-30/+14
This commit replaces the hardwired fprintf/exit error handlers for usage errors with calls to error. gdb/ChangeLog: * main.c (captured_main): Handle usage errors with error.
2014-08-29Replace hardwired error handler in go32_create_inferiorGary Benson2-6/+11
go32_create_inferior invokes a hardwired fprintf/exit error handler if v2loadimage fails. I could find no reason for this other than that the block seems to have been copy-and-pasted from v2loadimage's manpage. This commit replaces the hardwired handler with a call to error. gdb/ChangeLog: * go32-nat.c (go32_create_inferior): Replace a fprintf/ exit pair with a call to error. Wrap the message with _().
2014-08-29Replace hardwired error handler in captured_mainGary Benson2-6/+6
If the requested interpreter cannot be set captured_main reports the error with a hardwired fprintf/exit pair. A fprintf/exit pair on the previous line was replaced with a call to error in March 2003 (https://sourceware.org/ml/gdb-patches/2003-03/msg00444.html) but I found no documentation as to why this particular hardwired handler was left untouched. I was also unable to come up with a situation where error would not be suitable, so I have replaced it with a call to error. gdb/ChangeLog: * main.c (captured_main): Replace a fprintf/exit pair with a call to error. Wrap the message with _().
2014-08-29Replace hardwired error handlers in tui_initialize_ioGary Benson2-8/+9
tui_initialize_io contains a pair of hardwired fprintf/exit error handlers. I was unable to find any documentation as to why they're hardwired (the code appeared in a monolithic block back in 2001: https://sourceware.org/ml/gdb-patches/2001-07/msg00490.html) and I was also unable to come up with a situation where error would not be suitable, so I have replaced both handlers with calls to error. gdb/ChangeLog: * tui/tui-io.c (tui_initialize_io): Replace two fprintf/exit pairs with calls to error. Wrap the message with _().
2014-08-29Make warning usable earlierGary Benson2-2/+9
warning will crash if called before the first call to set_width. This commit makes the warning usable from the moment gdb_stderr is set up. gdb/ChangeLog: * utils.c (vwarning): Protect calls to target_terminal_ours and wrap_here.