1 /* Wine internal debugger
2 * Interface to Windows debugger API
3 * Copyright 2000-2004 Eric Pouech
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/debug.h"
31 * + ensure that all commands work as expected in minidump reload function
32 * (and re-enable parser usage)
34 * + we always assume the stack grows as on i386 (i.e. downwards)
36 * + re-enable the limited output (depth of structure printing and number of
38 * + make the output as close as possible to what gdb does
39 * - symbol management:
40 * + symbol table loading is broken
41 * + in symbol_get_lvalue, we don't do any scoping (as C does) between local and
42 * global vars (we may need this to force some display for example). A solution
43 * would be always to return arrays with: local vars, global vars, thunks
45 * + some bits of internal types are missing (like type casts and the address
47 * + all computations should be made on 64bit
48 * o bitfield spreading on more bytes than dbg_lgint_t isn't supported
49 * (can happen on 128bit integers, of an ELF build...)
51 * + set a better fix for gdb (proxy mode) than the step-mode hack
52 * + implement function call in debuggee
53 * + trampoline management is broken when getting 16 <=> 32 thunk destination
55 * + thunking of delayed imports doesn't work as expected (ie, when stepping,
56 * it currently stops at first insn with line number during the library
57 * loading). We should identify this (__wine_delay_import) and set a
58 * breakpoint instead of single stepping the library loading.
59 * + it's wrong to copy thread->step_over_bp into process->bp[0] (when
60 * we have a multi-thread debuggee). complete fix must include storing all
61 * thread's step-over bp in process-wide bp array, and not to handle bp
62 * when we have the wrong thread running into that bp
63 * + code in CREATE_PROCESS debug event doesn't work on Windows, as we cannot
64 * get the name of the main module this way. We should rewrite all this code
65 * and store in struct dbg_process as early as possible (before process
66 * creation or attachment), the name of the main module
68 * + define a better way to enable the wine extensions (either DBG SDK function
69 * in dbghelp, or TLS variable, or environment variable or ...)
70 * + audit all files to ensure that we check all potential return values from
71 * every function call to catch the errors
72 * + BTW check also whether the exception mechanism is the best way to return
73 * errors (or find a proper fix for MinGW port)
76 WINE_DEFAULT_DEBUG_CHANNEL(winedbg
);
78 struct dbg_process
* dbg_curr_process
= NULL
;
79 struct dbg_thread
* dbg_curr_thread
= NULL
;
80 DWORD dbg_curr_tid
= 0;
81 DWORD dbg_curr_pid
= 0;
82 dbg_ctx_t dbg_context
;
83 BOOL dbg_interactiveP
= FALSE
;
84 HANDLE dbg_houtput
= 0;
86 static struct list dbg_process_list
= LIST_INIT(dbg_process_list
);
88 struct dbg_internal_var dbg_internal_vars
[DBG_IV_LAST
];
90 static void dbg_outputA(const char* buffer
, int len
)
92 static char line_buff
[4096];
93 static unsigned int line_pos
;
99 unsigned int count
= min( len
, sizeof(line_buff
) - line_pos
);
100 memcpy( line_buff
+ line_pos
, buffer
, count
);
104 for (i
= line_pos
; i
> 0; i
--) if (line_buff
[i
-1] == '\n') break;
105 if (!i
) /* no newline found */
107 if (len
> 0) i
= line_pos
; /* buffer is full, flush anyway */
110 WriteFile(dbg_houtput
, line_buff
, i
, &w
, NULL
);
111 memmove( line_buff
, line_buff
+ i
, line_pos
- i
);
116 int WINAPIV
dbg_printf(const char* format
, ...)
118 static char buf
[4*1024];
122 va_start(valist
, format
);
123 len
= vsnprintf(buf
, sizeof(buf
), format
, valist
);
126 if (len
<= -1 || len
>= sizeof(buf
))
128 len
= sizeof(buf
) - 1;
130 buf
[len
- 1] = buf
[len
- 2] = buf
[len
- 3] = '.';
132 dbg_outputA(buf
, len
);
136 static unsigned dbg_load_internal_vars(void)
139 DWORD type
= REG_DWORD
;
141 DWORD count
= sizeof(val
);
143 struct dbg_internal_var
* div
= dbg_internal_vars
;
145 /* initializes internal vars table */
146 #define INTERNAL_VAR(_var,_val,_ref,_tid) \
147 div->val = _val; div->name = #_var; div->pval = _ref; \
148 div->typeid = _tid; div++;
152 /* @@ Wine registry key: HKCU\Software\Wine\WineDbg */
153 if (RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\WineDbg", &hkey
))
155 WINE_ERR("Cannot create WineDbg key in registry\n");
159 for (i
= 0; i
< DBG_IV_LAST
; i
++)
161 if (!dbg_internal_vars
[i
].pval
)
163 if (!RegQueryValueExA(hkey
, dbg_internal_vars
[i
].name
, 0,
164 &type
, (LPBYTE
)&val
, &count
))
165 dbg_internal_vars
[i
].val
= val
;
166 dbg_internal_vars
[i
].pval
= &dbg_internal_vars
[i
].val
;
174 static unsigned dbg_save_internal_vars(void)
179 /* @@ Wine registry key: HKCU\Software\Wine\WineDbg */
180 if (RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\WineDbg", &hkey
))
182 WINE_ERR("Cannot create WineDbg key in registry\n");
186 for (i
= 0; i
< DBG_IV_LAST
; i
++)
188 /* FIXME: type should be inferred from basic type -if any- of intvar */
189 if (dbg_internal_vars
[i
].pval
== &dbg_internal_vars
[i
].val
)
191 DWORD val
= dbg_internal_vars
[i
].val
;
192 RegSetValueExA(hkey
, dbg_internal_vars
[i
].name
, 0, REG_DWORD
, (BYTE
*)&val
, sizeof(val
));
199 const struct dbg_internal_var
* dbg_get_internal_var(const char* name
)
201 const struct dbg_internal_var
* div
;
203 for (div
= &dbg_internal_vars
[DBG_IV_LAST
- 1]; div
>= dbg_internal_vars
; div
--)
205 if (!strcmp(div
->name
, name
)) return div
;
207 for (div
= dbg_curr_process
->be_cpu
->context_vars
; div
->name
; div
++)
209 if (!strcasecmp(div
->name
, name
))
211 struct dbg_internal_var
* ret
= (void*)lexeme_alloc_size(sizeof(*ret
));
212 /* relocate register's field against current context */
214 ret
->pval
= (char*)&dbg_context
+ (DWORD_PTR
)div
->pval
;
222 unsigned dbg_num_processes(void)
224 return list_count(&dbg_process_list
);
227 struct dbg_process
* dbg_get_process(DWORD pid
)
229 struct dbg_process
* p
;
231 LIST_FOR_EACH_ENTRY(p
, &dbg_process_list
, struct dbg_process
, entry
)
232 if (p
->pid
== pid
) return p
;
236 struct dbg_process
* dbg_get_process_h(HANDLE h
)
238 struct dbg_process
* p
;
240 LIST_FOR_EACH_ENTRY(p
, &dbg_process_list
, struct dbg_process
, entry
)
241 if (p
->handle
== h
) return p
;
246 extern struct backend_cpu be_i386
;
247 #elif defined(__x86_64__)
248 extern struct backend_cpu be_i386
;
249 extern struct backend_cpu be_x86_64
;
250 #elif defined(__arm__) && !defined(__ARMEB__)
251 extern struct backend_cpu be_arm
;
252 #elif defined(__aarch64__) && !defined(__AARCH64EB__)
253 extern struct backend_cpu be_arm64
;
258 struct dbg_process
* dbg_add_process(const struct be_process_io
* pio
, DWORD pid
, HANDLE h
)
260 struct dbg_process
* p
;
263 if ((p
= dbg_get_process(pid
)))
267 h
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
269 if (!IsWow64Process(h
, &wow64
)) wow64
= FALSE
;
271 if (!(p
= malloc(sizeof(struct dbg_process
)))) return NULL
;
277 list_init(&p
->threads
);
278 list_init(&p
->modules
);
279 p
->event_on_first_exception
= NULL
;
280 p
->active_debuggee
= FALSE
;
282 p
->next_bp
= 1; /* breakpoint 0 is reserved for step-over */
283 memset(p
->bp
, 0, sizeof(p
->bp
));
284 p
->delayed_bp
= NULL
;
285 p
->num_delayed_bp
= 0;
286 p
->source_ofiles
= NULL
;
287 p
->search_path
= NULL
;
288 p
->source_current_file
[0] = '\0';
289 p
->source_start_line
= -1;
290 p
->source_end_line
= -1;
291 p
->data_model
= NULL
;
292 p
->synthetized_types
= NULL
;
293 p
->num_synthetized_types
= 0;
295 list_add_head(&dbg_process_list
, &p
->entry
);
298 p
->be_cpu
= &be_i386
;
299 #elif defined(__x86_64__)
300 p
->be_cpu
= wow64
? &be_i386
: &be_x86_64
;
301 #elif defined(__arm__) && !defined(__ARMEB__)
303 #elif defined(__aarch64__) && !defined(__AARCH64EB__)
304 p
->be_cpu
= &be_arm64
;
311 void dbg_set_process_name(struct dbg_process
* p
, const WCHAR
* imageName
)
313 assert(p
->imageName
== NULL
);
314 if (imageName
) p
->imageName
= wcsdup(imageName
);
317 void dbg_del_process(struct dbg_process
* p
)
319 struct dbg_thread
* t
;
320 struct dbg_thread
* t2
;
321 struct dbg_module
* mod
;
322 struct dbg_module
* mod2
;
325 LIST_FOR_EACH_ENTRY_SAFE(t
, t2
, &p
->threads
, struct dbg_thread
, entry
)
328 LIST_FOR_EACH_ENTRY_SAFE(mod
, mod2
, &p
->modules
, struct dbg_module
, entry
)
331 for (i
= 0; i
< p
->num_delayed_bp
; i
++)
332 if (p
->delayed_bp
[i
].is_symbol
)
333 free(p
->delayed_bp
[i
].u
.symbol
.name
);
337 source_free_files(p
);
338 list_remove(&p
->entry
);
339 if (p
== dbg_curr_process
) dbg_curr_process
= NULL
;
340 if (p
->event_on_first_exception
) CloseHandle(p
->event_on_first_exception
);
341 free((char*)p
->imageName
);
342 free(p
->synthetized_types
);
346 /******************************************************************
349 * Initializes the dbghelp library, and also sets the application directory
350 * as a place holder for symbol searches.
352 BOOL
dbg_init(HANDLE hProc
, const WCHAR
* in
, BOOL invade
)
356 ret
= SymInitialize(hProc
, NULL
, invade
);
361 for (last
= in
+ lstrlenW(in
) - 1; last
>= in
; last
--)
363 if (*last
== '/' || *last
== '\\')
366 tmp
= malloc((1024 + 1 + (last
- in
) + 1) * sizeof(WCHAR
));
367 if (tmp
&& SymGetSearchPathW(hProc
, tmp
, 1024))
369 WCHAR
* x
= tmp
+ lstrlenW(tmp
);
372 memcpy(x
, in
, (last
- in
) * sizeof(WCHAR
));
374 ret
= SymSetSearchPathW(hProc
, tmp
);
385 BOOL
dbg_load_module(HANDLE hProc
, HANDLE hFile
, const WCHAR
* name
, DWORD_PTR base
, DWORD size
)
387 struct dbg_process
* pcs
= dbg_get_process_h(hProc
);
388 struct dbg_module
* mod
;
389 IMAGEHLP_MODULEW64 info
;
393 if (!pcs
) return FALSE
;
394 mod
= malloc(sizeof(struct dbg_module
));
395 if (!mod
) return FALSE
;
396 if (!SymLoadModuleExW(hProc
, hFile
, name
, NULL
, base
, size
, NULL
, 0))
402 list_add_head(&pcs
->modules
, &mod
->entry
);
404 mod
->tls_index_offset
= 0;
405 if ((hMap
= CreateFileMappingW(hFile
, NULL
, PAGE_READONLY
, 0, 0, NULL
)))
407 if ((image
= MapViewOfFile(hMap
, FILE_MAP_READ
, 0, 0, 0)))
409 IMAGE_NT_HEADERS
* nth
= RtlImageNtHeader(image
);
413 tlsdir
= RtlImageDirectoryEntryToData(image
, TRUE
, IMAGE_DIRECTORY_ENTRY_TLS
, &sz
);
414 switch (nth
->OptionalHeader
.Magic
)
416 case IMAGE_NT_OPTIONAL_HDR32_MAGIC
:
417 if (tlsdir
&& sz
>= sizeof(IMAGE_TLS_DIRECTORY32
))
418 mod
->tls_index_offset
= (const char*)tlsdir
- (const char*)image
+
419 offsetof(IMAGE_TLS_DIRECTORY32
, AddressOfIndex
);
421 case IMAGE_NT_OPTIONAL_HDR64_MAGIC
:
422 if (tlsdir
&& sz
>= sizeof(IMAGE_TLS_DIRECTORY64
))
423 mod
->tls_index_offset
= (const char*)tlsdir
- (const char*)image
+
424 offsetof(IMAGE_TLS_DIRECTORY64
, AddressOfIndex
);
427 UnmapViewOfFile(image
);
431 info
.SizeOfStruct
= sizeof(info
);
432 if (SymGetModuleInfoW64(hProc
, base
, &info
))
433 if (info
.PdbUnmatched
|| info
.DbgUnmatched
)
434 dbg_printf("Loaded unmatched debug information for %s\n", wine_dbgstr_w(name
));
439 void dbg_del_module(struct dbg_module
* mod
)
441 list_remove(&mod
->entry
);
445 struct dbg_module
* dbg_get_module(struct dbg_process
* pcs
, DWORD_PTR base
)
447 struct dbg_module
* mod
;
451 LIST_FOR_EACH_ENTRY(mod
, &pcs
->modules
, struct dbg_module
, entry
)
452 if (mod
->base
== base
)
457 BOOL
dbg_unload_module(struct dbg_process
* pcs
, DWORD_PTR base
)
459 struct dbg_module
* mod
= dbg_get_module(pcs
, base
);
461 types_unload_module(pcs
, base
);
462 SymUnloadModule64(pcs
->handle
, base
);
468 struct dbg_thread
* dbg_get_thread(struct dbg_process
* p
, DWORD tid
)
470 struct dbg_thread
* t
;
473 LIST_FOR_EACH_ENTRY(t
, &p
->threads
, struct dbg_thread
, entry
)
474 if (t
->tid
== tid
) return t
;
478 struct dbg_thread
* dbg_add_thread(struct dbg_process
* p
, DWORD tid
,
481 struct dbg_thread
* t
= malloc(sizeof(struct dbg_thread
));
490 t
->exec_mode
= dbg_exec_cont
;
492 t
->step_over_bp
.enabled
= FALSE
;
493 t
->step_over_bp
.refcount
= 0;
494 t
->stopped_xpoint
= -1;
496 t
->in_exception
= FALSE
;
500 t
->addr_mode
= AddrModeFlat
;
501 t
->suspended
= FALSE
;
503 list_add_head(&p
->threads
, &t
->entry
);
508 void dbg_del_thread(struct dbg_thread
* t
)
511 list_remove(&t
->entry
);
512 if (t
== dbg_curr_thread
) dbg_curr_thread
= NULL
;
516 void dbg_set_option(const char* option
, const char* val
)
518 if (!strcasecmp(option
, "module_load_mismatched"))
520 DWORD opt
= SymGetOptions();
522 dbg_printf("Option: module_load_mismatched %s\n", opt
& SYMOPT_LOAD_ANYTHING
? "true" : "false");
523 else if (!strcasecmp(val
, "true")) opt
|= SYMOPT_LOAD_ANYTHING
;
524 else if (!strcasecmp(val
, "false")) opt
&= ~SYMOPT_LOAD_ANYTHING
;
527 dbg_printf("Syntax: module_load_mismatched [true|false]\n");
532 else if (!strcasecmp(option
, "symbol_picker"))
535 dbg_printf("Option: symbol_picker %s\n",
536 symbol_current_picker
== symbol_picker_interactive
? "interactive" : "scoped");
537 else if (!strcasecmp(val
, "interactive"))
538 symbol_current_picker
= symbol_picker_interactive
;
539 else if (!strcasecmp(val
, "scoped"))
540 symbol_current_picker
= symbol_picker_scoped
;
543 dbg_printf("Syntax: symbol_picker [interactive|scoped]\n");
547 else if (!strcasecmp(option
, "data_model"))
549 if (!dbg_curr_process
)
551 dbg_printf("Not attached to a process\n");
556 const char* model
= "";
557 if (dbg_curr_process
->data_model
== NULL
) model
= "auto";
558 else if (dbg_curr_process
->data_model
== ilp32_data_model
) model
= "ilp32";
559 else if (dbg_curr_process
->data_model
== llp64_data_model
) model
= "llp64";
560 else if (dbg_curr_process
->data_model
== lp64_data_model
) model
= "lp64";
561 dbg_printf("Option: data_model %s\n", model
);
563 else if (!strcasecmp(val
, "auto")) dbg_curr_process
->data_model
= NULL
;
564 else if (!strcasecmp(val
, "ilp32")) dbg_curr_process
->data_model
= ilp32_data_model
;
565 else if (!strcasecmp(val
, "llp64")) dbg_curr_process
->data_model
= llp64_data_model
;
566 else if (!strcasecmp(val
, "lp64")) dbg_curr_process
->data_model
= lp64_data_model
;
568 dbg_printf("Unknown data model %s\n", val
);
570 else dbg_printf("Unknown option '%s'\n", option
);
573 BOOL
dbg_interrupt_debuggee(void)
575 struct dbg_process
* p
;
576 if (list_empty(&dbg_process_list
)) return FALSE
;
577 /* FIXME: since we likely have a single process, signal the first process
580 p
= LIST_ENTRY(list_head(&dbg_process_list
), struct dbg_process
, entry
);
581 if (list_next(&dbg_process_list
, &p
->entry
)) dbg_printf("Ctrl-C: only stopping the first process\n");
582 else dbg_printf("Ctrl-C: stopping debuggee\n");
583 if (p
->event_on_first_exception
)
585 SetEvent(p
->event_on_first_exception
);
586 CloseHandle(p
->event_on_first_exception
);
587 p
->event_on_first_exception
= NULL
;
589 return DebugBreakProcess(p
->handle
);
592 static BOOL WINAPI
ctrl_c_handler(DWORD dwCtrlType
)
594 if (dwCtrlType
== CTRL_C_EVENT
)
596 return dbg_interrupt_debuggee();
601 void dbg_init_console(void)
603 /* set the output handle */
604 dbg_houtput
= GetStdHandle(STD_OUTPUT_HANDLE
);
606 /* set our control-C handler */
607 SetConsoleCtrlHandler(ctrl_c_handler
, TRUE
);
609 /* set our own title */
610 SetConsoleTitleA("Wine Debugger");
613 static int dbg_winedbg_usage(BOOL advanced
)
617 dbg_printf("Usage:\n"
618 " winedbg <cmdline> launch process <cmdline> (as if you were starting\n"
619 " it with wine) and run WineDbg on it\n"
620 " winedbg <num> attach to running process of wpid <num> and run\n"
622 " winedbg --gdb <cmdline> launch process <cmdline> (as if you were starting\n"
623 " wine) and run gdb (proxied) on it\n"
624 " winedbg --gdb <num> attach to running process of wpid <num> and run\n"
625 " gdb (proxied) on it\n"
626 " winedbg <file.mdmp> reload the minidump <file.mdmp> into memory and run\n"
628 " winedbg --help prints advanced options\n");
631 dbg_printf("Usage:\n\twinedbg [ [ --gdb ] [ <prog-name> [ <prog-args> ] | <num> | <file.mdmp> | --help ]\n");
635 void dbg_start_interactive(const char* filename
, HANDLE hFile
)
637 struct dbg_process
* p
;
638 struct dbg_process
* p2
;
640 if (dbg_curr_process
)
642 dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid
);
643 if (dbg_curr_process
->active_debuggee
) dbg_active_wait_for_first_exception();
646 dbg_interactiveP
= TRUE
;
647 parser_handle(filename
, hFile
);
649 LIST_FOR_EACH_ENTRY_SAFE(p
, p2
, &dbg_process_list
, struct dbg_process
, entry
)
650 p
->process_io
->close_process(p
, FALSE
);
652 dbg_save_internal_vars();
655 static LONG CALLBACK
top_filter( EXCEPTION_POINTERS
*ptr
)
657 dbg_printf( "winedbg: Internal crash at %p\n", ptr
->ExceptionRecord
->ExceptionAddress
);
658 return EXCEPTION_EXECUTE_HANDLER
;
661 static void restart_if_wow64(void)
665 if (IsWow64Process( GetCurrentProcess(), &is_wow64
) && is_wow64
)
668 PROCESS_INFORMATION pi
;
669 WCHAR filename
[MAX_PATH
];
673 memset( &si
, 0, sizeof(si
) );
675 GetSystemDirectoryW( filename
, MAX_PATH
);
676 lstrcatW( filename
, L
"\\winedbg.exe" );
678 Wow64DisableWow64FsRedirection( &redir
);
679 if (CreateProcessW( filename
, GetCommandLineW(), NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
681 WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename
) );
682 SetConsoleCtrlHandler( NULL
, TRUE
); /* Ignore ^C */
683 WaitForSingleObject( pi
.hProcess
, INFINITE
);
684 GetExitCodeProcess( pi
.hProcess
, &exit_code
);
685 ExitProcess( exit_code
);
687 else WINE_ERR( "failed to restart 64-bit %s, err %ld\n", wine_dbgstr_w(filename
), GetLastError() );
688 Wow64RevertWow64FsRedirection( redir
);
692 int main(int argc
, char** argv
)
695 HANDLE hFile
= INVALID_HANDLE_VALUE
;
697 const char* filename
= NULL
;
699 /* Initialize the output */
700 dbg_houtput
= GetStdHandle(STD_OUTPUT_HANDLE
);
702 SetUnhandledExceptionFilter( top_filter
);
704 /* Initialize internal vars */
705 if (!dbg_load_internal_vars()) return -1;
707 /* as we don't care about exec name */
710 if (argc
&& !strcmp(argv
[0], "--help"))
711 return dbg_winedbg_usage(TRUE
);
713 if (argc
&& !strcmp(argv
[0], "--gdb"))
716 retv
= gdb_main(argc
, argv
);
717 if (retv
== -1) dbg_winedbg_usage(FALSE
);
722 SymSetOptions((SymGetOptions() & ~(SYMOPT_UNDNAME
)) |
723 SYMOPT_LOAD_LINES
| SYMOPT_DEFERRED_LOADS
| SYMOPT_AUTO_PUBLICS
|
724 SYMOPT_INCLUDE_32BIT_MODULES
);
726 SymSetExtendedOption(SYMOPT_EX_WINE_SOURCE_ACTUAL_PATH
, TRUE
);
728 if (argc
&& !strcmp(argv
[0], "--auto"))
730 switch (dbg_active_auto(argc
, argv
))
732 case start_ok
: return 0;
733 case start_error_parse
: return dbg_winedbg_usage(FALSE
);
734 case start_error_init
: return -1;
737 if (argc
&& !strcmp(argv
[0], "--minidump"))
739 switch (dbg_active_minidump(argc
, argv
))
741 case start_ok
: return 0;
742 case start_error_parse
: return dbg_winedbg_usage(FALSE
);
743 case start_error_init
: return -1;
747 while (argc
> 0 && argv
[0][0] == '-')
749 if (!strcmp(argv
[0], "--command") && argc
> 1)
752 hFile
= parser_generate_command_file(argv
[0], NULL
);
753 if (hFile
== INVALID_HANDLE_VALUE
)
755 dbg_printf("Couldn't open temp file (%lu)\n", GetLastError());
761 if (!strcmp(argv
[0], "--file") && argc
> 1)
765 hFile
= CreateFileA(argv
[0], GENERIC_READ
|DELETE
, 0,
766 NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, 0);
767 if (hFile
== INVALID_HANDLE_VALUE
)
769 dbg_printf("Couldn't open file %s (%lu)\n", argv
[0], GetLastError());
775 if (!strcmp(argv
[0], "--"))
780 return dbg_winedbg_usage(FALSE
);
782 if (!argc
) ds
= start_ok
;
783 else if ((ds
= dbg_active_attach(argc
, argv
)) == start_error_parse
&&
784 (ds
= minidump_reload(argc
, argv
)) == start_error_parse
)
785 ds
= dbg_active_launch(argc
, argv
);
788 case start_ok
: break;
789 case start_error_parse
: return dbg_winedbg_usage(FALSE
);
790 case start_error_init
: return -1;
795 dbg_start_interactive(filename
, hFile
);