* [RFA]: Remove tui hacks from gdb source.c
@ 2001-07-16 14:55 Stephane Carrez
2001-07-16 16:01 ` Andrew Cagney
0 siblings, 1 reply; 2+ messages in thread
From: Stephane Carrez @ 2001-07-16 14:55 UTC (permalink / raw)
To: gdb-patches
Hi!
The tui hacks in gdb/source.c can all be removed, if in the tui we do
the following:
- use `identify_source_line' each time the curses source window
is scrolled. This is necessary to update the static variable
`last_line_listed'.
- have a specific cli that clears the ui_source_list and does some
filtering on the ui_out fields (which is not easy but works).
The patch below cleans up source.c to remove the tui hacks.
Is it ok?
Stephane
2001-07-16 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* source.c (find_source_lines): Remove tui test, must be replaced
by appropriate warning hook.
(print_source_lines): Remove tui hacks, must be replaced by cli.
(forward_search_command): Remove tui hacks, can be replaced by
appropriate calls to identify_source_line when tui scrolls.
(reverse_search_command): Likewise.
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.18
diff -u -p -r1.18 source.c
--- source.c 2001/07/07 17:19:50 1.18
+++ source.c 2001/07/16 21:53:40
@@ -797,8 +797,6 @@ find_source_lines (struct symtab *s, int
if (mtime && mtime < st.st_mtime)
{
- if (tui_version)
- printf_filtered ("\n");
warning ("Source file is more recent than executable.\n");
}
@@ -1134,31 +1132,7 @@ print_source_lines_base (struct symtab *
void
print_source_lines (struct symtab *s, int line, int stopline, int noerror)
{
-#if defined(TUI)
- if (!tui_version ||
- m_winPtrIsNull (srcWin) || !srcWin->generic.isVisible)
- print_source_lines_base (s, line, stopline, noerror);
- else
- {
- TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
-extern void tui_vAddWinToLayout (va_list);
-extern void tui_vUpdateSourceWindowsWithLine (va_list);
-
- /* Regardless of whether we can open the file,
- set current_source_symtab. */
- current_source_symtab = s;
- current_source_line = line;
- first_line_listed = line;
-
- /* make sure that the source window is displayed */
- tuiDo ((TuiOpaqueFuncPtr) tui_vAddWinToLayout, SRC_WIN);
-
- tuiDo ((TuiOpaqueFuncPtr) tui_vUpdateSourceWindowsWithLine, s, line);
- tuiDo ((TuiOpaqueFuncPtr) tui_vUpdateLocatorFilename, s->filename);
- }
-#else
print_source_lines_base (s, line, stopline, noerror);
-#endif
}
\f
@@ -1463,29 +1437,7 @@ forward_search_command (char *regex, int
int line;
char *msg;
-#if defined(TUI)
- /*
- ** If this is the TUI, search from the first line displayed in
- ** the source window, otherwise, search from last_line_listed+1
- ** in current_source_symtab
- */
- if (!tui_version)
- line = last_line_listed;
- else
- {
- if (srcWin->generic.isVisible && srcWin->generic.contentSize > 0)
- line = ((TuiWinContent)
- srcWin->generic.content)[0]->whichElement.source.lineOrAddr.lineNo;
- else
- {
- printf_filtered ("No source displayed.\nExpression not found.\n");
- return;
- }
- }
- line++;
-#else
line = last_line_listed + 1;
-#endif
msg = (char *) re_comp (regex);
if (msg)
@@ -1557,8 +1509,6 @@ forward_search_command (char *regex, int
{
/* Match! */
fclose (stream);
- if (tui_version)
- print_source_lines_base (current_source_symtab, line, line + 1, 0);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
value_from_longest (builtin_type_int,
@@ -1582,29 +1532,8 @@ reverse_search_command (char *regex, int
register FILE *stream;
int line;
char *msg;
-#if defined(TUI)
- /*
- ** If this is the TUI, search from the first line displayed in
- ** the source window, otherwise, search from last_line_listed-1
- ** in current_source_symtab
- */
- if (!tui_version)
- line = last_line_listed;
- else
- {
- if (srcWin->generic.isVisible && srcWin->generic.contentSize > 0)
- line = ((TuiWinContent)
- srcWin->generic.content)[0]->whichElement.source.lineOrAddr.lineNo;
- else
- {
- printf_filtered ("No source displayed.\nExpression not found.\n");
- return;
- }
- }
- line--;
-#else
+
line = last_line_listed - 1;
-#endif
msg = (char *) re_comp (regex);
if (msg)
@@ -1665,8 +1594,6 @@ reverse_search_command (char *regex, int
{
/* Match! */
fclose (stream);
- if (tui_version)
- print_source_lines_base (current_source_symtab, line, line + 1, 0);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
value_from_longest (builtin_type_int,
From Stephane.Carrez@worldnet.fr Mon Jul 16 14:56:00 2001
From: Stephane Carrez <Stephane.Carrez@worldnet.fr>
To: gdb-patches@sources.redhat.com
Subject: [RFA]: Cleanup tui/tui-file.[ch]
Date: Mon, 16 Jul 2001 14:56:00 -0000
Message-id: <3B536421.C4F0E04D@worldnet.fr>
X-SW-Source: 2001-07/msg00391.html
Content-length: 4428
Hi!
The following patch cleans up the tui/tui-file to remove the
old and unused fputs_unfiltered_hook; It also simplifies the
implementation.
Can you approve this patch?
Stephane
2001-07-16 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* tui-file.h (fputs_unfiltered_hook): Remove.
* tui-file.c (tui_file_flush): Remove fputs_unfiltered_hook.
(tui_file_fputs): Likewise; simplify
Index: tui-file.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-file.c,v
retrieving revision 1.6
diff -u -p -r1.6 tui-file.c
--- tui-file.c 2001/02/08 06:03:54 1.6
+++ tui-file.c 2001/07/16 21:52:08
@@ -22,20 +22,10 @@
#include "ui-file.h"
#include "tui/tui-file.h"
-#ifdef TUI
#include "tui.h"
-#include "tuiData.h"
-#include "tuiIO.h"
-#include "tuiCommand.h"
-#endif
#include <string.h>
-/* Called instead of fputs for all TUI_FILE output. */
-
-void (*fputs_unfiltered_hook) (const char *linebuffer,
- struct ui_file * stream);
-
/* A ``struct ui_file'' that is compatible with all the legacy
code. */
@@ -176,66 +166,15 @@ void
tui_file_fputs (const char *linebuffer, struct ui_file *file)
{
struct tui_stream *stream = ui_file_data (file);
-#if defined(TUI)
- extern int tui_owns_terminal;
-#endif
- /* NOTE: cagney/1999-10-13: The use of fputs_unfiltered_hook is
- seriously discouraged. Those wanting to hook output should
- instead implement their own ui_file object and install that. See
- also tui_file_flush(). */
- if (fputs_unfiltered_hook
- && (file == gdb_stdout
- || file == gdb_stderr))
- fputs_unfiltered_hook (linebuffer, file);
+
+ if (stream->ts_streamtype == astring)
+ {
+ tui_file_adjust_strbuf (strlen (linebuffer), file);
+ strcat (stream->ts_strbuf, linebuffer);
+ }
else
{
-#if defined(TUI)
- if (tui_version && tui_owns_terminal)
- {
- /* If we get here somehow while updating the TUI (from
- * within a tuiDo(), then we need to temporarily
- * set up the terminal for GDB output. This probably just
- * happens on error output.
- */
-
- if (stream->ts_streamtype == astring)
- {
- tui_file_adjust_strbuf (strlen (linebuffer), file);
- strcat (stream->ts_strbuf, linebuffer);
- }
- else
- {
- tuiTermUnsetup (0, (tui_version) ? cmdWin->detail.commandInfo.curch : 0);
- fputs (linebuffer, stream->ts_filestream);
- tuiTermSetup (0);
- if (linebuffer[strlen (linebuffer) - 1] == '\n')
- tuiClearCommandCharCount ();
- else
- tuiIncrCommandCharCountBy (strlen (linebuffer));
- }
- }
- else
- {
- /* The normal case - just do a fputs() */
- if (stream->ts_streamtype == astring)
- {
- tui_file_adjust_strbuf (strlen (linebuffer), file);
- strcat (stream->ts_strbuf, linebuffer);
- }
- else
- fputs (linebuffer, stream->ts_filestream);
- }
-
-
-#else
- if (stream->ts_streamtype == astring)
- {
- tui_file_adjust_strbuf (strlen (linebuffer), file);
- strcat (stream->ts_strbuf, linebuffer);
- }
- else
- fputs (linebuffer, stream->ts_filestream);
-#endif
+ tuiPuts_unfiltered (linebuffer, file);
}
}
@@ -286,13 +225,6 @@ tui_file_flush (struct ui_file *file)
if (stream->ts_magic != &tui_file_magic)
internal_error (__FILE__, __LINE__,
"tui_file_flush: bad magic number");
-
- /* NOTE: cagney/1999-10-12: If we've been linked with code that uses
- fputs_unfiltered_hook then we assume that it doesn't need to know
- about flushes. Code that does need to know about flushes can
- implement a proper ui_file object. */
- if (fputs_unfiltered_hook)
- return;
switch (stream->ts_streamtype)
{
Index: tui-file.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-file.h,v
retrieving revision 1.2
diff -u -p -r1.2 tui-file.h
--- tui-file.h 2001/03/06 08:22:01 1.2
+++ tui-file.h 2001/07/16 21:52:08
@@ -26,9 +26,4 @@ extern struct ui_file *tui_sfileopen (in
extern char *tui_file_get_strbuf (struct ui_file *);
extern void tui_file_adjust_strbuf (int, struct ui_file *);
-/* NOTE: cagney/1999-10-14: fputs_unfiltered_hook is deprecated. Code
- wanting to control GDB's output should override the gdb_std...
- files. */
-extern void (*fputs_unfiltered_hook) (const char *linebuffer,
- struct ui_file * stream);
#endif
From Stephane.Carrez@worldnet.fr Mon Jul 16 15:00:00 2001
From: Stephane Carrez <Stephane.Carrez@worldnet.fr>
To: gdb-patches@sources.redhat.com
Subject: [RFA]: Cleanup Makefile.in to move tui-file.o to SUBDIR_TUI_OBS
Date: Mon, 16 Jul 2001 15:00:00 -0000
Message-id: <3B5364FB.59A050BC@worldnet.fr>
X-SW-Source: 2001-07/msg00392.html
Content-length: 1328
Hi!
I propose the following patch to cleanup the gdb makefile a little
and avoid to build tui-file.o for normal gdb. This file is tui specific
and should better appear in SUBDIR_TUI_OBS.
Can you approve this patch?
Stephane
2001-07-16 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* Makefile.in (COMMON_OBS): Remove tui-file.o.
(SUBDIR_TUI_OBS): Add it here.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.97
diff -u -p -r1.97 Makefile.in
--- Makefile.in 2001/07/14 09:50:25 1.97
+++ Makefile.in 2001/07/16 21:58:43
@@ -183,7 +183,7 @@ SUBDIR_MI_UNINSTALL=
# TUI sub directory definitions
#
SUBDIR_TUI_OBS = \
- tui.o tuiData.o tuiSource.o tuiStack.o tuiIO.o \
+ tui-file.o tui.o tuiData.o tuiSource.o tuiStack.o tuiIO.o \
tuiGeneralWin.o tuiLayout.o tuiWin.o tuiCommand.o \
tuiDisassem.o tuiSourceWin.o tuiRegs.o tuiDataWin.o
SUBDIR_TUI_SRCS = \
@@ -693,7 +693,7 @@ COMMON_OBS = version.o blockframe.o brea
c-typeprint.o ch-typeprint.o f-typeprint.o m2-typeprint.o \
c-valprint.o cp-valprint.o ch-valprint.o f-valprint.o m2-valprint.o \
nlmread.o serial.o mdebugread.o os9kread.o top.o utils.o \
- ui-file.o tui-file.o \
+ ui-file.o \
frame.o \
gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o
From Stephane.Carrez@worldnet.fr Mon Jul 16 15:02:00 2001
From: Stephane Carrez <Stephane.Carrez@worldnet.fr>
To: gdb-patches@sources.redhat.com
Subject: [RFA]: Fix register display in TUI
Date: Mon, 16 Jul 2001 15:02:00 -0000
Message-id: <3B536594.EB5E7503@worldnet.fr>
X-SW-Source: 2001-07/msg00393.html
Content-length: 7437
Hi!
The following patch fixes the TUI to display the registers in a generic way.
- it uses do_register_info() to get a particular register name+value.
The gdb_stdout is redirected to a string. A cleanup is installed
to restore gdb_stdout to its origin and free the redirected stream.
- it uses get_saved_register() to obtain the value of a register.
That value is then saved in tui internal struct so that it can detect
when a register is changed.
Can you approve this patch?
Stephane
2001-07-16 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* tuiRegs.c (tuiDisplayRegistersFrom): Set scrollok to FALSE in
each register window.
(tuiCheckRegisterValues): Use REGISTER_RAW_SIZE to obtain the size
of the register to check.
(_tuiRegValueHasChanged): Likewise.
(_tuiRegisterName): Use REGISTER_NAME.
(tui_restore_gdbout): New function.
(_tuiRegisterFormat): Use do_registers_info with gdb_stdout redirected
to a string.
(START_SPECIAL_REGS): Define.
(_tuiGetRegisterRawValue): Use get_saved_register.
(_tuiDisplayRegister): Fix clearing of register window.
Index: tuiRegs.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiRegs.c,v
retrieving revision 1.6
diff -u -p -r1.6 tuiRegs.c
--- tuiRegs.c 2001/07/14 19:31:09 1.6
+++ tuiRegs.c 2001/07/16 21:52:13
@@ -30,8 +30,8 @@
#include "target.h"
#include "tuiLayout.h"
#include "tuiWin.h"
+#include "tui-file.h"
-
/*****************************************
** LOCAL DEFINITIONS **
******************************************/
@@ -43,9 +43,9 @@
#define SINGLE_FLOAT_LABEL_FMT "%6.6s: "
#define SINGLE_FLOAT_VALUE_WIDTH 25 /* min of 8 but may be in sci notation */
-#define SINGLE_LABEL_WIDTH 10
+#define SINGLE_LABEL_WIDTH 16
#define SINGLE_LABEL_FMT "%10.10s: "
-#define SINGLE_VALUE_WIDTH 14 /* minimum of 8 but may be in sci notation */
+#define SINGLE_VALUE_WIDTH 20 /* minimum of 8 but may be in sci notation */
/* In the code HP gave Cygnus, this was actually a function call to a
PA-specific function, which was supposed to determine whether the
@@ -344,6 +344,7 @@ tuiDisplayRegistersFrom (int startElemen
dataItemWin->origin.x = (itemWinWidth * j) + 1;
dataItemWin->origin.y = curY;
makeWindow (dataItemWin, DONT_BOX_WINDOW);
+ scrollok (dataItemWin->handle, FALSE);
}
/*
** Get the printable representation of the register
@@ -484,7 +485,10 @@ tuiCheckRegisterValues (struct frame_inf
_tuiRegValueHasChanged (dataElementPtr, frame, &rawBuf[0]);
if (dataElementPtr->highlight)
{
- for (j = 0; j < MAX_REGISTER_RAW_SIZE; j++)
+ int size;
+
+ size = REGISTER_RAW_SIZE (dataElementPtr->itemNo);
+ for (j = 0; j < size; j++)
((char *) dataElementPtr->value)[j] = rawBuf[j];
_tuiDisplayRegister (
dataElementPtr->itemNo,
@@ -573,12 +577,17 @@ registers.\n",
static char *
_tuiRegisterName (int regNum)
{
- if (reg_names[regNum] != (char *) NULL && *(reg_names[regNum]) != (char) 0)
- return reg_names[regNum];
- else
- return ((char *) NULL);
-} /* tuiGetRegisterName */
+ return REGISTER_NAME (regNum);
+}
+extern int pagination_enabled;
+static void
+tui_restore_gdbout (void *ui)
+{
+ ui_file_delete (gdb_stdout);
+ gdb_stdout = (struct ui_file*) ui;
+ pagination_enabled = 1;
+}
/*
** _tuiRegisterFormat
@@ -590,17 +599,36 @@ _tuiRegisterFormat (char *buf, int bufLe
TuiDataElementPtr dataElement,
enum precision_type precision)
{
- char tmpBuf[15];
- char *fmt;
struct ui_file *stream;
-
+ struct ui_file *old_stdout;
+ char *name;
+ struct cleanup *cleanups;
+ char *p;
+
+ name = REGISTER_NAME (regNum);
+ if (name == 0)
+ {
+ strcpy (buf, "");
+ return;
+ }
+
+ pagination_enabled = 0;
+ old_stdout = gdb_stdout;
stream = tui_sfileopen (bufLen);
- pa_do_strcat_registers_info (regNum, 0, stream, precision);
- strcpy (buf, tui_file_get_strbuf (stream));
- ui_file_delete (stream);
+ gdb_stdout = stream;
+ cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);
+ do_registers_info (regNum, 0);
+
+ /* Save formatted output in the buffer. */
+ strncpy (buf, tui_file_get_strbuf (stream), bufLen);
+
+ /* Remove the possible \n. */
+ p = strchr (buf, '\n');
+ if (p)
+ *p = 0;
- return;
-} /* _tuiRegisterFormat */
+ do_cleanups (cleanups);
+}
#define NUM_GENERAL_REGS 32
@@ -620,7 +648,12 @@ _tuiSetGeneralRegsContent (int refreshVa
} /* _tuiSetGeneralRegsContent */
+#ifndef PCOQ_HEAD_REGNUM
+#define START_SPECIAL_REGS 0
+#else
#define START_SPECIAL_REGS PCOQ_HEAD_REGNUM
+#endif
+
/*
** _tuiSetSpecialRegsContent().
** Set the content of the data window to consist of the special registers.
@@ -676,8 +709,7 @@ _tuiSetGeneralAndSpecialRegsContent (int
** Set the content of the data window to consist of the float registers.
*/
static TuiStatus
-_tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType,
- int refreshValuesOnly)
+_tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType, int refreshValuesOnly)
{
TuiStatus ret = TUI_FAILURE;
int i, startRegNum;
@@ -720,11 +752,13 @@ _tuiRegValueHasChanged (TuiDataElementPt
if (_tuiGetRegisterRawValue (
dataElement->itemNo, rawBuf, frame) == TUI_SUCCESS)
{
- for (i = 0; (i < MAX_REGISTER_RAW_SIZE && !hasChanged); i++)
+ int size = REGISTER_RAW_SIZE (dataElement->itemNo);
+
+ for (i = 0; (i < size && !hasChanged); i++)
hasChanged = (((char *) dataElement->value)[i] != rawBuf[i]);
if (hasChanged && newValue != (char *) NULL)
{
- for (i = 0; (i < MAX_REGISTER_RAW_SIZE); i++)
+ for (i = 0; i < size; i++)
newValue[i] = rawBuf[i];
}
}
@@ -739,17 +773,19 @@ _tuiRegValueHasChanged (TuiDataElementPt
** Get the register raw value. The raw value is returned in regValue.
*/
static TuiStatus
-_tuiGetRegisterRawValue (int regNum, char *regValue,
- struct frame_info *frame)
+_tuiGetRegisterRawValue (int regNum, char *regValue, struct frame_info *frame)
{
TuiStatus ret = TUI_FAILURE;
if (target_has_registers)
{
- read_relative_register_raw_bytes_for_frame (regNum, regValue, frame);
- ret = TUI_SUCCESS;
+ int opt;
+
+ get_saved_register (regValue, &opt, (CORE_ADDR*) NULL, frame,
+ regNum, (enum lval_type*) NULL);
+ if (register_cached (regNum) >= 0)
+ ret = TUI_SUCCESS;
}
-
return ret;
} /* _tuiGetRegisterRawValue */
@@ -873,7 +909,8 @@ _tuiDisplayRegister (int regNum,
{
if (winInfo->handle != (WINDOW *) NULL)
{
- char buf[100];
+ int i;
+ char buf[40];
int valueCharsWide, labelWidth;
TuiDataElementPtr dataElementPtr = &((TuiWinContent)
winInfo->content)[0]->whichElement.data;
@@ -905,10 +942,13 @@ _tuiDisplayRegister (int regNum,
regNum,
dataElementPtr,
precision);
+
if (dataElementPtr->highlight)
wstandout (winInfo->handle);
- werase (winInfo->handle);
+ wmove (winInfo->handle, 0, 0);
+ for (i = 1; i < winInfo->width; i++)
+ waddch (winInfo->handle, ' ');
wmove (winInfo->handle, 0, 0);
waddstr (winInfo->handle, buf);
From jimb@zwingli.cygnus.com Mon Jul 16 15:03:00 2001
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: Eli Zaretskii <eliz@is.elta.co.il>
Cc: msnyder@redhat.com, gdb-patches@sources.redhat.com, ac131313@cygnus.com
Subject: Re: [RFA] enum enable
Date: Mon, 16 Jul 2001 15:03:00 -0000
Message-id: <npzoa4y1hp.fsf@zwingli.cygnus.com>
References: <Pine.SUN.3.91.1010711161311.5321C-100000@is> <3B4E41B5.64FB@redhat.com> <3028-Sat14Jul2001140821+0300-eliz@is.elta.co.il>
X-SW-Source: 2001-07/msg00394.html
Content-length: 410
Oh, I hadn't seen this message from Andrew:
Andrew Cagney <ac131313@cygnus.com> writes:
> My preference is for memattr.c to use ``int enabled_p'' and for
> breakpoint.h to use something like ``enum bp_state { bp_enabled, ...''.
Anyway, I get compilation errors with your patch. There are uses of
the old struct tracepoint `enabled' member that your patch didn't
catch.
(Or I botched appyling the patch.)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-07-16 16:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-16 14:55 [RFA]: Remove tui hacks from gdb source.c Stephane Carrez
2001-07-16 16:01 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox