OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [tui/] [tuiSourceWin.c] - Diff between revs 107 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 107 Rev 1765
/*
/*
   ** tuiSourceWin.c
   ** tuiSourceWin.c
   **         This module contains functions for displaying source or assembly in the "source" window.
   **         This module contains functions for displaying source or assembly in the "source" window.
   *        The "source" window may be the assembly or the source windows.
   *        The "source" window may be the assembly or the source windows.
 */
 */
 
 
#include "defs.h"
#include "defs.h"
#include <ctype.h>
#include <ctype.h>
#include "symtab.h"
#include "symtab.h"
#include "frame.h"
#include "frame.h"
#include "breakpoint.h"
#include "breakpoint.h"
 
 
#include "tui.h"
#include "tui.h"
#include "tuiData.h"
#include "tuiData.h"
#include "tuiStack.h"
#include "tuiStack.h"
#include "tuiSourceWin.h"
#include "tuiSourceWin.h"
#include "tuiSource.h"
#include "tuiSource.h"
#include "tuiDisassem.h"
#include "tuiDisassem.h"
 
 
 
 
/*****************************************
/*****************************************
** EXTERNAL FUNCTION DECLS                **
** EXTERNAL FUNCTION DECLS                **
******************************************/
******************************************/
 
 
/*****************************************
/*****************************************
** EXTERNAL DATA DECLS                    **
** EXTERNAL DATA DECLS                    **
******************************************/
******************************************/
extern int current_source_line;
extern int current_source_line;
extern struct symtab *current_source_symtab;
extern struct symtab *current_source_symtab;
 
 
 
 
/*****************************************
/*****************************************
** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
******************************************/
******************************************/
 
 
/*****************************************
/*****************************************
** STATIC LOCAL DATA                    **
** STATIC LOCAL DATA                    **
******************************************/
******************************************/
 
 
 
 
/*****************************************
/*****************************************
** PUBLIC FUNCTIONS                        **
** PUBLIC FUNCTIONS                        **
******************************************/
******************************************/
 
 
/*********************************
/*********************************
** SOURCE/DISASSEM  FUNCTIONS    **
** SOURCE/DISASSEM  FUNCTIONS    **
*********************************/
*********************************/
 
 
/*
/*
   ** tuiSrcWinIsDisplayed().
   ** tuiSrcWinIsDisplayed().
 */
 */
int
int
#ifdef __STDC__
#ifdef __STDC__
tuiSrcWinIsDisplayed (void)
tuiSrcWinIsDisplayed (void)
#else
#else
tuiSrcWinIsDisplayed ()
tuiSrcWinIsDisplayed ()
#endif
#endif
{
{
  return (m_winPtrNotNull (srcWin) && srcWin->generic.isVisible);
  return (m_winPtrNotNull (srcWin) && srcWin->generic.isVisible);
}                               /* tuiSrcWinIsDisplayed */
}                               /* tuiSrcWinIsDisplayed */
 
 
 
 
/*
/*
   ** tuiAsmWinIsDisplayed().
   ** tuiAsmWinIsDisplayed().
 */
 */
int
int
#ifdef __STDC__
#ifdef __STDC__
tuiAsmWinIsDisplayed (void)
tuiAsmWinIsDisplayed (void)
#else
#else
tuiAsmWinIsDisplayed ()
tuiAsmWinIsDisplayed ()
#endif
#endif
{
{
  return (m_winPtrNotNull (disassemWin) && disassemWin->generic.isVisible);
  return (m_winPtrNotNull (disassemWin) && disassemWin->generic.isVisible);
}                               /* tuiAsmWinIsDisplayed */
}                               /* tuiAsmWinIsDisplayed */
 
 
 
 
/*
/*
   ** tuiDisplayMainFunction().
   ** tuiDisplayMainFunction().
   **        Function to display the "main" routine"
   **        Function to display the "main" routine"
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiDisplayMainFunction (void)
tuiDisplayMainFunction (void)
#else
#else
tuiDisplayMainFunction ()
tuiDisplayMainFunction ()
#endif
#endif
{
{
  if ((sourceWindows ())->count > 0)
  if ((sourceWindows ())->count > 0)
    {
    {
      CORE_ADDR addr;
      CORE_ADDR addr;
 
 
      addr = parse_and_eval_address ("main");
      addr = parse_and_eval_address ("main");
      if (addr <= (CORE_ADDR) 0)
      if (addr <= (CORE_ADDR) 0)
        addr = parse_and_eval_address ("MAIN");
        addr = parse_and_eval_address ("MAIN");
      if (addr > (CORE_ADDR) 0)
      if (addr > (CORE_ADDR) 0)
        {
        {
          struct symtab_and_line sal;
          struct symtab_and_line sal;
 
 
          tuiUpdateSourceWindowsWithAddr ((Opaque) addr);
          tuiUpdateSourceWindowsWithAddr ((Opaque) addr);
          sal = find_pc_line (addr, 0);
          sal = find_pc_line (addr, 0);
          tuiSwitchFilename (sal.symtab->filename);
          tuiSwitchFilename (sal.symtab->filename);
        }
        }
    }
    }
 
 
  return;
  return;
}                               /* tuiDisplayMainFunction */
}                               /* tuiDisplayMainFunction */
 
 
 
 
 
 
/*
/*
   ** tuiUpdateSourceWindow().
   ** tuiUpdateSourceWindow().
   **    Function to display source in the source window.  This function
   **    Function to display source in the source window.  This function
   **    initializes the horizontal scroll to 0.
   **    initializes the horizontal scroll to 0.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateSourceWindow (
tuiUpdateSourceWindow (
                        TuiWinInfoPtr winInfo,
                        TuiWinInfoPtr winInfo,
                        struct symtab *s,
                        struct symtab *s,
                        Opaque lineOrAddr,
                        Opaque lineOrAddr,
                        int noerror)
                        int noerror)
#else
#else
tuiUpdateSourceWindow (winInfo, s, lineOrAddr, noerror)
tuiUpdateSourceWindow (winInfo, s, lineOrAddr, noerror)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     struct symtab *s;
     struct symtab *s;
     Opaque lineOrAddr;
     Opaque lineOrAddr;
     int noerror;
     int noerror;
#endif
#endif
{
{
  winInfo->detail.sourceInfo.horizontalOffset = 0;
  winInfo->detail.sourceInfo.horizontalOffset = 0;
  tuiUpdateSourceWindowAsIs (winInfo, s, lineOrAddr, noerror);
  tuiUpdateSourceWindowAsIs (winInfo, s, lineOrAddr, noerror);
 
 
  return;
  return;
}                               /* tuiUpdateSourceWindow */
}                               /* tuiUpdateSourceWindow */
 
 
 
 
/*
/*
   ** tuiUpdateSourceWindowAsIs().
   ** tuiUpdateSourceWindowAsIs().
   **        Function to display source in the source/asm window.  This
   **        Function to display source in the source/asm window.  This
   **        function shows the source as specified by the horizontal offset.
   **        function shows the source as specified by the horizontal offset.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateSourceWindowAsIs (
tuiUpdateSourceWindowAsIs (
                            TuiWinInfoPtr winInfo,
                            TuiWinInfoPtr winInfo,
                            struct symtab *s,
                            struct symtab *s,
                            Opaque lineOrAddr,
                            Opaque lineOrAddr,
                            int noerror)
                            int noerror)
#else
#else
tuiUpdateSourceWindowAsIs (winInfo, s, lineOrAddr, noerror)
tuiUpdateSourceWindowAsIs (winInfo, s, lineOrAddr, noerror)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     struct symtab *s;
     struct symtab *s;
     Opaque lineOrAddr;
     Opaque lineOrAddr;
     int noerror;
     int noerror;
#endif
#endif
{
{
  TuiStatus ret;
  TuiStatus ret;
 
 
  if (winInfo->generic.type == SRC_WIN)
  if (winInfo->generic.type == SRC_WIN)
    ret = tuiSetSourceContent (s, (int) lineOrAddr, noerror);
    ret = tuiSetSourceContent (s, (int) lineOrAddr, noerror);
  else
  else
    ret = tuiSetDisassemContent (s, (Opaque) lineOrAddr);
    ret = tuiSetDisassemContent (s, (Opaque) lineOrAddr);
 
 
  if (ret == TUI_FAILURE)
  if (ret == TUI_FAILURE)
    {
    {
      tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT);
      tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT);
      tuiClearExecInfoContent (winInfo);
      tuiClearExecInfoContent (winInfo);
    }
    }
  else
  else
    {
    {
      tuiEraseSourceContent (winInfo, NO_EMPTY_SOURCE_PROMPT);
      tuiEraseSourceContent (winInfo, NO_EMPTY_SOURCE_PROMPT);
      tuiShowSourceContent (winInfo);
      tuiShowSourceContent (winInfo);
      tuiUpdateExecInfo (winInfo);
      tuiUpdateExecInfo (winInfo);
      if (winInfo->generic.type == SRC_WIN)
      if (winInfo->generic.type == SRC_WIN)
        {
        {
          current_source_line = (int) lineOrAddr +
          current_source_line = (int) lineOrAddr +
            (winInfo->generic.contentSize - 2);
            (winInfo->generic.contentSize - 2);
          current_source_symtab = s;
          current_source_symtab = s;
          /*
          /*
             ** If the focus was in the asm win, put it in the src
             ** If the focus was in the asm win, put it in the src
             ** win if we don't have a split layout
             ** win if we don't have a split layout
           */
           */
          if (tuiWinWithFocus () == disassemWin &&
          if (tuiWinWithFocus () == disassemWin &&
              currentLayout () != SRC_DISASSEM_COMMAND)
              currentLayout () != SRC_DISASSEM_COMMAND)
            tuiSetWinFocusTo (srcWin);
            tuiSetWinFocusTo (srcWin);
        }
        }
    }
    }
 
 
 
 
  return;
  return;
}                               /* tuiUpdateSourceWindowAsIs */
}                               /* tuiUpdateSourceWindowAsIs */
 
 
 
 
/*
/*
   ** tuiUpdateSourceWindowsWithAddr().
   ** tuiUpdateSourceWindowsWithAddr().
   **        Function to ensure that the source and/or disassemly windows
   **        Function to ensure that the source and/or disassemly windows
   **        reflect the input address.
   **        reflect the input address.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateSourceWindowsWithAddr (
tuiUpdateSourceWindowsWithAddr (
                                 Opaque addr)
                                 Opaque addr)
#else
#else
tuiUpdateSourceWindowsWithAddr (addr)
tuiUpdateSourceWindowsWithAddr (addr)
     Opaque addr;
     Opaque addr;
#endif
#endif
{
{
  if (addr > (Opaque) NULL)
  if (addr > (Opaque) NULL)
    {
    {
      struct symtab_and_line sal;
      struct symtab_and_line sal;
 
 
      switch (currentLayout ())
      switch (currentLayout ())
        {
        {
        case DISASSEM_COMMAND:
        case DISASSEM_COMMAND:
        case DISASSEM_DATA_COMMAND:
        case DISASSEM_DATA_COMMAND:
          tuiShowDisassem (addr);
          tuiShowDisassem (addr);
          break;
          break;
        case SRC_DISASSEM_COMMAND:
        case SRC_DISASSEM_COMMAND:
          tuiShowDisassemAndUpdateSource (addr);
          tuiShowDisassemAndUpdateSource (addr);
          break;
          break;
        default:
        default:
          sal = find_pc_line ((CORE_ADDR) addr, 0);
          sal = find_pc_line ((CORE_ADDR) addr, 0);
          tuiShowSource (sal.symtab,
          tuiShowSource (sal.symtab,
                         (Opaque) sal.line,
                         (Opaque) sal.line,
                         FALSE);
                         FALSE);
          break;
          break;
        }
        }
    }
    }
  else
  else
    {
    {
      int i;
      int i;
 
 
      for (i = 0; i < (sourceWindows ())->count; i++)
      for (i = 0; i < (sourceWindows ())->count; i++)
        {
        {
          TuiWinInfoPtr winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
          TuiWinInfoPtr winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
 
 
          tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT);
          tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT);
          tuiClearExecInfoContent (winInfo);
          tuiClearExecInfoContent (winInfo);
        }
        }
    }
    }
 
 
  return;
  return;
}                               /* tuiUpdateSourceWindowsWithAddr */
}                               /* tuiUpdateSourceWindowsWithAddr */
 
 
 
 
/*
/*
   ** tui_vUpdateSourceWindowsWithAddr()
   ** tui_vUpdateSourceWindowsWithAddr()
   **        Update the source window with the address in a va_list
   **        Update the source window with the address in a va_list
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tui_vUpdateSourceWindowsWithAddr (
tui_vUpdateSourceWindowsWithAddr (
                                   va_list args)
                                   va_list args)
#else
#else
tui_vUpdateSourceWindowsWithAddr (args)
tui_vUpdateSourceWindowsWithAddr (args)
     va_list args;
     va_list args;
#endif
#endif
{
{
  Opaque addr = va_arg (args, Opaque);
  Opaque addr = va_arg (args, Opaque);
 
 
  tuiUpdateSourceWindowsWithAddr (addr);
  tuiUpdateSourceWindowsWithAddr (addr);
 
 
  return;
  return;
}                               /* tui_vUpdateSourceWindowsWithAddr */
}                               /* tui_vUpdateSourceWindowsWithAddr */
 
 
 
 
/*
/*
   ** tuiUpdateSourceWindowsWithLine().
   ** tuiUpdateSourceWindowsWithLine().
   **        Function to ensure that the source and/or disassemly windows
   **        Function to ensure that the source and/or disassemly windows
   **        reflect the input address.
   **        reflect the input address.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateSourceWindowsWithLine (
tuiUpdateSourceWindowsWithLine (
                                 struct symtab *s,
                                 struct symtab *s,
                                 int line)
                                 int line)
#else
#else
tuiUpdateSourceWindowsWithLine (s, line)
tuiUpdateSourceWindowsWithLine (s, line)
     struct symtab *s;
     struct symtab *s;
     int line;
     int line;
#endif
#endif
{
{
  switch (currentLayout ())
  switch (currentLayout ())
    {
    {
    case DISASSEM_COMMAND:
    case DISASSEM_COMMAND:
    case DISASSEM_DATA_COMMAND:
    case DISASSEM_DATA_COMMAND:
      tuiUpdateSourceWindowsWithAddr ((Opaque) find_line_pc (s, line));
      tuiUpdateSourceWindowsWithAddr ((Opaque) find_line_pc (s, line));
      break;
      break;
    default:
    default:
      tuiShowSource (s, (Opaque) line, FALSE);
      tuiShowSource (s, (Opaque) line, FALSE);
      if (currentLayout () == SRC_DISASSEM_COMMAND)
      if (currentLayout () == SRC_DISASSEM_COMMAND)
        tuiShowDisassem ((Opaque) find_line_pc (s, line));
        tuiShowDisassem ((Opaque) find_line_pc (s, line));
      break;
      break;
    }
    }
 
 
  return;
  return;
}                               /* tuiUpdateSourceWindowsWithLine */
}                               /* tuiUpdateSourceWindowsWithLine */
 
 
 
 
/*
/*
   ** tui_vUpdateSourceWindowsWithLine()
   ** tui_vUpdateSourceWindowsWithLine()
   **        Update the source window with the line number in a va_list
   **        Update the source window with the line number in a va_list
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tui_vUpdateSourceWindowsWithLine (
tui_vUpdateSourceWindowsWithLine (
                                   va_list args)
                                   va_list args)
#else
#else
tui_vUpdateSourceWindowsWithLine (args)
tui_vUpdateSourceWindowsWithLine (args)
     va_list args;
     va_list args;
#endif
#endif
{
{
  struct symtab *s = va_arg (args, struct symtab *);
  struct symtab *s = va_arg (args, struct symtab *);
  int line = va_arg (args, int);
  int line = va_arg (args, int);
 
 
  tuiUpdateSourceWindowsWithLine (s, line);
  tuiUpdateSourceWindowsWithLine (s, line);
 
 
  return;
  return;
}                               /* tui_vUpdateSourceWindowsWithLine */
}                               /* tui_vUpdateSourceWindowsWithLine */
 
 
 
 
/*
/*
   ** tuiClearSourceContent().
   ** tuiClearSourceContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiClearSourceContent (
tuiClearSourceContent (
                        TuiWinInfoPtr winInfo,
                        TuiWinInfoPtr winInfo,
                        int displayPrompt)
                        int displayPrompt)
#else
#else
tuiClearSourceContent (winInfo, displayPrompt)
tuiClearSourceContent (winInfo, displayPrompt)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     int displayPrompt;
     int displayPrompt;
#endif
#endif
{
{
  if (m_winPtrNotNull (winInfo))
  if (m_winPtrNotNull (winInfo))
    {
    {
      register int i;
      register int i;
 
 
      winInfo->generic.contentInUse = FALSE;
      winInfo->generic.contentInUse = FALSE;
      tuiEraseSourceContent (winInfo, displayPrompt);
      tuiEraseSourceContent (winInfo, displayPrompt);
      for (i = 0; i < winInfo->generic.contentSize; i++)
      for (i = 0; i < winInfo->generic.contentSize; i++)
        {
        {
          TuiWinElementPtr element =
          TuiWinElementPtr element =
          (TuiWinElementPtr) winInfo->generic.content[i];
          (TuiWinElementPtr) winInfo->generic.content[i];
          element->whichElement.source.hasBreak = FALSE;
          element->whichElement.source.hasBreak = FALSE;
          element->whichElement.source.isExecPoint = FALSE;
          element->whichElement.source.isExecPoint = FALSE;
        }
        }
    }
    }
 
 
  return;
  return;
}                               /* tuiClearSourceContent */
}                               /* tuiClearSourceContent */
 
 
 
 
/*
/*
   ** tuiClearAllSourceWinsContent().
   ** tuiClearAllSourceWinsContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiClearAllSourceWinsContent (
tuiClearAllSourceWinsContent (
                               int displayPrompt)
                               int displayPrompt)
#else
#else
tuiClearAllSourceWinsContent (displayPrompt)
tuiClearAllSourceWinsContent (displayPrompt)
     int displayPrompt;
     int displayPrompt;
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiClearSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i],
    tuiClearSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i],
                           displayPrompt);
                           displayPrompt);
 
 
  return;
  return;
}                               /* tuiClearAllSourceWinsContent */
}                               /* tuiClearAllSourceWinsContent */
 
 
 
 
/*
/*
   ** tuiEraseSourceContent().
   ** tuiEraseSourceContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiEraseSourceContent (
tuiEraseSourceContent (
                        TuiWinInfoPtr winInfo,
                        TuiWinInfoPtr winInfo,
                        int displayPrompt)
                        int displayPrompt)
#else
#else
tuiEraseSourceContent (winInfo, displayPrompt)
tuiEraseSourceContent (winInfo, displayPrompt)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     int displayPrompt;
     int displayPrompt;
#endif
#endif
{
{
  int xPos;
  int xPos;
  int halfWidth = (winInfo->generic.width - 2) / 2;
  int halfWidth = (winInfo->generic.width - 2) / 2;
 
 
  if (winInfo->generic.handle != (WINDOW *) NULL)
  if (winInfo->generic.handle != (WINDOW *) NULL)
    {
    {
      werase (winInfo->generic.handle);
      werase (winInfo->generic.handle);
      checkAndDisplayHighlightIfNeeded (winInfo);
      checkAndDisplayHighlightIfNeeded (winInfo);
      if (displayPrompt == EMPTY_SOURCE_PROMPT)
      if (displayPrompt == EMPTY_SOURCE_PROMPT)
        {
        {
          char *noSrcStr;
          char *noSrcStr;
 
 
          if (winInfo->generic.type == SRC_WIN)
          if (winInfo->generic.type == SRC_WIN)
            noSrcStr = NO_SRC_STRING;
            noSrcStr = NO_SRC_STRING;
          else
          else
            noSrcStr = NO_DISASSEM_STRING;
            noSrcStr = NO_DISASSEM_STRING;
          if (strlen (noSrcStr) >= halfWidth)
          if (strlen (noSrcStr) >= halfWidth)
            xPos = 1;
            xPos = 1;
          else
          else
            xPos = halfWidth - strlen (noSrcStr);
            xPos = halfWidth - strlen (noSrcStr);
          mvwaddstr (winInfo->generic.handle,
          mvwaddstr (winInfo->generic.handle,
                     (winInfo->generic.height / 2),
                     (winInfo->generic.height / 2),
                     xPos,
                     xPos,
                     noSrcStr);
                     noSrcStr);
 
 
          /* elz: added this function call to set the real contents of
          /* elz: added this function call to set the real contents of
             the window to what is on the  screen, so that later calls
             the window to what is on the  screen, so that later calls
             to refresh, do display
             to refresh, do display
             the correct stuff, and not the old image */
             the correct stuff, and not the old image */
 
 
          tuiSetSourceContentNil (winInfo, noSrcStr);
          tuiSetSourceContentNil (winInfo, noSrcStr);
        }
        }
      tuiRefreshWin (&winInfo->generic);
      tuiRefreshWin (&winInfo->generic);
    }
    }
  return;
  return;
}                               /* tuiEraseSourceContent */
}                               /* tuiEraseSourceContent */
 
 
 
 
/*
/*
   ** tuiEraseAllSourceContent().
   ** tuiEraseAllSourceContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiEraseAllSourceWinsContent (
tuiEraseAllSourceWinsContent (
                               int displayPrompt)
                               int displayPrompt)
#else
#else
tuiEraseAllSourceWinsContent (displayPrompt)
tuiEraseAllSourceWinsContent (displayPrompt)
     int displayPrompt;
     int displayPrompt;
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiEraseSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i],
    tuiEraseSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i],
                           displayPrompt);
                           displayPrompt);
 
 
  return;
  return;
}                               /* tuiEraseAllSourceWinsContent */
}                               /* tuiEraseAllSourceWinsContent */
 
 
 
 
/*
/*
   ** tuiShowSourceContent().
   ** tuiShowSourceContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiShowSourceContent (
tuiShowSourceContent (
                       TuiWinInfoPtr winInfo)
                       TuiWinInfoPtr winInfo)
#else
#else
tuiShowSourceContent (winInfo)
tuiShowSourceContent (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  int curLine, i, curX;
  int curLine, i, curX;
 
 
  tuiEraseSourceContent (winInfo, (winInfo->generic.contentSize <= 0));
  tuiEraseSourceContent (winInfo, (winInfo->generic.contentSize <= 0));
  if (winInfo->generic.contentSize > 0)
  if (winInfo->generic.contentSize > 0)
    {
    {
      char *line;
      char *line;
 
 
      for (curLine = 1; (curLine <= winInfo->generic.contentSize); curLine++)
      for (curLine = 1; (curLine <= winInfo->generic.contentSize); curLine++)
        mvwaddstr (
        mvwaddstr (
                    winInfo->generic.handle,
                    winInfo->generic.handle,
                    curLine,
                    curLine,
                    1,
                    1,
                    ((TuiWinElementPtr)
                    ((TuiWinElementPtr)
          winInfo->generic.content[curLine - 1])->whichElement.source.line);
          winInfo->generic.content[curLine - 1])->whichElement.source.line);
    }
    }
  checkAndDisplayHighlightIfNeeded (winInfo);
  checkAndDisplayHighlightIfNeeded (winInfo);
  tuiRefreshWin (&winInfo->generic);
  tuiRefreshWin (&winInfo->generic);
  winInfo->generic.contentInUse = TRUE;
  winInfo->generic.contentInUse = TRUE;
 
 
  return;
  return;
}                               /* tuiShowSourceContent */
}                               /* tuiShowSourceContent */
 
 
 
 
/*
/*
   ** tuiShowAllSourceWinsContent()
   ** tuiShowAllSourceWinsContent()
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiShowAllSourceWinsContent (void)
tuiShowAllSourceWinsContent (void)
#else
#else
tuiShowAllSourceWinsContent ()
tuiShowAllSourceWinsContent ()
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiShowSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
    tuiShowSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
 
 
  return;
  return;
}                               /* tuiShowAllSourceWinsContent */
}                               /* tuiShowAllSourceWinsContent */
 
 
 
 
/*
/*
   ** tuiHorizontalSourceScroll().
   ** tuiHorizontalSourceScroll().
   **      Scroll the source forward or backward horizontally
   **      Scroll the source forward or backward horizontally
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiHorizontalSourceScroll (
tuiHorizontalSourceScroll (
                            TuiWinInfoPtr winInfo,
                            TuiWinInfoPtr winInfo,
                            TuiScrollDirection direction,
                            TuiScrollDirection direction,
                            int numToScroll)
                            int numToScroll)
#else
#else
tuiHorizontalSourceScroll (winInfo, direction, numToScroll)
tuiHorizontalSourceScroll (winInfo, direction, numToScroll)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     TuiScrollDirection direction;
     TuiScrollDirection direction;
     int numToScroll;
     int numToScroll;
#endif
#endif
{
{
  if (winInfo->generic.content != (OpaquePtr) NULL)
  if (winInfo->generic.content != (OpaquePtr) NULL)
    {
    {
      int offset;
      int offset;
      struct symtab *s;
      struct symtab *s;
 
 
      if (current_source_symtab == (struct symtab *) NULL)
      if (current_source_symtab == (struct symtab *) NULL)
        s = find_pc_symtab (selected_frame->pc);
        s = find_pc_symtab (selected_frame->pc);
      else
      else
        s = current_source_symtab;
        s = current_source_symtab;
 
 
      if (direction == LEFT_SCROLL)
      if (direction == LEFT_SCROLL)
        offset = winInfo->detail.sourceInfo.horizontalOffset + numToScroll;
        offset = winInfo->detail.sourceInfo.horizontalOffset + numToScroll;
      else
      else
        {
        {
          if ((offset =
          if ((offset =
             winInfo->detail.sourceInfo.horizontalOffset - numToScroll) < 0)
             winInfo->detail.sourceInfo.horizontalOffset - numToScroll) < 0)
            offset = 0;
            offset = 0;
        }
        }
      winInfo->detail.sourceInfo.horizontalOffset = offset;
      winInfo->detail.sourceInfo.horizontalOffset = offset;
      tuiUpdateSourceWindowAsIs (
      tuiUpdateSourceWindowAsIs (
                                  winInfo,
                                  winInfo,
                                  s,
                                  s,
                                  ((winInfo == srcWin) ?
                                  ((winInfo == srcWin) ?
                                   (Opaque) ((TuiWinElementPtr)
                                   (Opaque) ((TuiWinElementPtr)
       winInfo->generic.content[0])->whichElement.source.lineOrAddr.lineNo :
       winInfo->generic.content[0])->whichElement.source.lineOrAddr.lineNo :
                                   (Opaque) ((TuiWinElementPtr)
                                   (Opaque) ((TuiWinElementPtr)
         winInfo->generic.content[0])->whichElement.source.lineOrAddr.addr),
         winInfo->generic.content[0])->whichElement.source.lineOrAddr.addr),
                                  (int) FALSE);
                                  (int) FALSE);
    }
    }
 
 
  return;
  return;
}                               /* tuiHorizontalSourceScroll */
}                               /* tuiHorizontalSourceScroll */
 
 
 
 
/*
/*
   ** tuiSetHasExecPointAt().
   ** tuiSetHasExecPointAt().
   **        Set or clear the hasBreak flag in the line whose line is lineNo.
   **        Set or clear the hasBreak flag in the line whose line is lineNo.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiSetIsExecPointAt (
tuiSetIsExecPointAt (
                      Opaque lineOrAddr,
                      Opaque lineOrAddr,
                      TuiWinInfoPtr winInfo)
                      TuiWinInfoPtr winInfo)
#else
#else
tuiSetIsExecPointAt (lineOrAddr, winInfo)
tuiSetIsExecPointAt (lineOrAddr, winInfo)
     Opaque lineOrAddr;
     Opaque lineOrAddr;
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  int i;
  int i;
  TuiWinContent content = (TuiWinContent) winInfo->generic.content;
  TuiWinContent content = (TuiWinContent) winInfo->generic.content;
 
 
  i = 0;
  i = 0;
  while (i < winInfo->generic.contentSize)
  while (i < winInfo->generic.contentSize)
    {
    {
      if (content[i]->whichElement.source.lineOrAddr.addr == lineOrAddr)
      if (content[i]->whichElement.source.lineOrAddr.addr == lineOrAddr)
        content[i]->whichElement.source.isExecPoint = TRUE;
        content[i]->whichElement.source.isExecPoint = TRUE;
      else
      else
        content[i]->whichElement.source.isExecPoint = FALSE;
        content[i]->whichElement.source.isExecPoint = FALSE;
      i++;
      i++;
    }
    }
 
 
  return;
  return;
}                               /* tuiSetIsExecPointAt */
}                               /* tuiSetIsExecPointAt */
 
 
 
 
/*
/*
   ** tuiSetHasBreakAt().
   ** tuiSetHasBreakAt().
   **        Set or clear the hasBreak flag in the line whose line is lineNo.
   **        Set or clear the hasBreak flag in the line whose line is lineNo.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiSetHasBreakAt (
tuiSetHasBreakAt (
                   struct breakpoint *bp,
                   struct breakpoint *bp,
                   TuiWinInfoPtr winInfo,
                   TuiWinInfoPtr winInfo,
                   int hasBreak)
                   int hasBreak)
#else
#else
tuiSetHasBreakAt (bp, winInfo, hasBreak)
tuiSetHasBreakAt (bp, winInfo, hasBreak)
     struct breakpoint *bp;
     struct breakpoint *bp;
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     int hasBreak;
     int hasBreak;
#endif
#endif
{
{
  int i;
  int i;
  TuiWinContent content = (TuiWinContent) winInfo->generic.content;
  TuiWinContent content = (TuiWinContent) winInfo->generic.content;
 
 
  i = 0;
  i = 0;
  while (i < winInfo->generic.contentSize)
  while (i < winInfo->generic.contentSize)
    {
    {
      int gotIt;
      int gotIt;
      TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
      TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
 
 
      if (winInfo == srcWin)
      if (winInfo == srcWin)
        {
        {
          char *fileNameDisplayed = (char *) NULL;
          char *fileNameDisplayed = (char *) NULL;
 
 
          if (((TuiWinElementPtr)
          if (((TuiWinElementPtr)
               locator->content[0])->whichElement.locator.fileName !=
               locator->content[0])->whichElement.locator.fileName !=
              (char *) NULL)
              (char *) NULL)
            fileNameDisplayed = ((TuiWinElementPtr)
            fileNameDisplayed = ((TuiWinElementPtr)
                        locator->content[0])->whichElement.locator.fileName;
                        locator->content[0])->whichElement.locator.fileName;
          else if (current_source_symtab != (struct symtab *) NULL)
          else if (current_source_symtab != (struct symtab *) NULL)
            fileNameDisplayed = current_source_symtab->filename;
            fileNameDisplayed = current_source_symtab->filename;
 
 
          gotIt = (fileNameDisplayed != (char *) NULL &&
          gotIt = (fileNameDisplayed != (char *) NULL &&
                   (strcmp (bp->source_file, fileNameDisplayed) == 0) &&
                   (strcmp (bp->source_file, fileNameDisplayed) == 0) &&
                   content[i]->whichElement.source.lineOrAddr.lineNo ==
                   content[i]->whichElement.source.lineOrAddr.lineNo ==
                   bp->line_number);
                   bp->line_number);
        }
        }
      else
      else
        gotIt = (content[i]->whichElement.source.lineOrAddr.addr
        gotIt = (content[i]->whichElement.source.lineOrAddr.addr
                 == (Opaque) bp->address);
                 == (Opaque) bp->address);
      if (gotIt)
      if (gotIt)
        {
        {
          content[i]->whichElement.source.hasBreak = hasBreak;
          content[i]->whichElement.source.hasBreak = hasBreak;
          break;
          break;
        }
        }
      i++;
      i++;
    }
    }
 
 
  return;
  return;
}                               /* tuiSetHasBreakAt */
}                               /* tuiSetHasBreakAt */
 
 
 
 
/*
/*
   ** tuiAllSetHasBreakAt().
   ** tuiAllSetHasBreakAt().
   **        Set or clear the hasBreak flag in all displayed source windows.
   **        Set or clear the hasBreak flag in all displayed source windows.
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiAllSetHasBreakAt (
tuiAllSetHasBreakAt (
                      struct breakpoint *bp,
                      struct breakpoint *bp,
                      int hasBreak)
                      int hasBreak)
#else
#else
tuiAllSetHasBreakAt (bp, hasBreak)
tuiAllSetHasBreakAt (bp, hasBreak)
     struct breakpoint *bp;
     struct breakpoint *bp;
     int hasBreak;
     int hasBreak;
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiSetHasBreakAt (bp,
    tuiSetHasBreakAt (bp,
                      (TuiWinInfoPtr) (sourceWindows ())->list[i], hasBreak);
                      (TuiWinInfoPtr) (sourceWindows ())->list[i], hasBreak);
 
 
  return;
  return;
}                               /* tuiAllSetHasBreakAt */
}                               /* tuiAllSetHasBreakAt */
 
 
 
 
/*
/*
   ** tui_vAllSetHasBreakAt()
   ** tui_vAllSetHasBreakAt()
   **        Set or clear the hasBreak flag in all displayed source windows,
   **        Set or clear the hasBreak flag in all displayed source windows,
   **        with params in a va_list
   **        with params in a va_list
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tui_vAllSetHasBreakAt (
tui_vAllSetHasBreakAt (
                        va_list args)
                        va_list args)
#else
#else
tui_vAllSetHasBreakAt (args)
tui_vAllSetHasBreakAt (args)
     va_list args;
     va_list args;
#endif
#endif
{
{
  struct breakpoint *bp = va_arg (args, struct breakpoint *);
  struct breakpoint *bp = va_arg (args, struct breakpoint *);
  int hasBreak = va_arg (args, int);
  int hasBreak = va_arg (args, int);
 
 
  tuiAllSetHasBreakAt (bp, hasBreak);
  tuiAllSetHasBreakAt (bp, hasBreak);
 
 
  return;
  return;
}                               /* tui_vAllSetHasBreakAt */
}                               /* tui_vAllSetHasBreakAt */
 
 
 
 
 
 
/*********************************
/*********************************
** EXECUTION INFO FUNCTIONS        **
** EXECUTION INFO FUNCTIONS        **
*********************************/
*********************************/
 
 
/*
/*
   ** tuiSetExecInfoContent().
   ** tuiSetExecInfoContent().
   **      Function to initialize the content of the execution info window,
   **      Function to initialize the content of the execution info window,
   **      based upon the input window which is either the source or
   **      based upon the input window which is either the source or
   **      disassembly window.
   **      disassembly window.
 */
 */
TuiStatus
TuiStatus
#ifdef __STDC__
#ifdef __STDC__
tuiSetExecInfoContent (
tuiSetExecInfoContent (
                        TuiWinInfoPtr winInfo)
                        TuiWinInfoPtr winInfo)
#else
#else
tuiSetExecInfoContent (winInfo)
tuiSetExecInfoContent (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  TuiStatus ret = TUI_SUCCESS;
  TuiStatus ret = TUI_SUCCESS;
 
 
  if (winInfo->detail.sourceInfo.executionInfo != (TuiGenWinInfoPtr) NULL)
  if (winInfo->detail.sourceInfo.executionInfo != (TuiGenWinInfoPtr) NULL)
    {
    {
      TuiGenWinInfoPtr execInfoPtr = winInfo->detail.sourceInfo.executionInfo;
      TuiGenWinInfoPtr execInfoPtr = winInfo->detail.sourceInfo.executionInfo;
 
 
      if (execInfoPtr->content == (OpaquePtr) NULL)
      if (execInfoPtr->content == (OpaquePtr) NULL)
        execInfoPtr->content =
        execInfoPtr->content =
          (OpaquePtr) allocContent (winInfo->generic.height,
          (OpaquePtr) allocContent (winInfo->generic.height,
                                    execInfoPtr->type);
                                    execInfoPtr->type);
      if (execInfoPtr->content != (OpaquePtr) NULL)
      if (execInfoPtr->content != (OpaquePtr) NULL)
        {
        {
          int i;
          int i;
 
 
          for (i = 0; i < winInfo->generic.contentSize; i++)
          for (i = 0; i < winInfo->generic.contentSize; i++)
            {
            {
              TuiWinElementPtr element;
              TuiWinElementPtr element;
              TuiWinElementPtr srcElement;
              TuiWinElementPtr srcElement;
 
 
              element = (TuiWinElementPtr) execInfoPtr->content[i];
              element = (TuiWinElementPtr) execInfoPtr->content[i];
              srcElement = (TuiWinElementPtr) winInfo->generic.content[i];
              srcElement = (TuiWinElementPtr) winInfo->generic.content[i];
              /*
              /*
                 ** First check to see if we have a breakpoint that is
                 ** First check to see if we have a breakpoint that is
                 ** temporary.  If so, and this is our current execution point,
                 ** temporary.  If so, and this is our current execution point,
                 ** then clear the break indicator.
                 ** then clear the break indicator.
               */
               */
              if (srcElement->whichElement.source.hasBreak &&
              if (srcElement->whichElement.source.hasBreak &&
                  srcElement->whichElement.source.isExecPoint)
                  srcElement->whichElement.source.isExecPoint)
                {
                {
                  struct breakpoint *bp;
                  struct breakpoint *bp;
                  int found = FALSE;
                  int found = FALSE;
                  extern struct breakpoint *breakpoint_chain;
                  extern struct breakpoint *breakpoint_chain;
 
 
                  for (bp = breakpoint_chain;
                  for (bp = breakpoint_chain;
                       (bp != (struct breakpoint *) NULL && !found);
                       (bp != (struct breakpoint *) NULL && !found);
                       bp = bp->next)
                       bp = bp->next)
                    {
                    {
                      found =
                      found =
                        (winInfo == srcWin &&
                        (winInfo == srcWin &&
                         bp->line_number ==
                         bp->line_number ==
                       srcElement->whichElement.source.lineOrAddr.lineNo) ||
                       srcElement->whichElement.source.lineOrAddr.lineNo) ||
                        (winInfo == disassemWin &&
                        (winInfo == disassemWin &&
                         bp->address == (CORE_ADDR)
                         bp->address == (CORE_ADDR)
                         srcElement->whichElement.source.lineOrAddr.addr);
                         srcElement->whichElement.source.lineOrAddr.addr);
                      if (found)
                      if (found)
                        srcElement->whichElement.source.hasBreak =
                        srcElement->whichElement.source.hasBreak =
                          (bp->disposition != del || bp->hit_count <= 0);
                          (bp->disposition != del || bp->hit_count <= 0);
                    }
                    }
                  if (!found)
                  if (!found)
                    srcElement->whichElement.source.hasBreak = FALSE;
                    srcElement->whichElement.source.hasBreak = FALSE;
                }
                }
              /*
              /*
                 ** Now update the exec info content based upon the state
                 ** Now update the exec info content based upon the state
                 ** of each line as indicated by the source content.
                 ** of each line as indicated by the source content.
               */
               */
              if (srcElement->whichElement.source.hasBreak &&
              if (srcElement->whichElement.source.hasBreak &&
                  srcElement->whichElement.source.isExecPoint)
                  srcElement->whichElement.source.isExecPoint)
                element->whichElement.simpleString = breakLocationStr ();
                element->whichElement.simpleString = breakLocationStr ();
              else if (srcElement->whichElement.source.hasBreak)
              else if (srcElement->whichElement.source.hasBreak)
                element->whichElement.simpleString = breakStr ();
                element->whichElement.simpleString = breakStr ();
              else if (srcElement->whichElement.source.isExecPoint)
              else if (srcElement->whichElement.source.isExecPoint)
                element->whichElement.simpleString = locationStr ();
                element->whichElement.simpleString = locationStr ();
              else
              else
                element->whichElement.simpleString = blankStr ();
                element->whichElement.simpleString = blankStr ();
            }
            }
          execInfoPtr->contentSize = winInfo->generic.contentSize;
          execInfoPtr->contentSize = winInfo->generic.contentSize;
        }
        }
      else
      else
        ret = TUI_FAILURE;
        ret = TUI_FAILURE;
    }
    }
 
 
  return ret;
  return ret;
}                               /* tuiSetExecInfoContent */
}                               /* tuiSetExecInfoContent */
 
 
 
 
/*
/*
   ** tuiShowExecInfoContent().
   ** tuiShowExecInfoContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiShowExecInfoContent (
tuiShowExecInfoContent (
                         TuiWinInfoPtr winInfo)
                         TuiWinInfoPtr winInfo)
#else
#else
tuiShowExecInfoContent (winInfo)
tuiShowExecInfoContent (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo;
  TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo;
  int curLine;
  int curLine;
 
 
  werase (execInfo->handle);
  werase (execInfo->handle);
  tuiRefreshWin (execInfo);
  tuiRefreshWin (execInfo);
  for (curLine = 1; (curLine <= execInfo->contentSize); curLine++)
  for (curLine = 1; (curLine <= execInfo->contentSize); curLine++)
    mvwaddstr (execInfo->handle,
    mvwaddstr (execInfo->handle,
               curLine,
               curLine,
               0,
               0,
               ((TuiWinElementPtr)
               ((TuiWinElementPtr)
                execInfo->content[curLine - 1])->whichElement.simpleString);
                execInfo->content[curLine - 1])->whichElement.simpleString);
  tuiRefreshWin (execInfo);
  tuiRefreshWin (execInfo);
  execInfo->contentInUse = TRUE;
  execInfo->contentInUse = TRUE;
 
 
  return;
  return;
}                               /* tuiShowExecInfoContent */
}                               /* tuiShowExecInfoContent */
 
 
 
 
/*
/*
   ** tuiShowAllExecInfosContent()
   ** tuiShowAllExecInfosContent()
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiShowAllExecInfosContent (void)
tuiShowAllExecInfosContent (void)
#else
#else
tuiShowAllExecInfosContent ()
tuiShowAllExecInfosContent ()
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiShowExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
    tuiShowExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
 
 
  return;
  return;
}                               /* tuiShowAllExecInfosContent */
}                               /* tuiShowAllExecInfosContent */
 
 
 
 
/*
/*
   ** tuiEraseExecInfoContent().
   ** tuiEraseExecInfoContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiEraseExecInfoContent (
tuiEraseExecInfoContent (
                          TuiWinInfoPtr winInfo)
                          TuiWinInfoPtr winInfo)
#else
#else
tuiEraseExecInfoContent (winInfo)
tuiEraseExecInfoContent (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo;
  TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo;
 
 
  werase (execInfo->handle);
  werase (execInfo->handle);
  tuiRefreshWin (execInfo);
  tuiRefreshWin (execInfo);
 
 
  return;
  return;
}                               /* tuiEraseExecInfoContent */
}                               /* tuiEraseExecInfoContent */
 
 
 
 
/*
/*
   ** tuiEraseAllExecInfosContent()
   ** tuiEraseAllExecInfosContent()
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiEraseAllExecInfosContent (void)
tuiEraseAllExecInfosContent (void)
#else
#else
tuiEraseAllExecInfosContent ()
tuiEraseAllExecInfosContent ()
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiEraseExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
    tuiEraseExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
 
 
  return;
  return;
}                               /* tuiEraseAllExecInfosContent */
}                               /* tuiEraseAllExecInfosContent */
 
 
 
 
/*
/*
   ** tuiClearExecInfoContent().
   ** tuiClearExecInfoContent().
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiClearExecInfoContent (
tuiClearExecInfoContent (
                          TuiWinInfoPtr winInfo)
                          TuiWinInfoPtr winInfo)
#else
#else
tuiClearExecInfoContent (winInfo)
tuiClearExecInfoContent (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  winInfo->detail.sourceInfo.executionInfo->contentInUse = FALSE;
  winInfo->detail.sourceInfo.executionInfo->contentInUse = FALSE;
  tuiEraseExecInfoContent (winInfo);
  tuiEraseExecInfoContent (winInfo);
 
 
  return;
  return;
}                               /* tuiClearExecInfoContent */
}                               /* tuiClearExecInfoContent */
 
 
 
 
/*
/*
   ** tuiClearAllExecInfosContent()
   ** tuiClearAllExecInfosContent()
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiClearAllExecInfosContent (void)
tuiClearAllExecInfosContent (void)
#else
#else
tuiClearAllExecInfosContent ()
tuiClearAllExecInfosContent ()
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiClearExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
    tuiClearExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
 
 
  return;
  return;
}                               /* tuiClearAllExecInfosContent */
}                               /* tuiClearAllExecInfosContent */
 
 
 
 
/*
/*
   ** tuiUpdateExecInfo().
   ** tuiUpdateExecInfo().
   **        Function to update the execution info window
   **        Function to update the execution info window
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateExecInfo (
tuiUpdateExecInfo (
                    TuiWinInfoPtr winInfo)
                    TuiWinInfoPtr winInfo)
#else
#else
tuiUpdateExecInfo (winInfo)
tuiUpdateExecInfo (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  tuiSetExecInfoContent (winInfo);
  tuiSetExecInfoContent (winInfo);
  tuiShowExecInfoContent (winInfo);
  tuiShowExecInfoContent (winInfo);
}                               /* tuiUpdateExecInfo
}                               /* tuiUpdateExecInfo
 
 
 
 
                                   /*
                                   /*
                                   ** tuiUpdateAllExecInfos()
                                   ** tuiUpdateAllExecInfos()
                                 */
                                 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateAllExecInfos (void)
tuiUpdateAllExecInfos (void)
#else
#else
tuiUpdateAllExecInfos ()
tuiUpdateAllExecInfos ()
#endif
#endif
{
{
  int i;
  int i;
 
 
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    tuiUpdateExecInfo ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
    tuiUpdateExecInfo ((TuiWinInfoPtr) (sourceWindows ())->list[i]);
 
 
  return;
  return;
}                               /* tuiUpdateAllExecInfos */
}                               /* tuiUpdateAllExecInfos */
 
 
 
 
 
 
/* tuiUpdateOnEnd()
/* tuiUpdateOnEnd()
   **       elz: This function clears the execution info from the source windows
   **       elz: This function clears the execution info from the source windows
   **       and resets the locator to display no line info, procedure info, pc
   **       and resets the locator to display no line info, procedure info, pc
   **       info.  It is called by stack_publish_stopped_with_no_frame, which
   **       info.  It is called by stack_publish_stopped_with_no_frame, which
   **       is called then the target terminates execution
   **       is called then the target terminates execution
 */
 */
void
void
#ifdef __STDC__
#ifdef __STDC__
tuiUpdateOnEnd (void)
tuiUpdateOnEnd (void)
#else
#else
tuiUpdateOnEnd ()
tuiUpdateOnEnd ()
#endif
#endif
{
{
  int i;
  int i;
  TuiGenWinInfoPtr locator;
  TuiGenWinInfoPtr locator;
  char *filename;
  char *filename;
  TuiWinInfoPtr winInfo;
  TuiWinInfoPtr winInfo;
 
 
  locator = locatorWinInfoPtr ();
  locator = locatorWinInfoPtr ();
 
 
  /* for all the windows (src, asm) */
  /* for all the windows (src, asm) */
  for (i = 0; i < (sourceWindows ())->count; i++)
  for (i = 0; i < (sourceWindows ())->count; i++)
    {
    {
      winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
      winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
 
 
      tuiSetIsExecPointAt ((Opaque) - 1, winInfo);      /* the target is'n running */
      tuiSetIsExecPointAt ((Opaque) - 1, winInfo);      /* the target is'n running */
      /* -1 should not match any line number or pc */
      /* -1 should not match any line number or pc */
      tuiSetExecInfoContent (winInfo);  /*set winInfo so that > is'n displayed */
      tuiSetExecInfoContent (winInfo);  /*set winInfo so that > is'n displayed */
      tuiShowExecInfoContent (winInfo);         /* display the new contents */
      tuiShowExecInfoContent (winInfo);         /* display the new contents */
    }
    }
 
 
  /*now update the locator */
  /*now update the locator */
  tuiClearLocatorDisplay ();
  tuiClearLocatorDisplay ();
  tuiGetLocatorFilename (locator, &filename);
  tuiGetLocatorFilename (locator, &filename);
  tuiSetLocatorInfo (
  tuiSetLocatorInfo (
                      filename,
                      filename,
                      (char *) NULL,
                      (char *) NULL,
                      0,
                      0,
                      (Opaque) NULL,
                      (Opaque) NULL,
           &((TuiWinElementPtr) locator->content[0])->whichElement.locator);
           &((TuiWinElementPtr) locator->content[0])->whichElement.locator);
  tuiShowLocatorContent ();
  tuiShowLocatorContent ();
 
 
  return;
  return;
}                               /* tuiUpdateOnEnd */
}                               /* tuiUpdateOnEnd */
 
 
 
 
 
 
TuiStatus
TuiStatus
#ifdef __STDC__
#ifdef __STDC__
tuiAllocSourceBuffer (
tuiAllocSourceBuffer (
                       TuiWinInfoPtr winInfo)
                       TuiWinInfoPtr winInfo)
#else
#else
tuiAllocSourceBuffer (winInfo)
tuiAllocSourceBuffer (winInfo)
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
#endif
#endif
{
{
  register char *srcLine, *srcLineBuf;
  register char *srcLine, *srcLineBuf;
  register int i, lineWidth, c, maxLines;
  register int i, lineWidth, c, maxLines;
  TuiStatus ret = TUI_FAILURE;
  TuiStatus ret = TUI_FAILURE;
 
 
  maxLines = winInfo->generic.height;   /* less the highlight box */
  maxLines = winInfo->generic.height;   /* less the highlight box */
  lineWidth = winInfo->generic.width - 1;
  lineWidth = winInfo->generic.width - 1;
  /*
  /*
     ** Allocate the buffer for the source lines.  Do this only once since they
     ** Allocate the buffer for the source lines.  Do this only once since they
     ** will be re-used for all source displays.  The only other time this will
     ** will be re-used for all source displays.  The only other time this will
     ** be done is when a window's size changes.
     ** be done is when a window's size changes.
   */
   */
  if (winInfo->generic.content == (OpaquePtr) NULL)
  if (winInfo->generic.content == (OpaquePtr) NULL)
    {
    {
      srcLineBuf = (char *) xmalloc ((maxLines * lineWidth) * sizeof (char));
      srcLineBuf = (char *) xmalloc ((maxLines * lineWidth) * sizeof (char));
      if (srcLineBuf == (char *) NULL)
      if (srcLineBuf == (char *) NULL)
        fputs_unfiltered (
        fputs_unfiltered (
           "Unable to Allocate Memory for Source or Disassembly Display.\n",
           "Unable to Allocate Memory for Source or Disassembly Display.\n",
                           gdb_stderr);
                           gdb_stderr);
      else
      else
        {
        {
          /* allocate the content list */
          /* allocate the content list */
          if ((winInfo->generic.content =
          if ((winInfo->generic.content =
          (OpaquePtr) allocContent (maxLines, SRC_WIN)) == (OpaquePtr) NULL)
          (OpaquePtr) allocContent (maxLines, SRC_WIN)) == (OpaquePtr) NULL)
            {
            {
              tuiFree (srcLineBuf);
              tuiFree (srcLineBuf);
              srcLineBuf = (char *) NULL;
              srcLineBuf = (char *) NULL;
              fputs_unfiltered (
              fputs_unfiltered (
                                 "Unable to Allocate Memory for Source or Disassembly Display.\n",
                                 "Unable to Allocate Memory for Source or Disassembly Display.\n",
                                 gdb_stderr);
                                 gdb_stderr);
            }
            }
        }
        }
      for (i = 0; i < maxLines; i++)
      for (i = 0; i < maxLines; i++)
        ((TuiWinElementPtr)
        ((TuiWinElementPtr)
         winInfo->generic.content[i])->whichElement.source.line =
         winInfo->generic.content[i])->whichElement.source.line =
          srcLineBuf + (lineWidth * i);
          srcLineBuf + (lineWidth * i);
      ret = TUI_SUCCESS;
      ret = TUI_SUCCESS;
    }
    }
  else
  else
    ret = TUI_SUCCESS;
    ret = TUI_SUCCESS;
 
 
  return ret;
  return ret;
}                               /* tuiAllocSourceBuffer */
}                               /* tuiAllocSourceBuffer */
 
 
 
 
/*
/*
   ** tuiLineIsDisplayed().
   ** tuiLineIsDisplayed().
   **      Answer whether the a particular line number or address is displayed
   **      Answer whether the a particular line number or address is displayed
   **      in the current source window.
   **      in the current source window.
 */
 */
