summaryrefslogtreecommitdiff
path: root/gdb/frame.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2008-07-09 22:16:15 +0000
committerPedro Alves <pedro@codesourcery.com>2008-07-09 22:16:15 +0000
commitd065f280b0e34d3e76f483f1c8eb50dcb491eab9 (patch)
tree36f31c3a12e0059770381f206d62d17f637e9689 /gdb/frame.c
parent37f7f50449affa0e4d50deb20b422d98491ee664 (diff)
downloadgdb-d065f280b0e34d3e76f483f1c8eb50dcb491eab9.tar.gz
Add "executing" property to threads.
* inferior.h (target_executing): Delete. * gdbthread.h (struct thread_info): Add executing_ field. (set_executing, is_executing): New. * thread.c (main_thread_executing): New. (init_thread_list): Clear it and also main_thread_running. (is_running): Return false if target has no execution. (any_running, is_executing, set_executing): New. * top.c: Include "gdbthread.h". (target_executing): Delete. (execute_command): Replace target_executing check by any_running. * event-top.c: Include "gdbthread.h". (display_gdb_prompt, command_handler): Replace target_executing by is_running. * inf-loop.c: Include "gdbthread.h". Don't mark as not executing here. Replace target_executing by is_running. * infrun.c (handle_inferior_event): Mark all threads as not-executing. * linux-nat.c (linux_nat_resume): Don't mark thread as executing here. * stack.c (get_selected_block): Return null if inferior is executing. * target.c (target_resume): Mark resumed ptid as executing. * breakpoint.c (until_break_command): Replace target_executing check by is_executing. * remote.c (remote_async_resume): Don't mark inferior as executing here. * mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing by any_running. * mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute) (mi_execute_async_cli_command): Replace target_executing by is_running. * frame.c (get_current_frame): Error out if the current thread is executing. (has_stack_frames): New. (get_selected_frame, deprecated_safe_get_selected_frame): Check has_stack_frames. * Makefile.in (event-top.o, frame.o, inf-loop.o, top.o): Depend on $(gdbthread_h).
Diffstat (limited to 'gdb/frame.c')
-rw-r--r--gdb/frame.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index a14367cf8ae..9f0d07d6b4f 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -40,6 +40,7 @@
#include "observer.h"
#include "objfiles.h"
#include "exceptions.h"
+#include "gdbthread.h"
static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
@@ -930,6 +931,9 @@ get_current_frame (void)
error (_("No stack."));
if (!target_has_memory)
error (_("No memory."));
+ if (is_executing (inferior_ptid))
+ error (_("Target is executing."));
+
if (current_frame == NULL)
{
struct frame_info *sentinel_frame =
@@ -950,6 +954,20 @@ get_current_frame (void)
static struct frame_info *selected_frame;
+static int
+has_stack_frames (void)
+{
+ if (!target_has_registers || !target_has_stack || !target_has_memory)
+ return 0;
+
+ /* If the current thread is executing, don't try to read from
+ it. */
+ if (is_executing (inferior_ptid))
+ return 0;
+
+ return 1;
+}
+
/* Return the selected frame. Always non-NULL (unless there isn't an
inferior sufficient for creating a frame) in which case an error is
thrown. */
@@ -959,9 +977,7 @@ get_selected_frame (const char *message)
{
if (selected_frame == NULL)
{
- if (message != NULL && (!target_has_registers
- || !target_has_stack
- || !target_has_memory))
+ if (message != NULL && !has_stack_frames ())
error (("%s"), message);
/* Hey! Don't trust this. It should really be re-finding the
last selected frame of the currently selected thread. This,
@@ -980,7 +996,7 @@ get_selected_frame (const char *message)
struct frame_info *
deprecated_safe_get_selected_frame (void)
{
- if (!target_has_registers || !target_has_stack || !target_has_memory)
+ if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
}