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

📄 command.c

📁 如果RH
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * *  xdbx - X Window System interface to the dbx debugger * *  Copyright 1989 The University of Texas at Austin *  Copyright 1990 Microelectronics and Computer Technology Corporation * *  Permission to use, copy, modify, and distribute this software and its *  documentation for any purpose and without fee is hereby granted, *  provided that the above copyright notice appear in all copies and that *  both that copyright notice and this permission notice appear in *  supporting documentation, and that the name of The University of Texas *  and Microelectronics and Computer Technology Corporation (MCC) not be  *  used in advertising or publicity pertaining to distribution of *  the software without specific, written prior permission.  The *  University of Texas and MCC makes no representations about the  *  suitability of this software for any purpose.  It is provided "as is"  *  without express or implied warranty. * *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * *  Author:  	Po Cheung *  Created:   	March 10, 1989 *  ***************************************************************************** *  *  xxgdb - X Window System interface to the gdb debugger *   * 	Copyright 1990,1993 Thomson Consumer Electronics, Inc. *   *  Permission to use, copy, modify, and distribute this software and its *  documentation for any purpose and without fee is hereby granted, *  provided that the above copyright notice appear in all copies and that *  both that copyright notice and this permission notice appear in *  supporting documentation, and that the name of Thomson Consumer *  Electronics (TCE) not be used in advertising or publicity pertaining *  to distribution of the software without specific, written prior *  permission.  TCE makes no representations about the suitability of *  this software for any purpose.  It is provided "as is" without express *  or implied warranty. * *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS *  SOFTWARE. * *  Adaptation to GDB:  Pierre Willard *  XXGDB Created:   	December, 1990 * *  AJK Changes: Apr-May 1991 *  1. Added new buttons for gdb, dbx, *  2. Free strings allocated by 'XFetchBytes', *****************************************************************************//*  command.c * *    Create the command window, the command buttons and their callbacks. * *    CreateCommandPanel() : 	Create a window with command buttons *    CreateButtons() :		Create command buttons in panel *    AddButton() :		Add a command button into the command window *    ButtonSet() :		Action proc for command button translation * *    Command callbacks for the command buttons: * *    forwardSearch() :		forward string search *    reverseSearch() :		reverse string search *    Search() :		call either forwardSearch() or reverseSearch() *    PopupSearch() :		command callback for search button *    DoneSearch() :		command callback for DONE button in search panel *    CreateSearchPopup() :	create search panel * *    Command queue manipulation routines: *	send_command():		send a command to dbx and record in the queue *	get_command():		read command off head of queue *	insert_command():	insert command at the head of queue *	delete_command():	delete command from head of queue */ #include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <signal.h>#ifdef	_POSIX_SOURCE#include <sys/types.h>#endif#include <sys/wait.h>#include "global.h"#define	 REVERSE	0#define	 FORWARD	1Widget		commandWindow;			/* command panel with buttons */Boolean		PopupMode = False;static int	Button;static Widget	searchPopupShell, searchPopup;static Widget	AddButton();static Widget	button[30];static char	SearchString[BUFSIZ] = "";	/* search string buffer */static char	command[LINESIZ];static CommandRec *commandQueue = NULL;#ifndef GDB#ifdef BSDstatic char	savedCommand[LINESIZ] = ""; #endif#endif	/* not GDB *//* ARGSUSED */static void ButtonSet(w, event, params, num_params)    Widget w;    XEvent *event;    String *params;    Cardinal *num_params;{    Button = atoi(params[0]);}/* ARGSUSED *//*  Execute the dbx command specifed in client_data */static void DoIt (w, command, call_data)    Widget w;    XtPointer command;    XtPointer call_data;{    /* run, cont, next, step, where, up, down, status */    send_command(command);    AppendDialogText(command);}#if !defined(GDB) && defined(BSD)	/* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< *//* ARGSUSED */static void Return (w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *funcname;    int  nbytes;    funcname = XFetchBytes(display, &nbytes);	/* from CUT_BUFFER0 */    if (nbytes == 0)    	strcpy(command, "return\n");    else {    	sprintf(command, "return %s\n", funcname);	XFree (funcname);                           /* AJK */      }    send_command(command);    AppendDialogText(command);}#endif /* NOT GDB && BSD */#ifdef GDB	/* >>>>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<< *//*	here client_data is "break" or "tbreak"*/static void Break(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    XawTextPosition pos;    int line;    char *funcname;    int  nbytes;    char *s;    funcname = XFetchBytes(display, &nbytes);	/* from CUT_BUFFER0 */	if (nbytes) 		{		s = funcname;		while (*s == ' ') s++;	/* skip leading spaces (if any) */		if ((*s >= '0') && (*s <= '9'))			sprintf(command, "%s *%s\n",client_data,funcname);		else			sprintf(command, "%s %s\n",client_data,funcname);		XFree (funcname);   /* AJK */		}	else		{		if (displayedFile != NULL)			{			pos = XawTextGetInsertionPoint(sourceWindow);			line = TextPositionToLine(pos);			sprintf(command, "%s %d\n",client_data,line);			}		else			{			UpdateMessageWindow(BREAK_HELP, NULL);			bell(0);			return;			}		}		    send_command(command);    AppendDialogText(command);}#else	/* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< *//* ARGSUSED */static void Stop_at(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    XawTextPosition pos;    int line;    if (displayedFile == NULL) {	UpdateMessageWindow(STOP_AT_HELP, NULL);	bell(0);	return;    }    pos = XawTextGetInsertionPoint(sourceWindow);    line = TextPositionToLine(pos);    sprintf(command, "stop at %d\n", line);    send_command(command);    AppendDialogText(command);}/* ARGSUSED */static void Stop_in(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *funcname;    int  nbytes;    funcname = XFetchBytes(display, &nbytes);	/* from CUT_BUFFER0 */    if (nbytes == 0) {	UpdateMessageWindow(STOP_IN_HELP, NULL);	bell(0);	return;    }    sprintf(command, "stop in %s\n", funcname);    send_command(command);    AppendDialogText(command);    XFree (funcname);          /* AJK */}#endif /* NOT GDB *//*  Delete removes the stop_no associated with a given line number. *  RemoveStop() is called to undisplay the stop sign only when there *  are no more stop_no's associated with that line number. *//* ARGSUSED */static void Delete(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    XawTextPosition pos;    char	    *string;    int		    stop_no, line, nbytes;    string = XFetchBytes(display, &nbytes);    if (nbytes > 0 && (stop_no = atoi(string)) > 0) {    	sprintf(command, "delete %d\n", stop_no);	send_command(command);	AppendDialogText(command);	XFree (string);                             /* AJK */	return;    }    else if (displayedFile) {      if (string) {                     /* AJK: string is non-NULL, but not an int */	  XFree (string);	  string = (char *)NULL;	}	pos = XawTextGetInsertionPoint(sourceWindow);	line = TextPositionToLine(pos);	if ((stop_no = LineToStop_no(line))) {	    sprintf(command, "delete %d\n", stop_no);	    send_command(command);	    AppendDialogText(command);	    return;	}    }    if (string) {                     /* AJK */      XFree (string);    }    UpdateMessageWindow(DELETE_HELP, NULL);    bell(0);}/* ARGSUSED */static void Print(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *string;    int nbytes;    if (Button == 3) PopupMode = True;    string = XFetchBytes(display, &nbytes);    if (nbytes == 0) {	UpdateMessageWindow(PRINT_HELP, NULL);	bell(0);	return;    }    if (client_data == (XtPointer)0)	sprintf(command, "print %s\n", string);    else if (client_data == (XtPointer)1)	sprintf(command, "print *%s\n", string);    send_command(command);#ifdef GDB	if (!PopupMode)		/* for GDB don't display print if everything goes in a window */#endif    AppendDialogText(command);    XFree (string);                           /* AJK */}#ifndef GDB /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< *//* ARGSUSED */static void Func(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *funcname;    int nbytes;    funcname = XFetchBytes(display, &nbytes);    if (nbytes == 0)    	strcpy(command, "func\n");    else {    	sprintf(command, "func %s\n", funcname);	XFree (funcname);                           /* AJK */      }    send_command(command);    AppendDialogText(command);}#endif /* NOT GDB *//* CRL mod 2/19/91 GWC - an callback procedure for the "interrupt" button. * As in SigInt in dialog.c the process is  * interrupted with killpg(dbxpid, SIGINT). *//* add interrupt button that send sigint to inferior gdb,need to have gdb receive SIGINT. */static void Interrupt(w, client_data, call_data)   Widget w;   XtPointer client_data;   XtPointer call_data;{  signal_interrupt_dbx ();}#ifdef EDIT_BUTTON/* allow invocation of favorite editor from within interface. */static void EdCallback(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    StartEditor();}#endif /* EDIT_BUTTON */ /* ARGSUSED */#ifndef NEW_INTERFACEstatic#endifvoid Quit(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{#ifdef SYSV     int status;#else    union wait status;#endif /* SYSV */    write_dbx("quit\n");    XtDestroyApplicationContext(app_context);    kill(dbxpid, SIGKILL);#ifdef SYSV#if 1 /* instead of ifdef SVR4 */	status = waitpid(dbxpid, (int *)0, WNOHANG);	/* (MJH) */#else	waitpid(&status, NULL, WNOHANG);#endif	/* SVR4 */#else	/* not SYSV */    wait3(&status, WNOHANG, NULL);#endif /* SYSV */    exit(0);}/* ARGSUSED */static void Display_(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *string;    int nbytes;    string = XFetchBytes(display, &nbytes);    sprintf(command, "display %s\n", string);    send_command(command);    AppendDialogText(command);    if (string)                  /* AJK */      XFree (string);}#ifndef GDB/* Handle dbx commands which need a variable name (whatis,whereis,which,trace). * Command name is passed in client_data. */static void WhCmds (w, client_data, call_data)                      /* AJK */    Widget    w;    XtPointer client_data;    XtPointer call_data;{    char *string;    int   nbytes;    string = XFetchBytes (display, &nbytes);    if (nbytes == 0) {	UpdateMessageWindow (WHATIS_HELP, NULL);	bell (0);	return;      }    sprintf (command, "%s %s\n", client_data, string);    send_command (command);    AppendDialogText (command);    XFree (string);} /* WhCmds */#endif          /* >>>>>>>>>>>>>> DBX ONLY <<<<<<<<<<<<<<<< */#ifdef GDB	/* >>>>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<< *//* ARGSUSED */static void Undisplay(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *string;    int	 stop_no, nbytes;    string = XFetchBytes(display, &nbytes);    if (nbytes != 0)    	{		if ((stop_no = atoi(string)) > 0)			sprintf(command, "undisplay %d\n", stop_no);   		else   			{			UpdateMessageWindow(UNDISPLAY_HELP, NULL);			bell(0);			return;   			}		XFree (string);           /* AJK */   		}   	else		sprintf(command, "undisplay\n");   			send_command(command);	AppendDialogText(command);}#else	/* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< *//* ARGSUSED */static void Undisplay(w, client_data, call_data)    Widget w;    XtPointer client_data;    XtPointer call_data;{    char *string;

⌨️ 快捷键说明

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