Added source command.
This commit is contained in:
parent
c1f9d386eb
commit
bad8b4ca49
|
@ -34,8 +34,6 @@
|
|||
#include "expr.h"
|
||||
#include "msvcrt/excpt.h"
|
||||
|
||||
extern FILE * yyin;
|
||||
|
||||
static void mode_command(int);
|
||||
int yylex(void);
|
||||
int yyerror(char *);
|
||||
|
@ -55,9 +53,9 @@ int yyerror(char *);
|
|||
%token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN
|
||||
%token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT tVM86
|
||||
%token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
|
||||
%token tPROCESS tTHREAD tMODREF tEOL
|
||||
%token tPROCESS tTHREAD tMODREF tEOL tEOF
|
||||
%token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
|
||||
%token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS
|
||||
%token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE
|
||||
%token <string> tPATH
|
||||
%token <string> tIDENTIFIER tSTRING tDEBUGSTR tINTVAR
|
||||
%token <integer> tNUM tFORMAT
|
||||
|
@ -101,6 +99,7 @@ input: line
|
|||
|
||||
line: command
|
||||
| tEOL
|
||||
| tEOF { return 1; }
|
||||
| error tEOL { yyerrok; }
|
||||
;
|
||||
|
||||
|
@ -145,6 +144,7 @@ command:
|
|||
| tUNDISPLAY tEOL { DEBUG_DelDisplay( -1 ); }
|
||||
| tCOND tNUM tEOL { DEBUG_AddBPCondition($2, NULL); }
|
||||
| tCOND tNUM expr tEOL { DEBUG_AddBPCondition($2, $3); }
|
||||
| tSOURCE pathname tEOL { DEBUG_Parser($2); }
|
||||
| tSYMBOLFILE pathname tEOL { DEBUG_ReadSymbolTable($2, 0); }
|
||||
| tSYMBOLFILE pathname tNUM tEOL { DEBUG_ReadSymbolTable($2, $3); }
|
||||
| tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); DEBUG_FreeExprMem(); }
|
||||
|
@ -412,30 +412,57 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
|
|||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
static void set_default_channels(void)
|
||||
{
|
||||
DEBUG_hParserOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DEBUG_hParserInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DEBUG_Parser
|
||||
*
|
||||
* Debugger editline parser
|
||||
*/
|
||||
void DEBUG_Parser(void)
|
||||
void DEBUG_Parser(LPCSTR filename)
|
||||
{
|
||||
BOOL ret_ok;
|
||||
#ifdef YYDEBUG
|
||||
yydebug = 0;
|
||||
#endif
|
||||
yyin = stdin;
|
||||
|
||||
ret_ok = FALSE;
|
||||
do {
|
||||
__TRY {
|
||||
|
||||
if (filename)
|
||||
{
|
||||
DEBUG_hParserOutput = 0;
|
||||
DEBUG_hParserInput = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0L, 0);
|
||||
if (DEBUG_hParserInput == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
set_default_channels();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
set_default_channels();
|
||||
|
||||
do
|
||||
{
|
||||
__TRY
|
||||
{
|
||||
ret_ok = TRUE;
|
||||
yyparse();
|
||||
} __EXCEPT(wine_dbg_cmd) {
|
||||
}
|
||||
__EXCEPT(wine_dbg_cmd)
|
||||
{
|
||||
ret_ok = FALSE;
|
||||
}
|
||||
__ENDTRY;
|
||||
DEBUG_FlushSymbols();
|
||||
} while (!ret_ok);
|
||||
|
||||
if (filename)
|
||||
CloseHandle(DEBUG_hParserInput);
|
||||
set_default_channels();
|
||||
}
|
||||
|
||||
int yyerror(char* s)
|
||||
|
|
|
@ -29,13 +29,15 @@
|
|||
|
||||
#undef YY_INPUT
|
||||
|
||||
HANDLE DEBUG_hParserInput;
|
||||
HANDLE DEBUG_hParserOutput;
|
||||
|
||||
static int DEBUG_FetchFromLine(const char* pfx, char* buf, int size);
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
if ( (result = DEBUG_FetchFromLine("Wine-dbg>", buf, max_size)) <= 0 ) \
|
||||
if ( (result = DEBUG_FetchFromLine("Wine-dbg>", buf, max_size)) < 0 ) \
|
||||
YY_FATAL_ERROR( "ReadLine() in flex scanner failed" );
|
||||
|
||||
|
||||
#define YY_NO_UNPUT
|
||||
|
||||
static int syntax_error;
|
||||
|
@ -64,6 +66,7 @@ STRING \"[^\n"]+\"
|
|||
/* set to special state when no process is loaded. */
|
||||
if (!DEBUG_CurrProcess && YYSTATE == INITIAL) {BEGIN(NOPROCESS);}
|
||||
|
||||
<<EOF>> { return tEOF; }
|
||||
<*>\n { BEGIN(INITIAL); syntax_error = 0; return tEOL; }
|
||||
/* Indicates end of command. Reset state. */
|
||||
|
||||
|
@ -128,6 +131,7 @@ STRING \"[^\n"]+\"
|
|||
|
||||
<INITIAL>mode { BEGIN(MODE_CMD); return tMODE; }
|
||||
<INITIAL>show|sho|sh { BEGIN(SHOW_CMD); return tSHOW; }
|
||||
<INITIAL,NOPROCESS>source|sourc|sour|src { BEGIN(PATH_EXPECTED); return tSOURCE; }
|
||||
<INITIAL>symbolfile|symbols|symbol|sf { BEGIN(PATH_EXPECTED); return tSYMBOLFILE; }
|
||||
|
||||
<INITIAL,INFO_CMD,DEL_CMD>break|brea|bre|br|b { BEGIN(NOCMD); return tBREAK; }
|
||||
|
@ -216,12 +220,12 @@ static int DEBUG_FetchEntireLine(const char* pfx, char** line, size_t* allo
|
|||
/* as of today, console handles can be file handles... so better use file APIs rather than
|
||||
* consoles
|
||||
*/
|
||||
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pfx, strlen(pfx), NULL, NULL);
|
||||
WriteFile(DEBUG_hParserOutput, pfx, strlen(pfx), NULL, NULL);
|
||||
|
||||
len = 0;
|
||||
do
|
||||
{
|
||||
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf_line, sizeof(buf_line) - 1, &nread, NULL))
|
||||
if (!ReadFile(DEBUG_hParserInput, buf_line, sizeof(buf_line) - 1, &nread, NULL) || nread == 0)
|
||||
break;
|
||||
buf_line[nread] = '\0';
|
||||
|
||||
|
@ -237,6 +241,14 @@ static int DEBUG_FetchEntireLine(const char* pfx, char** line, size_t* allo
|
|||
len += nread;
|
||||
} while (nread == 0 || buf_line[nread - 1] != '\n');
|
||||
|
||||
if (!len)
|
||||
{
|
||||
*line = HeapReAlloc(GetProcessHeap(), 0, *line, *alloc = 1);
|
||||
**line = '\0';
|
||||
strcpy(*line + len, buf_line);
|
||||
len += nread;
|
||||
} while (nread == 0 || buf_line[nread - 1] != '\n');
|
||||
|
||||
/* Remove leading and trailing whitespace from the line */
|
||||
stripwhite(*line);
|
||||
return 1;
|
||||
|
|
|
@ -243,6 +243,8 @@ extern DWORD DEBUG_CurrPid;
|
|||
extern CONTEXT DEBUG_context;
|
||||
extern BOOL DEBUG_InteractiveP;
|
||||
extern enum exit_mode DEBUG_ExitMode;
|
||||
extern HANDLE DEBUG_hParserInput;
|
||||
extern HANDLE DEBUG_hParserOutput;
|
||||
|
||||
#define DEBUG_READ_MEM(addr, buf, len) \
|
||||
(ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
|
||||
|
@ -306,8 +308,8 @@ extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
|
|||
extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
|
||||
|
||||
/* debugger/dbg.y */
|
||||
extern void DEBUG_Parser(void);
|
||||
extern void DEBUG_Exit( DWORD );
|
||||
extern void DEBUG_Parser(LPCSTR);
|
||||
extern void DEBUG_Exit(DWORD);
|
||||
|
||||
/* debugger/debug.l */
|
||||
extern void DEBUG_FlushSymbols(void);
|
||||
|
@ -321,10 +323,6 @@ extern int DEBUG_DoDisplay(void);
|
|||
extern int DEBUG_DelDisplay(int displaynum);
|
||||
extern int DEBUG_InfoDisplay(void);
|
||||
|
||||
/* debugger/editline.c */
|
||||
extern char * readline(const char *);
|
||||
extern void add_history(char *);
|
||||
|
||||
/* debugger/expr.c */
|
||||
extern void DEBUG_FreeExprMem(void);
|
||||
struct expr * DEBUG_IntVarExpr(const char* name);
|
||||
|
|
|
@ -880,7 +880,7 @@ static DWORD DEBUG_MainLoop(void)
|
|||
else
|
||||
{
|
||||
DEBUG_InteractiveP = TRUE;
|
||||
DEBUG_Parser();
|
||||
DEBUG_Parser(NULL);
|
||||
}
|
||||
DEBUG_Printf(DBG_CHN_MESG, "WineDbg terminated on pid %lx\n", DEBUG_CurrPid);
|
||||
|
||||
|
|
Loading…
Reference in New Issue