summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-07 13:03:39 +0000
committerPedro Alves <palves@redhat.com>2017-11-07 13:04:42 +0000
commit5f6d441b51f671d2c2a684e9a2348487500cef74 (patch)
tree3e0f739380b1aad5bb443ff6a33a92779108272d
parent598364c2a4bb8fd086763a0eecedfaa581e4b214 (diff)
downloadbinutils-gdb-users/palves/per_ui_repeat.tar.gz
-rw-r--r--gdb/printcmd.c6
-rw-r--r--gdb/source.c6
-rw-r--r--gdb/top.c51
-rw-r--r--gdb/top.h12
4 files changed, 59 insertions, 16 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index da04285b04d..ec546587cd8 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -83,6 +83,12 @@ get_current_printcmd_info ()
return *current_ui->curr_printcmd_info;
}
+void
+delete_current_printcmd_info (struct ui *ui)
+{
+ delete ui->curr_printcmd_info;
+}
+
/* Number of delay instructions following current disassembled insn. */
static int branch_delay_insns;
diff --git a/gdb/source.c b/gdb/source.c
index 6ac1af22063..61a36343fe1 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -111,6 +111,12 @@ get_current_source_info ()
return *current_ui->curr_source_info;
}
+void
+delete_current_source_info (struct ui *ui)
+{
+ delete ui->curr_source_info;
+}
+
/* Default number of lines to print with commands like "list".
This is based on guessing how many long (i.e. more than chars_per_line
characters) lines there will be. To be completely correct, "list"
diff --git a/gdb/top.c b/gdb/top.c
index a7d70627375..391920320fe 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -298,6 +298,10 @@ ui::~ui ()
else
ui_list = next;
+ delete_current_printcmd_info (this);
+ delete_current_source_info (this);
+ delete_current_top_info (this);
+
delete m_gdb_stdin;
delete m_gdb_stdout;
delete m_gdb_stderr;
@@ -1665,6 +1669,27 @@ dont_repeat_command (char *ignored, int from_tty)
/* Functions to manipulate command line editing control variables. */
+struct current_top_info
+{
+ /* Number of the history entry which we are planning to display
+ next in "show commands". Relative to history_base. */
+ int num = 0;
+};
+
+static current_top_info &
+get_current_top_info ()
+{
+ if (current_ui->curr_top_info == NULL)
+ current_ui->curr_top_info = new current_top_info ();
+ return *current_ui->curr_top_info;
+}
+
+void
+delete_current_top_info (struct ui *ui)
+{
+ delete ui->curr_top_info;
+}
+
/* Number of commands to print in each call to show_commands. */
#define Hist_print 10
void
@@ -1673,9 +1698,7 @@ show_commands (char *args, int from_tty)
/* Index for history commands. Relative to history_base. */
int offset;
- /* Number of the history entry which we are planning to display next.
- Relative to history_base. */
- static int num = 0;
+ current_top_info &ci = get_current_top_info ();
/* Print out some of the commands from the command history. */
@@ -1686,28 +1709,28 @@ show_commands (char *args, int from_tty)
;
else
/* "info editing <exp>" should print around command number <exp>. */
- num = (parse_and_eval_long (args) - history_base) - Hist_print / 2;
+ ci.num = (parse_and_eval_long (args) - history_base) - Hist_print / 2;
}
/* "show commands" means print the last Hist_print commands. */
else
{
- num = history_length - Hist_print;
+ ci.num = history_length - Hist_print;
}
- if (num < 0)
- num = 0;
+ if (ci.num < 0)
+ ci.num = 0;
/* If there are at least Hist_print commands, we want to display the last
Hist_print rather than, say, the last 6. */
- if (history_length - num < Hist_print)
+ if (history_length - ci.num < Hist_print)
{
- num = history_length - Hist_print;
- if (num < 0)
- num = 0;
+ ci.num = history_length - Hist_print;
+ if (ci.num < 0)
+ ci.num = 0;
}
- for (offset = num;
- offset < num + Hist_print && offset < history_length;
+ for (offset = ci.num;
+ offset < ci.num + Hist_print && offset < history_length;
offset++)
{
printf_filtered ("%5d %s\n", history_base + offset,
@@ -1716,7 +1739,7 @@ show_commands (char *args, int from_tty)
/* The next command we want to display is the next one that we haven't
displayed yet. */
- num += Hist_print;
+ ci.num += Hist_print;
/* If the user repeats this command with return, it should do what
"show commands +" does. This is unnecessary if arg is null,
diff --git a/gdb/top.h b/gdb/top.h
index 7827a5346b7..94822772167 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -134,11 +134,14 @@ struct ui
/* See enum prompt_state's description. */
enum prompt_state prompt_state;
+ /* Per-UI info for printcmd.c. Initialized on demand. */
+ struct current_printcmd_info *curr_printcmd_info = NULL;
+
/* Per-UI info for source.c. Initialized on demand. */
struct current_source_info *curr_source_info = NULL;
- /* Per-UI info for printcmd.c. Initialized on demand. */
- struct current_printcmd_info *curr_printcmd_info = NULL;
+ /* Per-UI info for top.c. Initialized on demand. */
+ struct current_top_info *curr_top_info = NULL;
/* The fields below that start with "m_" are "private". They're
meant to be accessed through wrapper macros that make them look
@@ -243,6 +246,11 @@ extern void quit_command (char *, int);
extern void quit_cover (void);
extern void execute_command (char *, int);
+/* Delete the per-UI info of UI. */
+extern void delete_current_printcmd_info (struct ui *ui);
+extern void delete_current_source_info (struct ui *ui);
+extern void delete_current_top_info (struct ui *ui);
+
/* If the interpreter is in sync mode (we're running a user command's
list, running command hooks or similars), and we just ran a
synchronous command that started the target, wait for that command