int
int
#ifdef __STDC__
#ifdef __STDC__
tuiLineIsDisplayed (
tuiLineIsDisplayed (
                     Opaque lineNoOrAddr,
                     Opaque lineNoOrAddr,
                     TuiWinInfoPtr winInfo,
                     TuiWinInfoPtr winInfo,
                     int checkThreshold)
                     int checkThreshold)
#else
#else
tuiLineIsDisplayed (lineNoOrAddr, winInfo, checkThreshold)
tuiLineIsDisplayed (lineNoOrAddr, winInfo, checkThreshold)
     Opaque lineNoOrAddr;
     Opaque lineNoOrAddr;
     TuiWinInfoPtr winInfo;
     TuiWinInfoPtr winInfo;
     int checkThreshold;
     int checkThreshold;
#endif
#endif
{
{
  int isDisplayed = FALSE;
  int isDisplayed = FALSE;
  int i, threshold;
  int i, threshold;
 
 
  if (checkThreshold)
  if (checkThreshold)
    threshold = SCROLL_THRESHOLD;
    threshold = SCROLL_THRESHOLD;
  else
  else
    threshold = 0;
    threshold = 0;
  i = 0;
  i = 0;
  while (i < winInfo->generic.contentSize - threshold && !isDisplayed)
  while (i < winInfo->generic.contentSize - threshold && !isDisplayed)
    {
    {
      if (winInfo == srcWin)
      if (winInfo == srcWin)
        isDisplayed = (((TuiWinElementPtr)
        isDisplayed = (((TuiWinElementPtr)
         winInfo->generic.content[i])->whichElement.source.lineOrAddr.lineNo
         winInfo->generic.content[i])->whichElement.source.lineOrAddr.lineNo
                       == (int) lineNoOrAddr);
                       == (int) lineNoOrAddr);
      else
      else
        isDisplayed = (((TuiWinElementPtr)
        isDisplayed = (((TuiWinElementPtr)
           winInfo->generic.content[i])->whichElement.source.lineOrAddr.addr
           winInfo->generic.content[i])->whichElement.source.lineOrAddr.addr
                       == lineNoOrAddr);
                       == lineNoOrAddr);
      i++;
      i++;
    }
    }
 
 
  return isDisplayed;
  return isDisplayed;
}                               /* tuiLineIsDisplayed */
}                               /* tuiLineIsDisplayed */
 
 
 
 
/*****************************************
/*****************************************
** STATIC LOCAL FUNCTIONS               **
** STATIC LOCAL FUNCTIONS               **
******************************************/
******************************************/
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.