gdb/tui/tui-hooks.c - gdb
Global variables defined
Functions defined
Source code
#include "defs.h"
#include "symtab.h"
#include "inferior.h"
#include "command.h"
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
#include "target.h"
#include "gdbcore.h"
#include "event-loop.h"
#include "event-top.h"
#include "frame.h"
#include "breakpoint.h"
#include "ui-out.h"
#include "top.h"
#include "observer.h"
#include <unistd.h>
#include <fcntl.h>
#include "tui/tui.h"
#include "tui/tui-hooks.h"
#include "tui/tui-data.h"
#include "tui/tui-layout.h"
#include "tui/tui-io.h"
#include "tui/tui-regs.h"
#include "tui/tui-win.h"
#include "tui/tui-stack.h"
#include "tui/tui-windata.h"
#include "tui/tui-winsource.h"
#include "gdb_curses.h"
#include "readline/readline.h"
int tui_target_has_run = 0;
static void
tui_new_objfile_hook (struct objfile* objfile)
{
if (tui_active)
tui_display_main ();
}
static int ATTRIBUTE_PRINTF (1, 0)
tui_query_hook (const char *msg, va_list argp)
{
int retval;
int ans2;
int answer;
char *question;
struct cleanup *old_chain;
question = xstrvprintf (msg, argp);
old_chain = make_cleanup (xfree, question);
echo ();
while (1)
{
wrap_here (""); gdb_flush (gdb_stdout);
fputs_filtered (question, gdb_stdout);
printf_filtered (_("(y or n) "));
wrap_here ("");
gdb_flush (gdb_stdout);
answer = tui_getc (stdin);
clearerr (stdin); if (answer == EOF) {
retval = 1;
break;
}
if (answer != '\n')
do
{
ans2 = tui_getc (stdin);
clearerr (stdin);
}
while (ans2 != EOF && ans2 != '\n' && ans2 != '\r');
if (answer >= 'a')
answer -= 040;
if (answer == 'Y')
{
retval = 1;
break;
}
if (answer == 'N')
{
retval = 0;
break;
}
printf_filtered (_("Please answer y or n.\n"));
}
noecho ();
do_cleanups (old_chain);
return retval;
}
static int tui_refreshing_registers = 0;
static void
tui_register_changed_hook (int regno)
{
struct frame_info *fi;
fi = get_selected_frame (NULL);
if (tui_refreshing_registers == 0)
{
tui_refreshing_registers = 1;
tui_check_data_values (fi);
tui_refreshing_registers = 0;
}
}
static void
tui_event_create_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
static void
tui_event_delete_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
static void
tui_event_modify_breakpoint (struct breakpoint *b)
{
tui_update_all_breakpoint_info ();
}
static void
tui_about_to_proceed (void)
{
#if 0
#endif
tui_target_has_run = 1;
}
static void
tui_selected_frame_level_changed_hook (int level)
{
struct frame_info *fi;
CORE_ADDR pc;
if (level < 0)
return;
fi = get_selected_frame (NULL);
if (get_frame_pc_if_available (fi, &pc))
{
struct symtab *s;
s = find_pc_line_symtab (pc);
if (s)
select_source_symtab (s);
}
tui_show_frame_info (fi);
if (tui_is_window_visible (DATA_WIN))
{
tui_refreshing_registers = 1;
tui_check_data_values (fi);
tui_refreshing_registers = 0;
}
}
static void
tui_print_frame_info_listing_hook (struct symtab *s,
int line,
int stopline,
int noerror)
{
select_source_symtab (s);
tui_show_frame_info (get_selected_frame (NULL));
}
static void
tui_inferior_exit (struct inferior *inf)
{
tui_set_key_mode (TUI_COMMAND_MODE);
tui_show_frame_info (0);
tui_display_main ();
}
static struct observer *tui_bp_created_observer;
static struct observer *tui_bp_deleted_observer;
static struct observer *tui_bp_modified_observer;
static struct observer *tui_inferior_exit_observer;
static struct observer *tui_about_to_proceed_observer;
void
tui_install_hooks (void)
{
deprecated_selected_frame_level_changed_hook
= tui_selected_frame_level_changed_hook;
deprecated_print_frame_info_listing_hook
= tui_print_frame_info_listing_hook;
deprecated_query_hook = tui_query_hook;
tui_bp_created_observer
= observer_attach_breakpoint_created (tui_event_create_breakpoint);
tui_bp_deleted_observer
= observer_attach_breakpoint_deleted (tui_event_delete_breakpoint);
tui_bp_modified_observer
= observer_attach_breakpoint_modified (tui_event_modify_breakpoint);
tui_inferior_exit_observer
= observer_attach_inferior_exit (tui_inferior_exit);
tui_about_to_proceed_observer
= observer_attach_about_to_proceed (tui_about_to_proceed);
deprecated_register_changed_hook = tui_register_changed_hook;
}
void
tui_remove_hooks (void)
{
deprecated_selected_frame_level_changed_hook = 0;
deprecated_print_frame_info_listing_hook = 0;
deprecated_query_hook = 0;
deprecated_register_changed_hook = 0;
observer_detach_breakpoint_created (tui_bp_created_observer);
tui_bp_created_observer = NULL;
observer_detach_breakpoint_deleted (tui_bp_deleted_observer);
tui_bp_deleted_observer = NULL;
observer_detach_breakpoint_modified (tui_bp_modified_observer);
tui_bp_modified_observer = NULL;
observer_detach_inferior_exit (tui_inferior_exit_observer);
tui_inferior_exit_observer = NULL;
observer_detach_about_to_proceed (tui_about_to_proceed_observer);
tui_about_to_proceed_observer = NULL;
}
void _initialize_tui_hooks (void);
void
_initialize_tui_hooks (void)
{
observer_attach_new_objfile (tui_new_objfile_hook);
}