⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tuiregs.c

📁 gdb-6.0 linux 下的调试工具
💻 C
📖 第 1 页 / 共 2 页
字号:
    }  return;}				/* tuiCheckRegisterValues *//*   ** tuiToggleFloatRegs(). */voidtuiToggleFloatRegs (void){  TuiLayoutDefPtr layoutDef = tuiLayoutDef ();  if (layoutDef->floatRegsDisplayType == TUI_SFLOAT_REGS)    layoutDef->floatRegsDisplayType = TUI_DFLOAT_REGS;  else    layoutDef->floatRegsDisplayType = TUI_SFLOAT_REGS;  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible &&      (dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_SFLOAT_REGS ||       dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_DFLOAT_REGS))    tuiShowRegisters (layoutDef->floatRegsDisplayType);  return;}				/* tuiToggleFloatRegs */void_initialize_tuiRegs (void){  if (xdb_commands)    {      add_com ("fr", class_tui, _tuiShowFloat_command,	       "Display only floating point registers\n");      add_com ("gr", class_tui, _tuiShowGeneral_command,	       "Display only general registers\n");      add_com ("sr", class_tui, _tuiShowSpecial_command,	       "Display only special registers\n");      add_com ("+r", class_tui, _tuiScrollRegsForward_command,	       "Scroll the registers window forward\n");      add_com ("-r", class_tui, _tuiScrollRegsBackward_command,	       "Scroll the register window backward\n");      add_com ("tf", class_tui, _tuiToggleFloatRegs_command,	       "Toggle between single and double precision floating point registers.\n");      add_cmd (TUI_FLOAT_REGS_NAME_LOWER,	       class_tui,	       _tuiToggleFloatRegs_command,	       "Toggle between single and double precision floating point \registers.\n",	       &togglelist);    }}/******************************************* STATIC LOCAL FUNCTIONS                 ********************************************//*   ** _tuiRegisterName().   **        Return the register name. */static const char *_tuiRegisterName (int regNum){  return REGISTER_NAME (regNum);}extern int pagination_enabled;static voidtui_restore_gdbout (void *ui){  ui_file_delete (gdb_stdout);  gdb_stdout = (struct ui_file*) ui;  pagination_enabled = 1;}/*   ** _tuiRegisterFormat   **        Function to format the register name and value into a buffer,   **        suitable for printing or display */static void_tuiRegisterFormat (char *buf, int bufLen, int regNum,                    TuiDataElementPtr dataElement,                    enum precision_type precision){  struct ui_file *stream;  struct ui_file *old_stdout;  const char *name;  struct cleanup *cleanups;  char *p;  int pos;  name = REGISTER_NAME (regNum);  if (name == 0)    {      strcpy (buf, "");      return;    }    pagination_enabled = 0;  old_stdout = gdb_stdout;  stream = tui_sfileopen (bufLen);  gdb_stdout = stream;  cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);  gdbarch_print_registers_info (current_gdbarch, stream, deprecated_selected_frame,                                regNum, 1);  /* Save formatted output in the buffer.  */  p = tui_file_get_strbuf (stream);  pos = 0;  while (*p && *p == *name++ && bufLen)    {      *buf++ = *p++;      bufLen--;      pos++;    }  while (*p == ' ')    p++;  while (pos < 8 && bufLen)    {      *buf++ = ' ';      bufLen--;      pos++;    }  strncpy (buf, p, bufLen);  /* Remove the possible \n.  */  p = strchr (buf, '\n');  if (p)    *p = 0;  do_cleanups (cleanups);}#define NUM_GENERAL_REGS    32/*   ** _tuiSetGeneralRegsContent().   **      Set the content of the data window to consist of the general registers. */static TuiStatus_tuiSetGeneralRegsContent (int refreshValuesOnly){  return (_tuiSetRegsContent (0,			      NUM_GENERAL_REGS - 1,			      deprecated_selected_frame,			      TUI_GENERAL_REGS,			      refreshValuesOnly));}				/* _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. */static TuiStatus_tuiSetSpecialRegsContent (int refreshValuesOnly){  TuiStatus ret = TUI_FAILURE;  int endRegNum;  endRegNum = FP0_REGNUM - 1;  ret = _tuiSetRegsContent (START_SPECIAL_REGS,			    endRegNum,			    deprecated_selected_frame,			    TUI_SPECIAL_REGS,			    refreshValuesOnly);  return ret;}				/* _tuiSetSpecialRegsContent *//*   ** _tuiSetGeneralAndSpecialRegsContent().   **      Set the content of the data window to consist of the special registers. */static TuiStatus_tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly){  TuiStatus ret = TUI_FAILURE;  int endRegNum = (-1);  endRegNum = FP0_REGNUM - 1;  ret = _tuiSetRegsContent (	 0, endRegNum, deprecated_selected_frame, TUI_SPECIAL_REGS, refreshValuesOnly);  return ret;}				/* _tuiSetGeneralAndSpecialRegsContent *//*   ** _tuiSetFloatRegsContent().   **        Set the content of the data window to consist of the float registers. */static TuiStatus_tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType, int refreshValuesOnly){  TuiStatus ret = TUI_FAILURE;  int startRegNum;  startRegNum = FP0_REGNUM;  ret = _tuiSetRegsContent (startRegNum,			    NUM_REGS - 1,			    deprecated_selected_frame,			    dpyType,			    refreshValuesOnly);  return ret;}				/* _tuiSetFloatRegsContent *//*   ** _tuiRegValueHasChanged().   **        Answer TRUE if the register's value has changed, FALSE otherwise.   **        If TRUE, newValue is filled in with the new value. */static int_tuiRegValueHasChanged (TuiDataElementPtr dataElement,                        struct frame_info *frame,                        char *newValue){  int hasChanged = FALSE;  if (dataElement->itemNo != UNDEFINED_ITEM &&      _tuiRegisterName (dataElement->itemNo) != (char *) NULL)    {      char rawBuf[MAX_REGISTER_SIZE];      int i;      if (_tuiGetRegisterRawValue (			 dataElement->itemNo, rawBuf, frame) == TUI_SUCCESS)	{          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 < size; i++)		newValue[i] = rawBuf[i];	    }	}    }  return hasChanged;}				/* _tuiRegValueHasChanged *//*   ** _tuiGetRegisterRawValue().   **        Get the register raw value.  The raw value is returned in regValue. */static TuiStatus_tuiGetRegisterRawValue (int regNum, char *regValue, struct frame_info *frame){  TuiStatus ret = TUI_FAILURE;  if (target_has_registers)    {      frame_read_register (frame, regNum, regValue);      /* NOTE: cagney/2003-03-13: This is bogus.  It is refering to         the register cache and not the frame which could have pulled         the register value off the stack.  */      if (register_cached (regNum) >= 0)	ret = TUI_SUCCESS;    }  return ret;}				/* _tuiGetRegisterRawValue *//*   ** _tuiSetRegisterElement().   **       Function to initialize a data element with the input and   **       the register value. */static void_tuiSetRegisterElement (int regNum, struct frame_info *frame,                        TuiDataElementPtr dataElement,                        int refreshValueOnly){  if (dataElement != (TuiDataElementPtr) NULL)    {      if (!refreshValueOnly)	{	  dataElement->itemNo = regNum;	  dataElement->name = _tuiRegisterName (regNum);	  dataElement->highlight = FALSE;	}      if (dataElement->value == (Opaque) NULL)	dataElement->value = (Opaque) xmalloc (MAX_REGISTER_SIZE);      if (dataElement->value != (Opaque) NULL)	_tuiGetRegisterRawValue (regNum, dataElement->value, frame);    }  return;}				/* _tuiSetRegisterElement *//*   ** _tuiSetRegsContent().   **        Set the content of the data window to consist of the registers   **        numbered from startRegNum to endRegNum.  Note that if   **        refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored. */static TuiStatus_tuiSetRegsContent (int startRegNum, int endRegNum,                    struct frame_info *frame,                    TuiRegisterDisplayType dpyType,                    int refreshValuesOnly){  TuiStatus ret = TUI_FAILURE;  int numRegs = endRegNum - startRegNum + 1;  int allocatedHere = FALSE;  if (dataWin->detail.dataDisplayInfo.regsContentCount > 0 &&      !refreshValuesOnly)    {      freeDataContent (dataWin->detail.dataDisplayInfo.regsContent,		       dataWin->detail.dataDisplayInfo.regsContentCount);      dataWin->detail.dataDisplayInfo.regsContentCount = 0;    }  if (dataWin->detail.dataDisplayInfo.regsContentCount <= 0)    {      dataWin->detail.dataDisplayInfo.regsContent =	allocContent (numRegs, DATA_WIN);      allocatedHere = TRUE;    }  if (dataWin->detail.dataDisplayInfo.regsContent != (TuiWinContent) NULL)    {      int i;      if (!refreshValuesOnly || allocatedHere)	{	  dataWin->generic.content = (OpaquePtr) NULL;	  dataWin->generic.contentSize = 0;	  addContentElements (&dataWin->generic, numRegs);	  dataWin->detail.dataDisplayInfo.regsContent =	    (TuiWinContent) dataWin->generic.content;	  dataWin->detail.dataDisplayInfo.regsContentCount = numRegs;	}      /*         ** Now set the register names and values       */      for (i = startRegNum; (i <= endRegNum); i++)	{	  TuiGenWinInfoPtr dataItemWin;	  dataItemWin = &dataWin->detail.dataDisplayInfo.	    regsContent[i - startRegNum]->whichElement.dataWindow;	  _tuiSetRegisterElement (				   i,				   frame,	   &((TuiWinElementPtr) dataItemWin->content[0])->whichElement.data,				   !allocatedHere && refreshValuesOnly);	}      dataWin->detail.dataDisplayInfo.regsColumnCount =	tuiCalculateRegsColumnCount (dpyType);#ifdef LATER      if (dataWin->detail.dataDisplayInfo.dataContentCount > 0)	{	  /* delete all the windows? */	  /* realloc content equal to dataContentCount + regsContentCount */	  /* append dataWin->detail.dataDisplayInfo.dataContent to content */	}#endif      dataWin->generic.contentSize =	dataWin->detail.dataDisplayInfo.regsContentCount +	dataWin->detail.dataDisplayInfo.dataContentCount;      ret = TUI_SUCCESS;    }  return ret;}				/* _tuiSetRegsContent *//*   ** _tuiDisplayRegister().   **        Function to display a register in a window.  If hilite is TRUE,   **        than the value will be displayed in reverse video */static void_tuiDisplayRegister (int regNum,                     TuiGenWinInfoPtr winInfo,		/* the data item window */                     enum precision_type precision){  if (winInfo->handle != (WINDOW *) NULL)    {      int i;      char buf[40];      int valueCharsWide, labelWidth;      TuiDataElementPtr dataElementPtr = &((TuiWinContent)				    winInfo->content)[0]->whichElement.data;      if (IS_64BIT ||	  dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_DFLOAT_REGS)	{	  valueCharsWide = DOUBLE_FLOAT_VALUE_WIDTH;	  labelWidth = DOUBLE_FLOAT_LABEL_WIDTH;	}      else	{	  if (dataWin->detail.dataDisplayInfo.regsDisplayType ==	      TUI_SFLOAT_REGS)	    {	      valueCharsWide = SINGLE_FLOAT_VALUE_WIDTH;	      labelWidth = SINGLE_FLOAT_LABEL_WIDTH;	    }	  else	    {	      valueCharsWide = SINGLE_VALUE_WIDTH;	      labelWidth = SINGLE_LABEL_WIDTH;	    }	}      buf[0] = (char) 0;      _tuiRegisterFormat (buf,			  valueCharsWide + labelWidth,			  regNum,			  dataElementPtr,			  precision);      if (dataElementPtr->highlight)	wstandout (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);      if (dataElementPtr->highlight)	wstandend (winInfo->handle);      tuiRefreshWin (winInfo);    }  return;}				/* _tuiDisplayRegister */static void_tui_vShowRegisters_commandSupport (TuiRegisterDisplayType dpyType){  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)    {				/* Data window already displayed, show the registers */      if (dataWin->detail.dataDisplayInfo.regsDisplayType != dpyType)	tuiShowRegisters (dpyType);    }  else    (tuiLayoutDef ())->regsDisplayType = dpyType;  return;}				/* _tui_vShowRegisters_commandSupport */static void_tuiShowFloat_command (char *arg, int fromTTY){  if (m_winPtrIsNull (dataWin) || !dataWin->generic.isVisible ||      (dataWin->detail.dataDisplayInfo.regsDisplayType != TUI_SFLOAT_REGS &&       dataWin->detail.dataDisplayInfo.regsDisplayType != TUI_DFLOAT_REGS))    _tui_vShowRegisters_commandSupport ((tuiLayoutDef ())->floatRegsDisplayType);  return;}				/* _tuiShowFloat_command */static void_tuiShowGeneral_command (char *arg, int fromTTY){  _tui_vShowRegisters_commandSupport (TUI_GENERAL_REGS);}static void_tuiShowSpecial_command (char *arg, int fromTTY){  _tui_vShowRegisters_commandSupport (TUI_SPECIAL_REGS);}static void_tuiToggleFloatRegs_command (char *arg, int fromTTY){  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)    tuiToggleFloatRegs ();  else    {      TuiLayoutDefPtr layoutDef = tuiLayoutDef ();      if (layoutDef->floatRegsDisplayType == TUI_SFLOAT_REGS)	layoutDef->floatRegsDisplayType = TUI_DFLOAT_REGS;      else	layoutDef->floatRegsDisplayType = TUI_SFLOAT_REGS;    }  return;}				/* _tuiToggleFloatRegs_command */static void_tuiScrollRegsForward_command (char *arg, int fromTTY){  tui_scroll (FORWARD_SCROLL, dataWin, 1);}static void_tuiScrollRegsBackward_command (char *arg, int fromTTY){  tui_scroll (BACKWARD_SCROLL, dataWin, 1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -