mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 02:38:21 +00:00
winedbg: Display line number of syntax errors when reading a command file.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
dd59222d4d
commit
5a94f20065
|
@ -452,8 +452,15 @@ static LONG WINAPI wine_dbg_cmd(EXCEPTION_POINTERS *eptr)
|
|||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
static HANDLE dbg_parser_input;
|
||||
static HANDLE dbg_parser_output;
|
||||
struct parser_context
|
||||
{
|
||||
const char* filename;
|
||||
HANDLE input;
|
||||
HANDLE output;
|
||||
unsigned line_no;
|
||||
};
|
||||
|
||||
static struct parser_context dbg_parser = {NULL, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0};
|
||||
|
||||
int input_fetch_entire_line(const char* pfx, char** line)
|
||||
{
|
||||
|
@ -465,15 +472,16 @@ int input_fetch_entire_line(const char* pfx, char** line)
|
|||
/* as of today, console handles can be file handles... so better use file APIs rather than
|
||||
* console's
|
||||
*/
|
||||
WriteFile(dbg_parser_output, pfx, strlen(pfx), &nread, NULL);
|
||||
WriteFile(dbg_parser.output, pfx, strlen(pfx), &nread, NULL);
|
||||
|
||||
buffer = HeapAlloc(GetProcessHeap(), 0, alloc = 16);
|
||||
assert(buffer != NULL);
|
||||
|
||||
dbg_parser.line_no++;
|
||||
len = 0;
|
||||
do
|
||||
{
|
||||
if (!ReadFile(dbg_parser_input, &ch, 1, &nread, NULL) || nread == 0)
|
||||
if (!ReadFile(dbg_parser.input, &ch, 1, &nread, NULL) || nread == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
return -1;
|
||||
|
@ -513,25 +521,25 @@ int input_read_line(const char* pfx, char* buf, int size)
|
|||
*
|
||||
* Debugger command line parser
|
||||
*/
|
||||
void parser_handle(HANDLE input)
|
||||
void parser_handle(const char* filename, HANDLE input)
|
||||
{
|
||||
BOOL ret_ok;
|
||||
HANDLE in_copy = dbg_parser_input;
|
||||
HANDLE out_copy = dbg_parser_output;
|
||||
BOOL ret_ok;
|
||||
struct parser_context prev = dbg_parser;
|
||||
|
||||
ret_ok = FALSE;
|
||||
|
||||
if (input != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dbg_parser_output = INVALID_HANDLE_VALUE;
|
||||
dbg_parser_input = input;
|
||||
dbg_parser.output = INVALID_HANDLE_VALUE;
|
||||
dbg_parser.input = input;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_parser_output = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
dbg_parser_input = GetStdHandle(STD_INPUT_HANDLE);
|
||||
dbg_parser.output = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
dbg_parser.input = GetStdHandle(STD_INPUT_HANDLE);
|
||||
}
|
||||
|
||||
dbg_parser.line_no = 0;
|
||||
dbg_parser.filename = filename;
|
||||
do
|
||||
{
|
||||
__TRY
|
||||
|
@ -547,8 +555,7 @@ void parser_handle(HANDLE input)
|
|||
lexeme_flush();
|
||||
} while (!ret_ok);
|
||||
|
||||
dbg_parser_input = in_copy;
|
||||
dbg_parser_output = out_copy;
|
||||
dbg_parser = prev;
|
||||
}
|
||||
|
||||
static void parser(const char* filename)
|
||||
|
@ -556,13 +563,15 @@ static void parser(const char* filename)
|
|||
HANDLE h = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0L, 0);
|
||||
if (h != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
parser_handle(h);
|
||||
parser_handle(filename, h);
|
||||
CloseHandle(h);
|
||||
}
|
||||
}
|
||||
|
||||
static int dbg_error(const char* s)
|
||||
{
|
||||
if (dbg_parser.filename)
|
||||
dbg_printf("%s:%d:", dbg_parser.filename, dbg_parser.line_no);
|
||||
dbg_printf("%s\n", s);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ extern HANDLE display_crash_details(HANDLE event);
|
|||
extern int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType);
|
||||
|
||||
/* dbg.y */
|
||||
extern void parser_handle(HANDLE);
|
||||
extern void parser_handle(const char*, HANDLE);
|
||||
extern int input_read_line(const char* pfx, char* buffer, int size);
|
||||
extern int input_fetch_entire_line(const char* pfx, char** line);
|
||||
extern HANDLE WINAPIV parser_generate_command_file(const char*, ...);
|
||||
|
@ -476,7 +476,7 @@ extern void dbg_del_thread(struct dbg_thread* t);
|
|||
extern BOOL dbg_init(HANDLE hProc, const WCHAR* in, BOOL invade);
|
||||
extern BOOL dbg_load_module(HANDLE hProc, HANDLE hFile, const WCHAR* name, DWORD_PTR base, DWORD size);
|
||||
extern void dbg_set_option(const char*, const char*);
|
||||
extern void dbg_start_interactive(HANDLE hFile);
|
||||
extern void dbg_start_interactive(const char*, HANDLE hFile);
|
||||
extern void dbg_init_console(void);
|
||||
|
||||
/* gdbproxy.c */
|
||||
|
|
|
@ -865,7 +865,7 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
|
|||
case ID_DEBUG:
|
||||
AllocConsole();
|
||||
dbg_init_console();
|
||||
dbg_start_interactive(INVALID_HANDLE_VALUE);
|
||||
dbg_start_interactive(NULL, INVALID_HANDLE_VALUE);
|
||||
return start_ok;
|
||||
case ID_DETAILS:
|
||||
event = CreateEventW( NULL, TRUE, FALSE, NULL );
|
||||
|
@ -882,7 +882,7 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
|
|||
dbg_active_wait_for_first_exception();
|
||||
|
||||
dbg_interactiveP = TRUE;
|
||||
parser_handle(input);
|
||||
parser_handle(NULL, input);
|
||||
output_system_info();
|
||||
|
||||
if (output != INVALID_HANDLE_VALUE)
|
||||
|
@ -963,7 +963,7 @@ enum dbg_start dbg_active_minidump(int argc, char* argv[])
|
|||
dbg_active_wait_for_first_exception();
|
||||
|
||||
dbg_interactiveP = TRUE;
|
||||
parser_handle(hFile);
|
||||
parser_handle(NULL, hFile);
|
||||
|
||||
return start_ok;
|
||||
}
|
||||
|
|
|
@ -562,7 +562,7 @@ static int dbg_winedbg_usage(BOOL advanced)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void dbg_start_interactive(HANDLE hFile)
|
||||
void dbg_start_interactive(const char* filename, HANDLE hFile)
|
||||
{
|
||||
struct dbg_process* p;
|
||||
struct dbg_process* p2;
|
||||
|
@ -574,7 +574,7 @@ void dbg_start_interactive(HANDLE hFile)
|
|||
}
|
||||
|
||||
dbg_interactiveP = TRUE;
|
||||
parser_handle(hFile);
|
||||
parser_handle(filename, hFile);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(p, p2, &dbg_process_list, struct dbg_process, entry)
|
||||
p->process_io->close_process(p, FALSE);
|
||||
|
@ -624,6 +624,7 @@ int main(int argc, char** argv)
|
|||
int retv = 0;
|
||||
HANDLE hFile = INVALID_HANDLE_VALUE;
|
||||
enum dbg_start ds;
|
||||
const char* filename = NULL;
|
||||
|
||||
/* Initialize the output */
|
||||
dbg_houtput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -688,6 +689,7 @@ int main(int argc, char** argv)
|
|||
if (!strcmp(argv[0], "--file") && argc > 1)
|
||||
{
|
||||
argc--; argv++;
|
||||
filename = argv[0];
|
||||
hFile = CreateFileA(argv[0], GENERIC_READ|DELETE, 0,
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
|
@ -718,7 +720,7 @@ int main(int argc, char** argv)
|
|||
|
||||
restart_if_wow64();
|
||||
|
||||
dbg_start_interactive(hFile);
|
||||
dbg_start_interactive(filename, hFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue