aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2014-07-14Remove the target from the event loop while in secondary promptsPedro Alves5-0/+146
If a pagination prompt triggers while the target is running, and the target exits before the user responded to the pagination query, this happens: Starting program: foo ---Type <return> to continue, or q <return> to quit---No unwaited-for children left. Couldn't get registers: No such process. Couldn't get registers: No such process. Couldn't get registers: No such process. (gdb) Couldn't get registers: No such process. (gdb) To reiterate, the user hasn't replied to the pagination prompt above. A pagination query nests an event loop (in gdb_readline_wrapper). In async mode, in addition to stdin and signal handlers, we'll have the target also installed in the event loop still. So if the target reports an event, that wakes up the nested event loop, which calls into fetch_inferior_event etc. to handle the event which generates further output, all while we should be waiting for pagination confirmation... (TBC, any target event that generates output ends up spuriously waking up the pagination, though exits seem to be the worse kind.) I've played with a couple different approaches to fixing this, while at the same time trying to avoid being invasive. Both revolve around not listening to target events while in a pagination prompt (doing anything else I think would be a much bigger change). The approach taken just removes the target from the event loop while within gdb_readline_wrapper. The other approach used gdb_select directly, with only input_fd installed, but that had the issue that it didn't handle the async signal handlers, and turned out to be a bit more code than the first version. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * top.c: Include "inf-loop.h". (struct gdb_readline_wrapper_cleanup) <target_is_async_orig>: New field. (gdb_readline_wrapper_cleanup): Make the target async again, if it was async before. (gdb_readline_wrapper): Store whether the target is async, and make it sync. gdb/testsuite/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * gdb.base/paginate-inferior-exit.c: New file. * gdb.base/paginate-inferior-exit.exp: New file.
2014-07-14Background execution + pagination aborts readline/gdbPedro Alves5-1/+180
If pagination occurs as result of output sent as response to a target event while the target is executing in the background, subsequent input aborts readline/gdb: $ gdb program ... (gdb) continue& Continuing. (gdb) ---Type <return> to continue, or q <return> to quit--- *return* ---Type <return> to continue, or q <return> to quit--- Breakpoint 2, after_sleep () at paginate-bg-execution.c:21 ---Type <return> to continue, or q <return> to quit--- 21 return; /* after sleep */ p 1 readline: readline_callback_read_char() called with no handler! *abort/SIGABRT* $ gdb_readline_wrapper_line removes the handler after a line is processed. Usually, we'll end up re-displaying the prompt, and that reinstalls the handler. But if the output is coming out of handling a stop event, we don't re-display the prompt, and nothing restores the handler. So the next input wakes up the event loop and calls into readline, which aborts. We should do better with the prompt handling while the target is running (I think we should coordinate with readline, and hide/redisplay it around output), but that's a more invasive change better done post 7.8, so this patch is conservative and just reinstalls the handler as soon as we're out of the readline line callback. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * top.c (gdb_readline_wrapper_line): Tweak comment. (gdb_readline_wrapper_cleanup): If readline is enabled, reinstall the input handler callback. gdb/testsuite/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * gdb.base/paginate-bg-execution.c: New file. * gdb.base/paginate-bg-execution.exp: New file.
2014-07-14Canceling pagination caused by execution command from command line aborts ↵Pedro Alves6-20/+310
readline/gdb This fixes: $ ./gdb program -ex "set height 2" -ex "start" ... Reading symbols from /home/pedro/gdb/tests/threads...done. ---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit *type something* readline: readline_callback_read_char() called with no handler! Aborted $ Usually, if an error propagates all the way to the top level, we'll re-enable stdin, in case the command that was running was a synchronous command. That's done in the event loop's actual loop (event-loop.c:start_event_loop). However, if a foreground execution command is run before the event loop starts and throws, nothing is presently reenabling stdin, which leaves sync_execution set. When we do start the event loop, because sync_execution is still (mistakenly) set, display_gdb_prompt removes the readline input callback, even though stdin is registered in the event loop. Any input from here on results in readline aborting. Such commands are run through catch_command_errors, catch_command_errors_const, so add the tweak there. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * main.c: Include event-top.h. (handle_command_errors): New function. (catch_command_errors, catch_command_errors_const): Use it. gdb/testsuite/ 2014-07-14 Pedro Alves <palves@redhat.com> PR gdb/17072 * gdb.base/paginate-execution-startup.c: New file. * gdb.base/paginate-execution-startup.exp: New file. * lib/gdb.exp (pagination_prompt): New global. (default_gdb_spawn): New procedure, factored out from default_gdb_spawn. (default_gdb_start): Adjust to call default_gdb_spawn. (gdb_spawn): New procedure.
2014-07-14testsuite: Introduce gdb_assertPedro Alves3-5/+28
Often we'll do something like: if {$ok} { fail "whatever" } else { pass "whatever" } This adds a helper procedure for that, and converts one random place to use it, as an example. 2014-07-14 Pedro Alves <palves@redhat.com> * lib/gdb.exp (gdb_assert): New procedure. * gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Use it.
2014-07-14Move catch_command_errors and catch_command_errors_const to main.cPedro Alves4-45/+57
We'll need to add error handling code to commands run before the event loop starts (commands in .gdbinit, -ex commands, etc.). Turns out those are run through catch_command_errors, and, catch_command_errors is used nowhere else. Move it (and the _const variant) to main.c, so that we can further specialize it freely. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> * exceptions.c (catch_command_errors, catch_command_errors_const): Moved to main.c. * exceptions.h (catch_command_errors_ftype) (catch_command_errors_const_ftype): Moved to main.c. (catch_command_errors, catch_command_errors_const): Delete declarations. * main.c (catch_command_errors_ftype) (catch_command_errors_const_ftype): Moved here from exceptions.h. (catch_command_errors, catch_command_errors_const)): Moved here from exceptions.c and make static.
2014-07-14Eliminate exceptions.c:print_any_exception.Pedro Alves2-22/+14
exception_print and exception_fprintf call print_flush, which does all the same flushing and annotation things that print_any_exception does, and more. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> * exceptions.c (print_any_exception): Delete. (catch_exceptions_with_msg): Use exception_print instead of print_any_exception. (catch_errors): Use exception_fprintf instead of print_any_exception. (catch_command_errors, catch_command_errors_const): Use exception_print instead of print_any_exception.
2014-07-14Put the inferior's terminal settings in effect while running (fg) infcallsPedro Alves5-0/+112
The "call" and "print" commands presently always run synchronously, in the foreground, but GDB currently forgets to put the inferior's terminal settings into effect while running them, on async-capable targets, resulting in: (gdb) print func () hello world Program received signal SIGTTOU, Stopped (tty output). 0x000000373bceb8d0 in __libc_tcdrain (fd=1) at ../sysdeps/unix/sysv/linux/tcdrain.c:29 29 return INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1); The program being debugged was signaled while in a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior use "set unwindonsignal on". Evaluation of the expression containing the function (func) will be abandoned. When the function is done executing, GDB will silently stop. (gdb) That's because target_terminal_inferior skips actually doing anything if running in the background, and, nothing is setting sync_execution while running infcalls: void target_terminal_inferior (void) { /* A background resume (``run&'') should leave GDB in control of the terminal. Use target_can_async_p, not target_is_async_p, since at this point the target is not async yet. However, if sync_execution is not set, we know it will become async prior to resume. */ if (target_can_async_p () && !sync_execution) return; This would best be all cleaned up by making GDB not even call target_terminal_inferior and try to pass the terminal to the inferior if running in the background, but that's a more invasive fix that is better done post-7.8. This was originally caught by a patch later in this series that makes catch_command_errors use exception_print instead of print_any_exception. Note that print_flush calls serial_drain_output while print_any_exception doesnt't have that bit. And, gdb.gdb/python-selftest.exp does: gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \ "Python not initialized.* = 0" which without this fix results in SIGTTOU... gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> * infcall.c (run_inferior_call): Set 'sync_execution' while running the inferior call. gdb/testsuite/ 2014-07-14 Pedro Alves <palves@redhat.com> * gdb.base/execution-termios.c: New file. * gdb.base/execution-termios.exp: New file.
2014-07-14Garbage collect value_contents_equal.Pedro Alves3-20/+5
Hasn't been used in years. gdb/ 2014-07-14 Pedro Alves <palves@redhat.com> * value.c (value_contents_equal): Delete function. * value.h (value_contents_equal): Delete declaration.
2014-07-14fix PR 17106Tom Tromey5-15/+142
This fixes PR 17106, a regression in printing. The bug is that resolve_dynamic_type follows struct members and references, but doesn't consider the possibility of infinite recursion. This patch fixes the problem by limiting reference following to the topmost layer of calls -- that is, reference-typed struct members are never considered as being VLAs. Built and regtested on x86-64 Fedora 20. New test case included. 2014-07-14 Tom Tromey <tromey@redhat.com> PR exp/17106: * gdbtypes.c (is_dynamic_type_internal): New function, from is_dynamic_type. (is_dynamic_type): Rewrite. (resolve_dynamic_union): Use resolve_dynamic_type_internal. (resolve_dynamic_struct): Likewise. (resolve_dynamic_type_internal): New function, from resolve_dynamic_type. (resolve_dynamic_type): Rewrite. 2014-07-14 Tom Tromey <tromey@redhat.com> * gdb.cp/vla-cxx.cc: New file. * gdb.cp/vla-cxx.exp: New file.
2014-07-14fix record "run" regressionTom Tromey5-1/+68
This fixes the record "run" regression pointed out by Marc Khouzam: https://sourceware.org/ml/gdb/2014-06/msg00096.html The bug is that target_require_runnable must agree with the handling of the "run" target, but currently it is out of sync. This patch fixes the problem by changing target_require_runnable to also ignore the record_stratum. Built and regtested on x86-64 Fedora 20. New test case included. 2014-07-14 Tom Tromey <tromey@redhat.com> * target.c (target_require_runnable): Also check record_stratum. Update comment. 2014-07-14 Tom Tromey <tromey@redhat.com> * gdb.reverse/rerun-prec.c: New file. * gdb.reverse/rerun-prec.exp: New file.
2014-07-12gdb/testsuite: Add a way to send multiple init commandsMaciej W. Rozycki5-6/+59
Right now we provide a board info entry, `gdb_init_command', that allows one to send a single command to GDB before the program to be debugged is started. This is useful e.g. for slow remote targets to change the default "remotetimeout" setting. Occasionally I found a need to send multiple commands instead, however this cannot be achieved with `gdb_init_command'. This change therefore extends the mechanism by adding a TCL list of GDB commands to send, via a board info entry called `gdb_init_commands'. There is no limit as to the number of commands put there. The old `gdb_init_command' mechanism remains supported for compatibility with existing people's environments. * lib/gdb-utils.exp: New file. * lib/gdb.exp (gdb_run_cmd): Call gdb_init_commands, replacing inline `gdb_init_command' processing. (gdb_start_cmd): Likewise. * lib/mi-support.exp (mi_run_cmd): Likewise. * README: Document `gdb_init_command' and `gdb_init_commands'.
2014-07-11Fix false argv0-symlink.exp FAIL running under a very long directory nameJan Kratochvil2-0/+12
Starting program: /home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink ^M [...] (gdb) print argv[0]^M $1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-", 'f' <repeats 169 times>...^M (gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name after "set print repeats 10000": print argv[0]^M $1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"...^M (gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name after "set print elements 10000": print argv[0]^M $1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink"^M (gdb) PASS: gdb.base/argv0-symlink.exp: kept file symbolic link name gdb/testsuite/ 2014-07-11 Jan Kratochvil <jan.kratochvil@redhat.com> Fix false FAIL running under a very long directory name. * gdb.base/argv0-symlink.exp: Add "set print repeats 10000" and "set print elements 10000". Twice.
2014-07-11Stop prologue analysis when past the epilogueYao Qi2-0/+10
We see a fail in gdb.trace/entry-values.exp on armv4t thumb, bt^M #0 0x000086fc in foo (i=0, i@entry=<optimized out>, j=2, j@entry=<optimized out>)^M #1 0x00000002 in ?? ()^M Backtrace stopped: previous frame identical to this frame (corrupt stack?)^M (gdb) FAIL: gdb.trace/entry-values.exp: bt (1) (pattern 1) The fail is caused by incorrect prologue analysis, which can be illustrated by setting a breakpoint on function foo, (gdb) disassemble foo Dump of assembler code for function foo: 0x000086e8 <+0>: push {r7, lr} 0x000086ea <+2>: sub sp, #8 0x000086ec <+4>: add r7, sp, #0 0x000086ee <+6>: str r0, [r7, #4] 0x000086f0 <+8>: str r1, [r7, #0] 0x000086f2 <+10>: movs r3, #0 0x000086f4 <+12>: adds r0, r3, #0 0x000086f6 <+14>: mov sp, r7 0x000086f8 <+16>: add sp, #8 0x000086fa <+18>: pop {r7} 0x000086fc <+20>: pop {r1} 0x000086fe <+22>: bx r1 End of assembler dump. (gdb) b foo Breakpoint 1 at 0x86fc As we can see, GDB analyzes the prologue and skip the prologue to the last instruction but one. The breakpoint is set within the epilogue, and GDB skips too many instruction for prologue. This patch teaches GDB to stop prologue analysis when goes into the epilogue. With this patch applied, GDB is able to unwind correctly, (gdb) bt #0 0x000086f6 in foo (i=0, i@entry=2, j=2, j@entry=3) #1 0x00008718 in bar (i=<optimized out>) #2 0x00008758 in main () gdb: 2014-07-11 Yao Qi <yao@codesourcery.com> * arm-tdep.c (thumb_analyze_prologue): Break the loop if thumb_instruction_restores_sp return true.
2014-07-11Match instruction adjusts SP in thumbYao Qi2-11/+20
This is a refactor patch, that moves matching instructions adjusting SP into a new function, thumb_instruction_restores_sp. The second call to thumb_instruction_restores_sp in thumb_in_function_epilogue_p is a little different from the original. The original code matches 'POP <registers> without PC', but thumb_in_function_epilogue_p matches 'POP <registers> (with and without PC)'. However, GDB found one instruction about return and is scanning the previous instruction, which should be an instruction about return too, so the code change doesn't affect the functionality. gdb: 2014-07-11 Yao Qi <yao@codesourcery.com> * arm-tdep.c (thumb_instruction_restores_sp): New function. (thumb_in_function_epilogue_p): Call thumb_instruction_restores_sp.
2014-07-11Restrict matching add/sub sp, #immYao Qi2-10/+11
Currently, GDB matches both add/sub sp, #imm in prologue and epilogue, which is not very precise. On the instruction level, the immediate number in both instruction can't be negative, so 'sub sp, #imm' only appears in prologue while 'add sp, #imm' only appears in epilogue. Note that on assembly level, we can write 'add sp, -8', but gas will translate to 'sub sp, 8' instruction. This patch is to only match 'sub sp, #imm' in prologue and match 'add sp, #immm' in epilogue. It paves the way for the following patch. gdb: 2014-07-11 Yao Qi <yao@codesourcery.com> * arm-tdep.c (thumb_analyze_prologue): Don't match instruction 'add sp, #imm'. (thumb_in_function_epilogue_p): Don't match 'sub sp, #imm'.
2014-07-11Tidy #include listsGary Benson3-57/+38
This commit tidies up the #include lists in {i386,amd64}-linux-nat.c, removing headers that are no longer required and reordering some lines so that both files roughly match. Additionally, an unused definition was removed from the middle of the #include list in i386-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (gdbcore.h): Remove include. (regset.h): Likewise. (nat/linux-btrace.h): Likewise. (btrace.h): Likewise. (gdb_assert.h): Likewise. (string.h): Likewise. (sys/uio.h): Likewise. (sys/debugreg.h): Likewise. (sys/syscall.h): Likewise. (sys/procfs.h): Likewise. (sys/user.h): Likewise. (asm/ptrace.h): Likewise. (i386-nat.h): Likewise. * i386-linux-nat.c (i386-nat.h): Likewise. (regset.h): Likewise. (target.h): Likewise. (linux-nat.h): Likewise. (nat/linux-btrace.h): Likewise. (btrace.h): Likewise. (gdb_assert.h): Likewise. (string.h): Likewise. (sys/uio.h): Likewise. (sys/user.h): Likewise. (sys/procfs.h): Likewise. (sys/reg.h): Likewise. (sys/debugreg.h): Likewise. (ORIG_EAX): Remove definition.
2014-07-11Move duplicated code into new filesGary Benson9-1068/+718
This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-11Comment and whitespace changesGary Benson3-3/+20
This commit merges the comments and whitespace in the common parts of i386-linux-nat.c and amd64-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c: Comment and whitespace changes. * i386-linux-nat.c: Comment and whitespace changes.
2014-07-11Pull out common parts of _initialize_{i386,amd64}_linux_natGary Benson3-40/+89
This commit adds two new helpers, x86_linux_create_target and x86_linux_add_target, to hold the parts of _initialize_i386_linux_nat and _initialize_amd64_linux_nat which are common. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (x86_linux_create_target): New function. (x86_linux_add_target): Likewise. (_initialize_amd64_linux_nat): Delegate to the above new functions. * i386-linux-nat.c (x86_linux_create_target): New function. (x86_linux_add_target): Likewise. (_initialize_i386_linux_nat): Delegate to the above new functions.
2014-07-11Merge ps_get_thread_areaGary Benson3-28/+88
This commit adds a new helper, x86_linux_get_thread_area, to hold the common parts of the ps_get_thread_area functions in i386-linux-nat.c and amd64-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (x86_linux_get_thread_area): New function. (ps_get_thread_area): Delegate to the above in 32-bit mode. * i386-linux-nat.c (x86_linux_get_thread_area): New function. (ps_get_thread_area): Delegate to the above.
2014-07-11Merge {i386,amd64}_linux_read_descriptionGary Benson3-92/+198
This commit merges i386_ and amd64_linux_read_description, renaming both to x86_linux_read_description. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (amd64_linux_read_description): Renamed to x86_linux_read_description. All uses updated. amd64-specific code conditionalized. Conditionalized i386-specific code added. Redundant cast removed. * i386-linux-nat.c (i386_linux_read_description): Renamed to x86_linux_read_description. All uses updated. i386-specific code conditionalized. Conditionalized amd64-specific code added. One sizeof replaced with the actual type it is describing.
2014-07-11Rename identical functionsGary Benson3-80/+143
amd64-linux-nat.c and i386-linux-nat.c contain a number of functions which are identical but for prefix on their names. This commit renames all such functions to have the prefix x86_ instead of the prefixes amd64_ or i386_ and updates all uses of those functions. The now-identical x86_ functions will be pulled out to a separate shared file in a later commit. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (amd64_linux_dr_get): Renamed to x86_linux_dr_get. All uses updated. (amd64_linux_dr_set): Renamed to x86_linux_dr_set. All uses updated. (amd64_linux_dr_get_addr): Renamed to x86_linux_dr_get_addr. All uses updated. (amd64_linux_dr_get_control): Renamed to x86_linux_dr_get_control. All uses updated. (amd64_linux_dr_get_status): Renamed to x86_linux_dr_get_status. All uses updated. (amd64_linux_dr_set_control): Renamed to x86_linux_dr_set_control. All uses updated. (amd64_linux_dr_set_addr): Renamed to x86_linux_dr_set_addr. All uses updated. (amd64_linux_prepare_to_resume): Renamed to x86_linux_prepare_to_resume. All uses updated. (amd64_linux_new_thread): Renamed to x86_linux_new_thread. All uses updated. (amd64_linux_new_fork): Renamed to x86_linux_new_fork. All uses updated. (amd64_linux_child_post_startup_inferior): Renamed to x86_linux_child_post_startup_inferior. All uses updated. (amd64_linux_enable_btrace): Renamed to x86_linux_enable_btrace. All uses updated. (amd64_linux_disable_btrace): Renamed to x86_linux_disable_btrace. All uses updated. (amd64_linux_teardown_btrace): Renamed to x86_linux_teardown_btrace. All uses updated. (amd64_linux_read_btrace): Renamed to x86_linux_read_btrace. All uses updated. * i386-linux-nat.c (i386_linux_dr_get): Renamed to x86_linux_dr_get. All uses updated. (i386_linux_dr_set): Renamed to x86_linux_dr_set. All uses updated. (i386_linux_dr_get_addr): Renamed to x86_linux_dr_get_addr. All uses updated. (i386_linux_dr_get_control): Renamed to x86_linux_dr_get_control. All uses updated. (i386_linux_dr_get_status): Renamed to x86_linux_dr_get_status. All uses updated. (i386_linux_dr_set_control): Renamed to x86_linux_dr_set_control. All uses updated. (i386_linux_dr_set_addr): Renamed to x86_linux_dr_set_addr. All uses updated. (i386_linux_prepare_to_resume): Renamed to x86_linux_prepare_to_resume. All uses updated. (i386_linux_new_thread): Renamed to x86_linux_new_thread. All uses updated. (i386_linux_new_fork): Renamed to x86_linux_new_fork. All uses updated. (i386_linux_child_post_startup_inferior): Renamed to x86_linux_child_post_startup_inferior. All uses updated. (i386_linux_enable_btrace): Renamed to x86_linux_enable_btrace. All uses updated. (i386_linux_disable_btrace): Renamed to x86_linux_disable_btrace. All uses updated. (i386_linux_teardown_btrace): Renamed to x86_linux_teardown_btrace. All uses updated. (i386_linux_read_btrace): Renamed to x86_linux_read_btrace. All uses updated.
2014-07-11Don't print symbol on address 0x0Yao Qi2-1/+7
We see the following fails on arm-none-eabi target, print (void*)v_signed_char^M $190 = (void *) 0x0 <_ftext>^M (gdb) FAIL: gdb.base/exprs.exp: print (void*)v_signed_char (print (void*)v_signed_char) GDB behaves correctly but the test assumes there is no symbol on address 0x0. This patch is set print symbol off, so that tests below can match the address only. gdb/testsuite: 2014-07-11 Yao Qi <yao@codesourcery.com> * gdb.base/exprs.exp: "set print symbol off".
2014-07-11GDBserver crashes when killing a multi-thread processPedro Alves5-26/+194
Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11remote: call remote_check_symbols after attachingAdrian Sendroiu2-0/+20
When debugging a remote bare-metal target with "target extended-remote" + attach, GDB won't send a qSymbol packet to initiate symbol lookup. This happens because all the previous places in which GDB might have done this are guarded by conditions that don't hold in the said scenario: there are no shared libraries, no vsyscall page and the binary file didn't change in the time passed between the "file" and the "attach" commands. To solve this problem remote_check_symbols is called in the target_post_attach hook. gdb/ 2014-07-11 Adrian Sendroiu <adrian.sendroiu@freescale.com> * remote.c (extended_remote_post_attach): New function. (init_extended_remote_ops): Install it as to_post_attach method.
2014-07-10Revert gdbthread.h (any_running): Declare.Doug Evans3-20/+0
Not properly marked as 1/2. This reverts commit 1a76d598884a052dacd8feb49f1999e1a0d537f1.
2014-07-10 * gdbthread.h (any_running): Declare.Doug Evans3-0/+20
* thread.c (any_running): New function.
2014-07-10Tweak gdb.trace/tfile.c for thumb modeYao Qi2-2/+15
We see the fail below happens on thumb related multi-libs (-mthumb -march={armv4t,armv7-a}), target tfile tfile-basic.tf ^M warning: Uploaded tracepoint 1 has no source location, using raw address^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M Tracepoint 3 at 0x8958: file /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.trace/tfile.c, line 91.^M Created tracepoint 3 for target's tracepoint 1 at 0x8959.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M (gdb) FAIL: gdb.trace/tfile.exp: complete-command 'target tfile' The address of write_basic_trace_file is two-bytes aligned, (gdb) p write_basic_trace_file $1 = {void (void)} 0x8958 <write_basic_trace_file> but the ld sets the LSB of every reference to the function address (indicating the address is in thumb mode), so "&write_basic_trace_file" in the program becomes 0x8959, which is saved in the trace file. That is why the warnnings are emitted. This patch is to clear the LSB of the function address written to trace file in thumb and thumb2 mode. This patch fixes the fail above. gdb/testsuite: 2014-07-10 Yao Qi <yao@codesourcery.com> * gdb.trace/tfile.c (write_basic_trace_file) [__thumb__||__thumb2__]: Clear the Thumb bit of the function address written to trace file.
2014-07-09Fix "attach" command vs user input racePedro Alves5-3/+186
On async targets, a synchronous attach is done like this: #1 - target_attach is called (PTRACE_ATTACH is issued) #2 - a continuation is installed #3 - we go back to the event loop #4 - target reports stop (SIGSTOP), event loop wakes up, and attach continuation is called #5 - among other things, the continuation calls target_terminal_inferior, which removes stdin from the event loop Note that in #3, GDB is still processing user input. If the user is fast enough, e.g., with something like: echo -e "attach PID\nset xxx=1" | gdb ... then the "set" command is processed before the attach completes. We get worse behavior even, if input is a tty and therefore readline/editing is enabled, with e.g.,: (gdb) attach PID\nset xxx=1 we then crash readline/gdb, with: Attaching to program: attach-wait-input, process 14537 readline: readline_callback_read_char() called with no handler! Aborted $ Fix this by calling target_terminal_inferior before #3 above. The test covers both scenarios by running with editing/readline forced to both on and off. gdb/ 2014-07-09 Pedro Alves <palves@redhat.com> * infcmd.c (attach_command_post_wait): Don't call target_terminal_inferior here. (attach_command): Call it here instead. gdb/testsuite/ 2014-07-09 Pedro Alves <palves@redhat.com> * gdb.base/attach-wait-input.exp: New file. * gdb.base/attach-wait-input.c: New file.
2014-07-09Improve MI -var-info-path-expression for nested struct/union case.Andrew Burgess9-14/+246
https://sourceware.org/ml/gdb-patches/2014-05/msg00383.html The MI command -var-info-path-expression currently does not handle non-anonymous structs / unions nested within other structs / unions, it will skip parts of the expression. Consider this example: ## START EXAMPLE ## $ cat ex.c #include <string.h> int main () { struct s1 { int a; }; struct ss { struct s1 x; }; struct ss an_ss; memset (&an_ss, 0, sizeof (an_ss)); return 0; } $ gcc -g -o ex.x ex.c $ gdb ex.x (gdb) break 18 Breakpoint 1 at 0x80483ba: file ex.c, line 18. (gdb) run Starting program: /home/user/ex.x Breakpoint 1, main () at ex.c:18 18 return 0; (gdb) interpreter-exec mi "-var-create an_ss * an_ss" (gdb) interpreter-exec mi "-var-list-children an_ss" ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x" ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x.a" ^done,numchild="0",has_more="0" (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a" ^done,path_expr="(an_ss).a" (gdb) print (an_ss).a There is no member named a. ## END EXAMPLE ## Notice that the path expression returned is wrong, and as a result the print command fails. This patch adds a new method to the varobj_ops structure called is_path_expr_parent, to allow language specific control over finding the parent varobj, the current logic becomes the C/C++ version and is extended to handle the nested cases. No other language currently uses this code, so all other languages just get a default method. With this patch, the above example now finishes like this: ## START EXAMPLE ## $ gdb ex.x (gdb) break 18 Breakpoint 1 at 0x80483ba: file ex.c, line 18. (gdb) run Starting program: /home/user/ex.x Breakpoint 1, main () at ex.c:18 18 return 0; (gdb) interpreter-exec mi "-var-list-children an_ss" ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x" ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x.a" ^done,numchild="0",has_more="0" (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a" ^done,path_expr="((an_ss).x).a" (gdb) print ((an_ss).x).a $1 = 0 ## END EXAMPLE ## Notice that the path expression is now correct, and the print is a success. gdb/ChangeLog: * ada-varobj.c (ada_varobj_ops): Fill in is_path_expr_parent field. * c-varobj.c (c_is_path_expr_parent): New function, moved core from varobj.c, with additional checks. (c_varobj_ops): Fill in is_path_expr_parent field. (cplus_varobj_ops): Fill in is_path_expr_parent field. * jv-varobj.c (java_varobj_ops): Fill in is_path_expr_parent field. * varobj.c (is_path_expr_parent): Call is_path_expr_parent varobj ops method. (varobj_default_is_path_expr_parent): New function. * varobj.h (lang_varobj_ops): Add is_path_expr_parent field. (varobj_default_is_path_expr_parent): Declare new function. gdb/testsuite/ChangeLog: * gdb.mi/var-cmd.c (do_nested_struct_union_tests): New function setting up test structures. (main): Call new test function. * gdb.mi/mi2-var-child.exp: Create additional breakpoint in new test function, continue into test function and walk test structures.
2014-07-08Fix gdb.trace/entry-values.exp for thumb modeYao Qi3-5/+19
We see some fails in gdb.trace/entry-values.exp in thumb mode (-mthumb -march={armv4t,armv7-a}). In thumb mode, the lsb of references to 'foo' and 'bar' in the assembly (produced by dwarf assember) is set, so the generated debug information is incorrect. This patch copies the approach used by [PATCH 4/4] Fix dw2-ifort-parameter.exp on PPC64 https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html to introduce new labels 'foo_start' and 'bar_start' which are about the correct function address (without lsb set). This patch fixes these fails we've seen. gdb/testsuite: 2014-07-08 Yao Qi <yao@codesourcery.com> * gdb.trace/entry-values.c: Define labels 'foo_start' and 'bar_start' at the beginning of functions 'foo' and 'bar' respectively. * gdb.trace/entry-values.exp: Use 'foo_start' and 'bar_start' instead of 'foo' and 'bar'.
2014-07-08reverse-finish: turn internal error into normal errorMarkus Metzger5-2/+87
The reverse-finish command results in an internal error if it cannot determine the current function. (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) reverse-finish Run back to call of #0 0x0000000000000000 in ?? () gdb/infcmd.c:1576: internal-error: Finish: couldn't find function. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) y This is not an internal error case since the command may be used in scenarios where there is no function at the current PC, e.g. after calling through a bad function pointer. Turn this into a normal error. gdb/ * infcmd.c (finish_backward): Turn internal error into normal error. testsuite/ * gdb.btrace/segv.c: New. * gdb.btrace/segv.exp: New.
2014-07-07Mention PR gdb/17096 in ChangeLogPedro Alves1-0/+1
2014-07-07PR gdb/17096: async support breaks remote debugging on WindowsPedro Alves2-2/+12
On Windows, with "maint set target-async on" (the default since a09dd441), Ctrl-C fails to stop a remote target. With maint target-async on, the SIGINT signal handler doesn't send the remote interrupt request immediately. Instead, it marks an async handler as ready, and then the main event loop wakes up and notices that the SIGINT async signal handler token was set, and calls the corresponding event handler, which sends the remote interrupt request. On POSIX-like systems, the SIGINT signal makes the select/poll in the main event loop wake up / return with EINTR. However, on Windows, signal handlers run on a separate thread, and Windows doesn't really have a concept of EINTR. So, just marking the async handler (effectively just setting a flag) does not wake up gdb_select. Instead, we need to call gdb_call_async_signal_handler from the signal handler. The Windows version (in mingw-hdep.c) sets a Windows event that gdb_select's WaitForMultipleObjects is waiting for. Confirmed that with this, Ctrl-C interrupts the remote target on Windows. Also regression tested on x86_64 Fedora 20 against GDBserver. gdb/ 2014-07-07 Pedro Alves <palves@redhat.com> * remote.c (async_handle_remote_sigint) (async_handle_remote_sigint_twice): Call gdb_call_async_signal_handler instead of mark_async_signal_handler.
2014-07-07change to_info_record to use target delegationTom Tromey4-23/+13
This changes to_info_record to use target delegation. Also, target_info_record was unused, so this patch removes it. 2014-07-07 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (target_info_record): Remove. * record.c (info_record_command): Unconditionally call to_info_record. * target.h (struct target_ops) <to_info_record>: Use TARGET_DEFAULT_IGNORE. (target_info_record): Remove.
2014-07-07convert to_get_thread_local_address to use target delegationTom Tromey6-22/+44
This converts to_get_thread_local_address to use TARGET_DEFAULT_NORETURN. One possible oddity is that this changes the text of the kind of exception thrown in some cases. This doesn't seem to be a problem; in fact perhaps the final call to 'error' in target_translate_tls_address should be changed to call generic_tls_error. 2014-07-07 Tom Tromey <tromey@redhat.com> * target.h (struct target_ops) <to_get_thread_local_address>: Use TARGET_DEFAULT_NORETURN. * target.c (generic_tls_error): New function. (target_translate_tls_address): Don't search target stack. * target-delegates.c: Rebuild. * ppc-linux-tdep.c (ppc_linux_spe_context): Don't search target stack. * linux-thread-db.c (thread_db_get_thread_local_address): Unconditionally call beneath target.
2014-07-03Assign 'targerr' instead of 'targ' to gdb_stdtargerr.Marc Khouzam2-1/+6
2014-07-03Update email address in MAINTAINERS list.Andrew Burgess2-1/+5
2014-07-02This testcase currently does not handle powerpc branches. It kindaLuis Machado2-0/+7
does in a way, because the arm/aarch64 branch instruction is the same as powerpc's, but the target triplet pattern is not there. In summary, the testcase fails to locate the branch offset and causes a failure and the early termination of the test. The following patch adds a separate conditional block for powerpc (to keep things organized), allowing the testcase to continue. 2014-07-02 Luis Machado <lgustavo@codesourcery.com> * gdb.trace/entry-values.exp: Handle powerpc-specific branch instruction.
2014-07-02Remove unused Linux libthread_db callbacksGary Benson2-103/+15
gdb/proc-service.c includes several libthread_db callbacks that do not exist in gdb/gdbserver/proc-service.c. Other than in proc_service.h, there is no reference to any of these callbacks in any revision of nptl_db or linuxthreads_db in glibc's git repo so it seems likely that these functions have never been called. This commit removes them. gdb/ 2014-07-02 Gary Benson <gbenson@redhat.com> * proc-service.c (ps_xfer_memory): Update comment. (ps_pstop): Remove unused function. (ps_pcontinue): Likewise. (ps_lstop): Likewise. (ps_lcontinue): Likewise. (ps_lgetxregsize): Likewise. (ps_lgetxregs): Likewise. (ps_lsetxregs): Likewise. (ps_plog): Likewise. (ps_ptread): Likewise. (ps_ptwrite): Likewise.
2014-07-01Handle volatile array types in dwarf2read.c.Mark Wielaard5-19/+89
read_tag_const_type propagates the cv-qualifier to the array element type, but read_tag_volatile_type didn't. Make sure that both cv-qualifiers that apply to array types are handled the same. gdb/ChangeLog * dwarf2read.c (add_array_cv_type): New function. (read_tag_const_type): Call add_array_cv_type for TYPE_CODE_ARRAY. (read_tag_volatile_type): Likewise. gdb/testsuite/ChangeLog * gdb.base/constvars.c (violent, violet, vips, virgen, vulgar, vulture, vilify, villar): New volatile array constants. (vindictive, vegetation): New const volatile array constants. * gdb.base/volatile.exp: Test volatile and const volatile array types.
2014-07-01use cmd_sfunc_ftype and cmd_cfunc_ftype moreTom Tromey5-19/+27
This patch changes a few more spots to use either cmd_sfunc_ftype or cmd_cfunc_ftype, as appropriate. This is a bit cleaner. Tested by rebuilding. 2014-07-01 Tom Tromey <tromey@redhat.com> * breakpoint.c (add_catch_command): Use cmd_sfunc_ftype. * breakpoint.h (add_catch_command): Use cmd_sfunc_ftype. * cli/cli-decode.c (cmd_cfunc_eq, add_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, add_info, add_com): Use cmd_cfunc_ftype. * command.h (cmd_cfunc_ftype): Move earlier. (add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd, cmd_cfunc_eq) (add_com, add_info): Use cmd_cfunc_ftype.
2014-06-302014-01-07 Michael Eager <eager@eagercon.com>Michael Eager1-1/+2
* dwarf2read.c (read_structure_type): Set stub if ICC & length == 0.
2014-06-30constify search_symbolsTom Tromey3-18/+33
This constifies the parameters to search_symbols and fixes up the fallout. Tested by rebuilding. 2014-06-30 Tom Tromey <tromey@redhat.com> * symtab.c (operator_chars): Make parameters and return type const. (file_matches): Make "files" const. (struct search_symbols_data) <files>: Now const. (search_symbols): Make "regexp" and "files" parameters const. Update. (symtab_symbol_info): Remove cast. (rbreak_command): Update. * symtab.h (search_symbols): Update.
2014-06-30watchpoint-reuse-slot.exp: Correctly skip unsupported commands.Andreas Arnez2-1/+12
The test case "watchpoint-reuse-slot.exp" yields a lot of failures on s390/s390x: all instances of awatch, rwatch, and hbreak are performed even though they aren't supported on these targets. This is because the test case ignores non-support error messages when probing for support of these commands, like: (gdb) rwatch buf.byte[0] Target does not support this type of hardware watchpoint. The patch adds handling for this case in the appropriate gdb_test_multiple invocations. gdb/testsuite/ * gdb.base/watchpoint-reuse-slot.exp: Handle the case that the target lacks support for awatch, rwatch, or hbreak.
2014-06-27Associate dummy_frame with ptidYao Qi13-45/+236
This patch is to add ptid into dummy_frame and extend frame_id to dummy_frame_id (which has a ptid field). With this change, GDB uses dummy_frame_id (thread ptid and frame_id) to find the dummy frames. Currently, dummy frames are looked up by frame_id, which isn't accurate in non-stop or multi-process mode. The test case gdb.multi/dummy-frame-restore.exp shows the problem and this patch can fix it. Test dummy-frame-restore.exp makes two inferiors stop at different functions, say, inferior 1 stops at f1 while inferior 2 stops at f2. Set a breakpoint to a function, do the inferior call in two inferiors, and GDB has two dummy frames of the same frame_id. When the inferior call is finished, GDB will look up a dummy frame from its stack/list and restore the inferior's regcache. Two inferiors are finished in different orders, the inferiors' states are restored differently, which is wrong. Running dummy-frame-restore.exp under un-patched GDB, we'll get two fails: FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2 FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1 With this patch applied, GDB will choose the correct dummy_frame to restore for a given inferior, because ptid is considered when looking up dummy frames. Two fails above are fixed. Regression tested on x86_64-linux, both native and gdbserver. gdb: 2014-06-27 Yao Qi <yao@codesourcery.com> * breakpoint.c (check_longjmp_breakpoint_for_call_dummy): Change parameter type to 'struct thread_info *'. Caller updated. * breakpoint.h (check_longjmp_breakpoint_for_call_dummy): Update declaration. * dummy-frame.c (struct dummy_frame_id): New. (dummy_frame_id_eq): New function. (struct dummy_frame) <id>: Change its type to 'struct dummy_frame_id'. (dummy_frame_push): Add parameter ptid and save it in dummy_frame_id. (pop_dummy_frame_bpt): Use ptid of dummy_frame instead of inferior_ptid. (pop_dummy_frame): Assert that the ptid of dummy_frame equals to inferior_ptid. (lookup_dummy_frame): Change parameter type to 'struct dummy_frame_id *'. Callers updated. Call dummy_frame_id_eq instead of frame_id_eq. (dummy_frame_pop): Add parameter ptid. Callers updated. Update comments. Compose dummy_frame_id and pass it to lookup_dummy_frame. (dummy_frame_discard): Add parameter ptid. (dummy_frame_sniffer): Compose dummy_frame_id and call dummy_frame_id_eq instead of frame_id_eq. (fprint_dummy_frames): Print ptid. * dummy-frame.h: Remove comments. (dummy_frame_push): Add ptid in declaration. (dummy_frame_pop, dummy_frame_discard): Likewise. gdb/testsuite: 2014-06-27 Yao Qi <yao@codesourcery.com> * gdb.multi/dummy-frame-restore.exp: New. * gdb.multi/dummy-frame-restore.c: New. gdb/doc: 2014-06-27 Yao Qi <yao@codesourcery.com> * gdb.texinfo (Maintenance Commands): Update the output of 'maint print dummy-frames' command.
2014-06-26constify error_no_argTom Tromey3-2/+7
This is a trivial patch to make error_no_arg take a const argument. 2014-06-26 Tom Tromey <tromey@redhat.com> * cli/cli-cmds.c (error_no_arg): Make "why" const. * command.h (error_no_arg): Update.
2014-06-26constify do_set_command and do_show_commandTom Tromey3-7/+15
This changes do_set_command and do_show_command to take const arguments. 2014-06-26 Tom Tromey <tromey@redhat.com> * cli/cli-setshow.c (do_set_command): Make "arg" const. (do_show_command): Make "arg" const. * cli/cli-setshow.h (do_set_command, do_show_command): Update.
2014-06-26constify get_bookmark and goto_bookmarkTom Tromey6-23/+47
This makes arguments to to_get_bookmark and to_goto_bookmark const and fixes the fallout. Tested by rebuilding. The only thing of note is the new split between cmd_record_goto and record_goto -- basically separating the CLI function from a new internal API, to allow const propagation. 2014-06-26 Tom Tromey <tromey@redhat.com> * record-full.c (record_full_get_bookmark): Make "args" const. (record_full_goto_bookmark): Make "raw_bookmark" const. * record.c (record_goto): New function. (cmd_record_goto): Use it. Now static. * record.h (record_goto): Declare. (cmd_record_goto): Remove declaration. * target-delegates.c: Rebuild. * target.h (struct target_ops) <to_get_bookmark, to_goto_bookmark>: Make parameter const.
2014-06-26constify to_loadTom Tromey12-37/+45
This makes the argument to the target_ops to_load method "const", and fixes up the fallout. Tested by rebuilding all the affected files. 2014-06-26 Tom Tromey <tromey@redhat.com> * defs.h (generic_load): Update. * m32r-rom.c (m32r_load_gen): Make "filename" const. * monitor.c (monitor_load): Make "args" const. * remote-m32r-sdi.c (m32r_load): Make "args" const. * remote-mips.c (mips_load_srec, pmon_load_fast): Make "args" const. (mips_load): Make "file" const. * remote-sim.c (gdbsim_load): Make "args" const. * remote.c (remote_load): Make "name" const. * symfile.c (generic_load): Make "args" const. * target-delegates.c: Rebuild. * target.c (target_load): Make "arg" const. (debug_to_load): Make "args" const. * target.h (struct target_ops) <to_load>: Make parameter const. (target_load): Update.