/* TUI layout window management.
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+ Inc.
+
Contributed by Hewlett-Packard Company.
This file is part of GDB.
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
+ "defs.h" should be included first. Unfortunatly some systems
+ (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
+ and they clash with "bfd.h"'s definiton of true/false. The correct
+ fix is to remove true/false from "bfd.h", however, until that
+ happens, hack around it by including "config.h" and <curses.h>
+ first. */
+
+#include "config.h"
+#ifdef HAVE_NCURSES_H
+#include <ncurses.h>
+#else
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+#endif
+
#include "defs.h"
#include "command.h"
#include "symtab.h"
#include "frame.h"
+#include <ctype.h>
#include "tui.h"
#include "tuiData.h"
+#include "tuiDataWin.h"
#include "tuiGeneralWin.h"
#include "tuiStack.h"
#include "tuiRegs.h"
+#include "tuiWin.h"
+#include "tuiSourceWin.h"
#include "tuiDisassem.h"
/*******************************
static TuiLayoutType _prevLayout (void);
static void _tuiLayout_command (char *, int);
static void _tuiToggleLayout_command (char *, int);
-static void _tui_vToggleLayout_command (va_list);
static void _tuiToggleSplitLayout_command (char *, int);
-static void _tui_vToggleSplitLayout_command (va_list);
-static Opaque _extractDisplayStartAddr (void);
+static CORE_ADDR _extractDisplayStartAddr (void);
static void _tuiHandleXDBLayout (TuiLayoutDefPtr);
-static TuiStatus _tuiSetLayoutTo (char *);
/***************************************
** Show the screen layout defined
*/
void
-#ifdef __STDC__
-showLayout (
- TuiLayoutType layout)
-#else
-showLayout (layout)
- TuiLayoutType layout;
-#endif
+showLayout (TuiLayoutType layout)
{
TuiLayoutType curLayout = currentLayout ();
** to regsDisplayType.
*/
TuiStatus
-#ifdef __STDC__
-tuiSetLayout (
- TuiLayoutType layoutType,
- TuiRegisterDisplayType regsDisplayType)
-#else
-tuiSetLayout (layoutType, regsDisplayType)
- TuiLayoutType layoutType;
- TuiRegisterDisplayType regsDisplayType;
-#endif
+tuiSetLayout (TuiLayoutType layoutType,
+ TuiRegisterDisplayType regsDisplayType)
{
TuiStatus status = TUI_SUCCESS;
{
TuiLayoutType curLayout = currentLayout (), newLayout = UNDEFINED_LAYOUT;
int regsPopulate = FALSE;
- Opaque addr = _extractDisplayStartAddr ();
+ CORE_ADDR addr = _extractDisplayStartAddr ();
TuiWinInfoPtr newWinWithFocus = (TuiWinInfoPtr) NULL, winWithFocus = tuiWinWithFocus ();
TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
** 2. if target was compiled without -g
** We still want to show the assembly though!
*/
- addr = vcatch_errors ((OpaqueFuncPtr)
- tuiGetBeginAsmAddress);
+ addr = tuiGetBeginAsmAddress ();
tuiSetWinFocusTo (disassemWin);
layoutDef->displayMode = DISASSEM_WIN;
layoutDef->split = FALSE;
** 2. if target was compiled without -g
** We still want to show the assembly though!
*/
- addr = vcatch_errors ((OpaqueFuncPtr)
- tuiGetBeginAsmAddress);
+ addr = tuiGetBeginAsmAddress ();
if (winWithFocus == srcWin)
tuiSetWinFocusTo (srcWin);
else
** 2. if target was compiled without -g
** We still want to show the assembly though!
*/
- addr = vcatch_errors ((OpaqueFuncPtr)
- tuiGetBeginAsmAddress);
+ addr = tuiGetBeginAsmAddress ();
if (winWithFocus != dataWin)
tuiSetWinFocusTo (disassemWin);
else
return status;
} /* tuiSetLayout */
-
-/*
- ** tui_vSetLayoutTo()
- ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
- ** REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
- */
-TuiStatus
-#ifdef __STDC__
-tui_vSetLayoutTo (
- va_list args)
-#else
-tui_vSetLayoutTo (args)
- va_list args;
-#endif
-{
- char *layoutName;
-
- layoutName = va_arg (args, char *);
-
- return (_tuiSetLayoutTo (layoutName));
-} /* tui_vSetLayoutTo */
-
-
/*
** tuiAddWinToLayout().
** Add the specified window to the layout in a logical way.
** window to be added.
*/
void
-#ifdef __STDC__
-tuiAddWinToLayout (
- TuiWinType type)
-#else
-tuiAddWinToLayout (type)
- TuiWinType type;
-#endif
+tuiAddWinToLayout (TuiWinType type)
{
TuiLayoutType curLayout = currentLayout ();
} /* tuiAddWinToLayout */
-/*
- ** tui_vAddWinToLayout().
- ** Add the specified window to the layout in a logical way,
- ** with arguments in a va_list.
- */
-void
-#ifdef __STDC__
-tui_vAddWinToLayout (
- va_list args)
-#else
-tui_vAddWinToLayout (args)
- va_list args;
-#endif
-{
- TuiWinType type = va_arg (args, TuiWinType);
-
- tuiAddWinToLayout (type);
-
- return;
-} /* tui_vAddWinToLayout */
-
-
/*
** tuiDefaultWinHeight().
** Answer the height of a window. If it hasn't been created yet,
** type and the layout.
*/
int
-#ifdef __STDC__
-tuiDefaultWinHeight (
- TuiWinType type,
- TuiLayoutType layout)
-#else
-tuiDefaultWinHeight (type, layout)
- TuiWinType type;
- TuiLayoutType layout;
-#endif
+tuiDefaultWinHeight (TuiWinType type, TuiLayoutType layout)
{
int h;
** type and the layout.
*/
int
-#ifdef __STDC__
-tuiDefaultWinViewportHeight (
- TuiWinType type,
- TuiLayoutType layout)
-#else
-tuiDefaultWinViewportHeight (type, layout)
- TuiWinType type;
- TuiLayoutType layout;
-#endif
+tuiDefaultWinViewportHeight (TuiWinType type, TuiLayoutType layout)
{
int h;
void
_initialize_tuiLayout (void)
{
- if (tui_version)
- {
- add_com ("layout", class_tui, _tuiLayout_command,
- "Change the layout of windows.\n\
+ add_com ("layout", class_tui, _tuiLayout_command,
+ "Change the layout of windows.\n\
Usage: layout prev | next | <layout_name> \n\
Layout names are:\n\
src : Displays source and command windows.\n\
source/assembly/command (split) is displayed, \n\
the register window is displayed with \n\
the window that has current logical focus.\n");
- if (xdb_commands)
- {
- add_com ("td", class_tui, _tuiToggleLayout_command,
- "Toggle between Source/Command and Disassembly/Command layouts.\n");
- add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
- "Toggle between Source/Command or Disassembly/Command and \n\
+ if (xdb_commands)
+ {
+ add_com ("td", class_tui, _tuiToggleLayout_command,
+ "Toggle between Source/Command and Disassembly/Command layouts.\n");
+ add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
+ "Toggle between Source/Command or Disassembly/Command and \n\
Source/Disassembly/Command layouts.\n");
- }
}
-
- return;
-} /* _intialize_tuiLayout */
+}
/*************************
** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
** $REGS, $GREGS, $FREGS, $SREGS.
*/
-static TuiStatus
-#ifdef __STDC__
-_tuiSetLayoutTo (
- char *layoutName)
-#else
-_tuiSetLayoutTo (layoutName)
- char *layoutName;
-#endif
+TuiStatus
+tui_set_layout (const char *layoutName)
{
TuiStatus status = TUI_SUCCESS;
TuiRegisterDisplayType dpyType = TUI_UNDEFINED_REGS;
TuiLayoutType curLayout = currentLayout ();
- bufPtr = (char *) tuiStrDup (layoutName);
+ bufPtr = (char *) xstrdup (layoutName);
for (i = 0; (i < strlen (layoutName)); i++)
bufPtr[i] = toupper (bufPtr[i]);
}
else
{
- if (subsetCompare (bufPtr, "SRC"))
+ if (subset_compare (bufPtr, "SRC"))
newLayout = SRC_COMMAND;
- else if (subsetCompare (bufPtr, "ASM"))
+ else if (subset_compare (bufPtr, "ASM"))
newLayout = DISASSEM_COMMAND;
- else if (subsetCompare (bufPtr, "SPLIT"))
+ else if (subset_compare (bufPtr, "SPLIT"))
newLayout = SRC_DISASSEM_COMMAND;
- else if (subsetCompare (bufPtr, "REGS") ||
- subsetCompare (bufPtr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
- subsetCompare (bufPtr, TUI_GENERAL_REGS_NAME) ||
- subsetCompare (bufPtr, TUI_FLOAT_REGS_NAME) ||
- subsetCompare (bufPtr, TUI_SPECIAL_REGS_NAME))
+ else if (subset_compare (bufPtr, "REGS") ||
+ subset_compare (bufPtr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
+ subset_compare (bufPtr, TUI_GENERAL_REGS_NAME) ||
+ subset_compare (bufPtr, TUI_FLOAT_REGS_NAME) ||
+ subset_compare (bufPtr, TUI_SPECIAL_REGS_NAME))
{
if (curLayout == SRC_COMMAND || curLayout == SRC_DATA_COMMAND)
newLayout = SRC_DATA_COMMAND;
layout command issued by the user. HP has asked us to hook up this code
- edie epstein
*/
- if (subsetCompare (bufPtr, TUI_FLOAT_REGS_NAME))
+ if (subset_compare (bufPtr, TUI_FLOAT_REGS_NAME))
{
if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
TUI_SFLOAT_REGS &&
dpyType =
dataWin->detail.dataDisplayInfo.regsDisplayType;
}
- else if (subsetCompare (bufPtr,
+ else if (subset_compare (bufPtr,
TUI_GENERAL_SPECIAL_REGS_NAME))
dpyType = TUI_GENERAL_AND_SPECIAL_REGS;
- else if (subsetCompare (bufPtr, TUI_GENERAL_REGS_NAME))
+ else if (subset_compare (bufPtr, TUI_GENERAL_REGS_NAME))
dpyType = TUI_GENERAL_REGS;
- else if (subsetCompare (bufPtr, TUI_SPECIAL_REGS_NAME))
+ else if (subset_compare (bufPtr, TUI_SPECIAL_REGS_NAME))
dpyType = TUI_SPECIAL_REGS;
- else
+ else if (dataWin)
{
if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
TUI_UNDEFINED_REGS)
/* dpyType = TUI_GENERAL_REGS;
*/
}
- else if (subsetCompare (bufPtr, "NEXT"))
+ else if (subset_compare (bufPtr, "NEXT"))
newLayout = _nextLayout ();
- else if (subsetCompare (bufPtr, "PREV"))
+ else if (subset_compare (bufPtr, "PREV"))
newLayout = _prevLayout ();
else
status = TUI_FAILURE;
status = TUI_FAILURE;
return status;
-} /* _tuiSetLayoutTo */
+}
-static Opaque
-#ifdef __STDC__
+static CORE_ADDR
_extractDisplayStartAddr (void)
-#else
-_extractDisplayStartAddr ()
-#endif
{
TuiLayoutType curLayout = currentLayout ();
- Opaque addr;
+ CORE_ADDR addr;
+ CORE_ADDR pc;
switch (curLayout)
{
case SRC_COMMAND:
case SRC_DATA_COMMAND:
- addr = (Opaque) find_line_pc (
- current_source_symtab,
- srcWin->detail.sourceInfo.startLineOrAddr.lineNo);
+ find_line_pc (current_source_symtab,
+ srcWin->detail.sourceInfo.startLineOrAddr.lineNo,
+ &pc);
+ addr = pc;
break;
case DISASSEM_COMMAND:
case SRC_DISASSEM_COMMAND:
addr = disassemWin->detail.sourceInfo.startLineOrAddr.addr;
break;
default:
- addr = (Opaque) NULL;
+ addr = 0;
break;
}
static void
-#ifdef __STDC__
-_tuiHandleXDBLayout (
- TuiLayoutDefPtr layoutDef)
-#else
-_tuiHandleXDBLayout (layoutDef)
- TuiLayoutDefPtr layoutDef;
-#endif
+_tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef)
{
if (layoutDef->split)
{
static void
-#ifdef __STDC__
-_tuiToggleLayout_command (
- char *arg,
- int fromTTY)
-#else
-_tuiToggleLayout_command (arg, fromTTY)
- char *arg;
- int fromTTY;
-#endif
-{
- tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleLayout_command, arg, fromTTY);
-}
-
-static void
-#ifdef __STDC__
-_tui_vToggleLayout_command (
- va_list args)
-#else
-_tui_vToggleLayout_command (args)
- va_list args;
-#endif
+_tuiToggleLayout_command (char *arg, int fromTTY)
{
TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
if (layoutDef->displayMode == SRC_WIN)
layoutDef->displayMode = DISASSEM_WIN;
else
if (!layoutDef->split)
_tuiHandleXDBLayout (layoutDef);
- return;
-} /* _tuiToggleLayout_command */
-
-
-static void
-#ifdef __STDC__
-_tuiToggleSplitLayout_command (
- char *arg,
- int fromTTY)
-#else
-_tuiToggleSplitLayout_command (arg, fromTTY)
- char *arg;
- int fromTTY;
-#endif
-{
- tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleSplitLayout_command, arg, fromTTY);
}
+
static void
-#ifdef __STDC__
-_tui_vToggleSplitLayout_command (
- va_list args)
-#else
-_tui_vToggleSplitLayout_command (args)
- va_list args;
-#endif
+_tuiToggleSplitLayout_command (char *arg, int fromTTY)
{
TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
layoutDef->split = (!layoutDef->split);
_tuiHandleXDBLayout (layoutDef);
- return;
-} /* _tui_vToggleSplitLayout_command */
+}
static void
-#ifdef __STDC__
-_tuiLayout_command (
- char *arg,
- int fromTTY)
-#else
-_tuiLayout_command (arg, fromTTY)
- char *arg;
- int fromTTY;
-#endif
+_tuiLayout_command (char *arg, int fromTTY)
{
- if ((TuiStatus) tuiDo (
- (TuiOpaqueFuncPtr) tui_vSetLayoutTo, arg) != TUI_SUCCESS)
- warning ("Invalid layout specified.\n%s" LAYOUT_USAGE);
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
- return;
-} /* _tuiLayout_command */
+ /* Switch to the selected layout. */
+ if (tui_set_layout (arg) != TUI_SUCCESS)
+ warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
+
+}
/*
** _nextLayout().
** Answer the previous layout to cycle to.
*/
static TuiLayoutType
-#ifdef __STDC__
_nextLayout (void)
-#else
-_nextLayout ()
-#endif
{
TuiLayoutType newLayout;
** Answer the next layout to cycle to.
*/
static TuiLayoutType
-#ifdef __STDC__
_prevLayout (void)
-#else
-_prevLayout ()
-#endif
{
TuiLayoutType newLayout;
** _makeCommandWindow().
*/
static void
-#ifdef __STDC__
-_makeCommandWindow (
- TuiWinInfoPtr * winInfoPtr,
- int height,
- int originY)
-#else
-_makeCommandWindow (winInfoPtr, height, originY)
- TuiWinInfoPtr *winInfoPtr;
- int height;
- int originY;
-#endif
+_makeCommandWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
{
_initAndMakeWin ((Opaque *) winInfoPtr,
CMD_WIN,
** _makeSourceWindow().
*/
static void
-#ifdef __STDC__
-_makeSourceWindow (
- TuiWinInfoPtr * winInfoPtr,
- int height,
- int originY)
-#else
-_makeSourceWindow (winInfoPtr, height, originY)
- TuiWinInfoPtr *winInfoPtr;
- int height;
- int originY;
-#endif
+_makeSourceWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
{
_makeSourceOrDisassemWindow (winInfoPtr, SRC_WIN, height, originY);
** _makeDisassemWindow().
*/
static void
-#ifdef __STDC__
-_makeDisassemWindow (
- TuiWinInfoPtr * winInfoPtr,
- int height,
- int originY)
-#else
-_makeDisassemWindow (winInfoPtr, height, originY)
- TuiWinInfoPtr *winInfoPtr;
- int height;
- int originY;
-#endif
+_makeDisassemWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
{
_makeSourceOrDisassemWindow (winInfoPtr, DISASSEM_WIN, height, originY);
** _makeDataWindow().
*/
static void
-#ifdef __STDC__
-_makeDataWindow (
- TuiWinInfoPtr * winInfoPtr,
- int height,
- int originY)
-#else
-_makeDataWindow (winInfoPtr, height, originY)
- TuiWinInfoPtr *winInfoPtr;
- int height;
- int originY;
-#endif
+_makeDataWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
{
_initAndMakeWin ((Opaque *) winInfoPtr,
DATA_WIN,
** Show the Source/Command layout
*/
static void
-#ifdef __STDC__
_showSourceCommand (void)
-#else
-_showSourceCommand ()
-#endif
{
_showSourceOrDisassemAndCommand (SRC_COMMAND);
** Show the Dissassem/Command layout
*/
static void
-#ifdef __STDC__
_showDisassemCommand (void)
-#else
-_showDisassemCommand ()
-#endif
{
_showSourceOrDisassemAndCommand (DISASSEM_COMMAND);
** Show the Source/Disassem/Command layout
*/
static void
-#ifdef __STDC__
_showSourceDisassemCommand (void)
-#else
-_showSourceDisassemCommand ()
-#endif
{
TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
** Show the Source/Data/Command or the Dissassembly/Data/Command layout
*/
static void
-#ifdef __STDC__
-_showData (
- TuiLayoutType newLayout)
-#else
-_showData (newLayout)
- TuiLayoutType newLayout;
-#endif
+_showData (TuiLayoutType newLayout)
{
int totalHeight = (termHeight () - cmdWin->generic.height);
int srcHeight, dataHeight;
** _initGenWinInfo().
*/
static void
-#ifdef __STDC__
-_initGenWinInfo (
- TuiGenWinInfoPtr winInfo,
- TuiWinType type,
- int height,
- int width,
- int originX,
- int originY)
-#else
-_initGenWinInfo (winInfo, type, height, width, originX, originY)
- TuiGenWinInfoPtr winInfo;
- TuiWinType type;
- int height;
- int width;
- int originX;
- int originY;
-#endif
+_initGenWinInfo (TuiGenWinInfoPtr winInfo, TuiWinType type,
+ int height, int width, int originX, int originY)
{
int h = height;
** _initAndMakeWin().
*/
static void
-#ifdef __STDC__
-_initAndMakeWin (
- Opaque * winInfoPtr,
- TuiWinType winType,
- int height,
- int width,
- int originX,
- int originY,
- int boxIt)
-#else
-_initAndMakeWin (winInfoPtr, winType, height, width, originX, originY, boxIt)
- Opaque *winInfoPtr;
- TuiWinType winType;
- int height;
- int width;
- int originX;
- int originY;
- int boxIt;
-#endif
+_initAndMakeWin (Opaque * winInfoPtr, TuiWinType winType,
+ int height, int width, int originX, int originY, int boxIt)
{
Opaque opaqueWinInfo = *winInfoPtr;
TuiGenWinInfoPtr generic;
makeWindow (generic, boxIt);
if (winType == LOCATOR_WIN)
tuiClearLocatorDisplay ();
- echo ();
}
*winInfoPtr = opaqueWinInfo;
** _makeSourceOrDisassemWindow().
*/
static void
-#ifdef __STDC__
-_makeSourceOrDisassemWindow (
- TuiWinInfoPtr * winInfoPtr,
- TuiWinType type,
- int height,
- int originY)
-#else
-_makeSourceOrDisassemWindow (winInfoPtr, type, height, originY)
- TuiWinInfoPtr *winInfoPtr;
- TuiWinType type;
- int height;
- int originY;
-#endif
+_makeSourceOrDisassemWindow (TuiWinInfoPtr * winInfoPtr, TuiWinType type,
+ int height, int originY)
{
TuiGenWinInfoPtr executionInfo = (TuiGenWinInfoPtr) NULL;
** Show the Source/Command or the Disassem layout
*/
static void
-#ifdef __STDC__
-_showSourceOrDisassemAndCommand (
- TuiLayoutType layoutType)
-#else
-_showSourceOrDisassemAndCommand (layoutType)
- TuiLayoutType layoutType;
-#endif
+_showSourceOrDisassemAndCommand (TuiLayoutType layoutType)
{
if (currentLayout () != layoutType)
{