mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
Revisited console support (got rid of old hacks and private editline
since we now have a brand new console), removed private debug heap.
This commit is contained in:
parent
0b83d4cbc6
commit
d0a04935ce
@ -9,7 +9,6 @@ C_SRCS = \
|
||||
break.c \
|
||||
db_disasm.c \
|
||||
display.c \
|
||||
editline.c \
|
||||
expr.c \
|
||||
ext_debugger.c \
|
||||
hash.c \
|
||||
|
@ -8,17 +8,17 @@
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "winbase.h"
|
||||
#include "wincon.h"
|
||||
#include "debugger.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
#ifndef DONT_USE_READLINE
|
||||
#undef YY_INPUT
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
if ( (result = dbg_read((char *) buf, max_size )) < 0 ) \
|
||||
if ( (result = DEBUG_ReadLine("Wine-dbg>", (char *) buf, max_size, TRUE )) < 0 ) \
|
||||
YY_FATAL_ERROR( "read() in flex scanner failed" );
|
||||
|
||||
static int dbg_read(char * buf, int size);
|
||||
|
||||
#endif /* DONT_USE_READLINE */
|
||||
|
||||
#define YY_NO_UNPUT
|
||||
@ -195,52 +195,61 @@ static void stripwhite (char *string)
|
||||
string[++i] = '\0';
|
||||
}
|
||||
|
||||
static int dbg_read(char * buf, int size)
|
||||
int DEBUG_ReadLine(const char* pfx, char * buf, int size, int remind)
|
||||
{
|
||||
static char last_line[256] = "";
|
||||
char * line;
|
||||
int len;
|
||||
|
||||
char buf_line[256];
|
||||
char* ptr;
|
||||
int len;
|
||||
DWORD nread;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
DEBUG_FlushSymbols();
|
||||
line = readline ("Wine-dbg>");
|
||||
if (!line)
|
||||
{
|
||||
DEBUG_Printf( DBG_CHN_MESG, "\n" );
|
||||
DEBUG_Exit(0);
|
||||
}
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pfx, strlen(pfx), NULL, NULL);
|
||||
|
||||
if (!ReadConsole(GetStdHandle(STD_INPUT_HANDLE), buf_line, sizeof(buf_line), &nread, NULL))
|
||||
break;
|
||||
/* FIXME: should be rewritten not to remove and then add the trailing '\n' */
|
||||
if (nread > 0 && buf_line[nread - 1] == '\n') nread--;
|
||||
buf_line[nread] = 0;
|
||||
|
||||
/* Remove leading and trailing whitespace from the line */
|
||||
stripwhite (buf_line);
|
||||
|
||||
stripwhite (line);
|
||||
if (remind)
|
||||
{
|
||||
static char last_line[256] = "";
|
||||
/* If there is anything left, add it to the history list
|
||||
and execute it. Otherwise, re-execute last command. */
|
||||
|
||||
if (*buf_line)
|
||||
{
|
||||
strncpy( last_line, buf_line, sizeof(last_line) - 1 );
|
||||
last_line[sizeof(last_line) - 1] = '\0';
|
||||
}
|
||||
ptr = last_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* I could also tweak with the undoc functions to remove this line from the console
|
||||
* history... */
|
||||
ptr = buf_line;
|
||||
}
|
||||
|
||||
/* If there is anything left, add it to the history list
|
||||
and execute it. Otherwise, re-execute last command. */
|
||||
|
||||
if (*line)
|
||||
if ((len = strlen(ptr)) > 0)
|
||||
{
|
||||
add_history( line );
|
||||
strncpy( last_line, line, 255 );
|
||||
last_line[255] = '\0';
|
||||
}
|
||||
|
||||
free( line );
|
||||
line = last_line;
|
||||
|
||||
if ((len = strlen(line)) > 0)
|
||||
{
|
||||
if (size < len + 1)
|
||||
if (size < len + 1)
|
||||
{
|
||||
DEBUG_Printf(DBG_CHN_MESG,"Fatal readline goof.\n");
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Fatal readline goof.\n");
|
||||
DEBUG_Exit(0);
|
||||
}
|
||||
strcpy(buf, line);
|
||||
strcpy(buf, ptr);
|
||||
buf[len] = '\n';
|
||||
buf[len+1] = 0;
|
||||
return len + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *local_symbols[30];
|
||||
|
@ -287,6 +287,7 @@ extern void DEBUG_Exit( DWORD );
|
||||
/* debugger/debug.l */
|
||||
extern void DEBUG_FlushSymbols(void);
|
||||
extern char*DEBUG_MakeSymbol(const char*);
|
||||
extern int DEBUG_ReadLine(const char* pfx, char* buffer, int size, int remind);
|
||||
|
||||
/* debugger/display.c */
|
||||
extern int DEBUG_DoDisplay(void);
|
||||
@ -512,13 +513,11 @@ extern char* DEBUG_XStrDup(const char *str);
|
||||
#define DBG_strdup(x) DEBUG_XStrDup(x)
|
||||
#else
|
||||
/* this one is slow (takes 5 minutes to load the debugger on my machine),
|
||||
but is pretty crash-proof (can step through malloc() without problems,
|
||||
malloc() arena (and other heaps) can be totally wasted and it'll still
|
||||
work, etc... if someone could make optimized routines so it wouldn't
|
||||
if someone could make optimized routines so it wouldn't
|
||||
take so long to load, it could be made default) */
|
||||
#define DBG_alloc(x) HeapAlloc(dbg_heap,0,x)
|
||||
#define DBG_realloc(x,y) HeapRealloc(dbg_heap,0,x,y)
|
||||
#define DBG_free(x) HeapFree(dbg_heap,0,x)
|
||||
#define DBG_alloc(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
|
||||
#define DBG_realloc(x,y) HeapReAlloc(GetProcessHeap(),0,x,y)
|
||||
#define DBG_free(x) HeapFree(GetProcessHeap(),0,x)
|
||||
inline static LPSTR DBG_strdup( LPCSTR str )
|
||||
{
|
||||
INT len = strlen(str) + 1;
|
||||
@ -526,8 +525,6 @@ inline static LPSTR DBG_strdup( LPCSTR str )
|
||||
if (p) memcpy( p, str, len );
|
||||
return p;
|
||||
}
|
||||
#define DBG_need_heap
|
||||
extern HANDLE dbg_heap;
|
||||
#endif
|
||||
|
||||
#define DEBUG_STATUS_OFFSET 0x80003000
|
||||
|
1249
debugger/editline.c
1249
debugger/editline.c
File diff suppressed because it is too large
Load Diff
@ -387,7 +387,8 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
|
||||
} else if (!DEBUG_interactiveP || num == 1) {
|
||||
i = 0;
|
||||
} else {
|
||||
char* ptr;
|
||||
char buffer[256];
|
||||
|
||||
if (num == NUMDBGV+1) {
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Too many addresses for symbol '%s', limiting the first %d\n", name, NUMDBGV);
|
||||
num = NUMDBGV;
|
||||
@ -399,11 +400,13 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
|
||||
DEBUG_Printf(DBG_CHN_MESG, "\n");
|
||||
}
|
||||
do {
|
||||
ptr = readline("=> ");
|
||||
if (!*ptr) return FALSE;
|
||||
i = atoi(ptr);
|
||||
if (i < 1 || i > num)
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i);
|
||||
i = 0;
|
||||
if (DEBUG_ReadLine("=> ", buffer, sizeof(buffer), FALSE))
|
||||
{
|
||||
i = atoi(buffer);
|
||||
if (i < 1 || i > num)
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i);
|
||||
}
|
||||
} while (i < 1 || i > num);
|
||||
|
||||
/* The array is 0-based, but the choices are 1..n, so we have to subtract one before returning. */
|
||||
|
@ -188,7 +188,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
|
||||
* Still couldn't find it. Ask user for path to add.
|
||||
*/
|
||||
sprintf(zbuf, "Enter path to file '%s': ", sourcefile);
|
||||
lstrcpynA(tmppath, readline(zbuf), sizeof(tmppath));
|
||||
DEBUG_ReadLine(zbuf, tmppath, sizeof(tmppath), FALSE);
|
||||
|
||||
if( tmppath[strlen(tmppath)-1] == '\n' )
|
||||
{
|
||||
|
@ -19,10 +19,6 @@
|
||||
|
||||
#include "winreg.h"
|
||||
|
||||
#ifdef DBG_need_heap
|
||||
HANDLE dbg_heap = 0;
|
||||
#endif
|
||||
|
||||
DBG_PROCESS* DEBUG_CurrProcess = NULL;
|
||||
DBG_THREAD* DEBUG_CurrThread = NULL;
|
||||
DWORD DEBUG_CurrTid;
|
||||
@ -464,6 +460,9 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL
|
||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Alignment");
|
||||
break;
|
||||
case DBG_CONTROL_C:
|
||||
DEBUG_Printf(DBG_CHN_MESG, "^C");
|
||||
break;
|
||||
case CONTROL_C_EXIT:
|
||||
DEBUG_Printf(DBG_CHN_MESG, "^C");
|
||||
break;
|
||||
@ -863,7 +862,7 @@ static BOOL DEBUG_Start(LPSTR cmdLine)
|
||||
startup.wShowWindow = SW_SHOWNORMAL;
|
||||
|
||||
if (!CreateProcess(NULL, cmdLine, NULL, NULL,
|
||||
FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info)) {
|
||||
FALSE, DEBUG_PROCESS|DETACHED_PROCESS, NULL, NULL, &startup, &info)) {
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Couldn't start process '%s'\n", cmdLine);
|
||||
return FALSE;
|
||||
}
|
||||
@ -889,15 +888,41 @@ void DEBUG_Run(const char* args)
|
||||
}
|
||||
}
|
||||
|
||||
static void DEBUG_InitConsole(void)
|
||||
{
|
||||
COORD c;
|
||||
SMALL_RECT sr;
|
||||
DWORD mode;
|
||||
|
||||
/* keep it as a cuiexe for now, so that Wine won't touch the Unix stdin,
|
||||
* stdout and stderr streams
|
||||
*/
|
||||
if (DBG_IVAR(UseXTerm))
|
||||
{
|
||||
FreeConsole();
|
||||
AllocConsole();
|
||||
}
|
||||
/* this would be nicer for output */
|
||||
c.X = 132;
|
||||
c.Y = 500;
|
||||
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), c);
|
||||
|
||||
/* sets the console's window width accordingly */
|
||||
sr.Left = 0;
|
||||
sr.Top = 0;
|
||||
sr.Right = c.X - 1;
|
||||
sr.Bottom = 50;
|
||||
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &sr);
|
||||
|
||||
/* put the line editing mode with the nice emacs features (FIXME: could be triggered by a IVAR) */
|
||||
if (GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &mode))
|
||||
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), mode | WINE_ENABLE_LINE_INPUT_EMACS);
|
||||
}
|
||||
|
||||
int DEBUG_main(int argc, char** argv)
|
||||
{
|
||||
DWORD retv = 0;
|
||||
|
||||
#ifdef DBG_need_heap
|
||||
/* Initialize the debugger heap. */
|
||||
dbg_heap = HeapCreate(HEAP_NO_SERIALIZE, 0x1000, 0x8000000); /* 128MB */
|
||||
#endif
|
||||
|
||||
/* Initialize the type handling stuff. */
|
||||
DEBUG_InitTypes();
|
||||
DEBUG_InitCVDataTypes();
|
||||
@ -917,17 +942,8 @@ int DEBUG_main(int argc, char** argv)
|
||||
DBG_IVAR(StdChannelMask) = DBG_CHN_MESG;
|
||||
}
|
||||
|
||||
/* keep it as a guiexe for now, so that Wine won't touch the Unix stdin,
|
||||
* stdout and stderr streams
|
||||
*/
|
||||
if (DBG_IVAR(UseXTerm)) {
|
||||
COORD pos;
|
||||
|
||||
/* This is a hack: it forces creation of an xterm, not done by default */
|
||||
pos.X = 0; pos.Y = 1;
|
||||
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
|
||||
}
|
||||
|
||||
DEBUG_InitConsole();
|
||||
|
||||
DEBUG_Printf(DBG_CHN_MESG, "WineDbg starting... ");
|
||||
|
||||
if (argc == 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user