Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ac7be1e9
Commit
ac7be1e9
authored
Feb 24, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Feb 27, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winedbg: Active and command line.
- move process attachment and process creation (related to command line handling) from winedbg.c to tgt_active.c - tidy up argument parsing
parent
f16f847c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
91 deletions
+123
-91
debugger.h
programs/winedbg/debugger.h
+4
-2
tgt_active.c
programs/winedbg/tgt_active.c
+93
-2
winedbg.c
programs/winedbg/winedbg.c
+26
-87
No files found.
programs/winedbg/debugger.h
View file @
ac7be1e9
...
...
@@ -257,6 +257,8 @@ struct type_expr_t
}
u
;
};
enum
dbg_start
{
start_ok
,
start_error_parse
,
start_error_init
};
/* break.c */
extern
void
break_set_xpoints
(
BOOL
set
);
extern
BOOL
break_add_break
(
const
ADDRESS
*
addr
,
BOOL
verbose
,
BOOL
swbp
);
...
...
@@ -368,11 +370,11 @@ extern BOOL symbol_is_local(const char* name);
/* tgt_active.c */
extern
void
dbg_run_debuggee
(
const
char
*
args
);
extern
void
dbg_wait_next_exception
(
DWORD
cont
,
int
count
,
int
mode
);
extern
enum
dbg_start
dbg_active_attach
(
int
argc
,
char
*
argv
[]);
extern
enum
dbg_start
dbg_active_launch
(
int
argc
,
char
*
argv
[]);
/* temporary for tgt_active.c */
extern
enum
dbg_action_mode
{
none_mode
=
0
,
winedbg_mode
,
automatic_mode
,
gdb_mode
}
dbg_action_mode
;
extern
char
*
dbg_last_cmd_line
;
extern
unsigned
dbg_main_loop
(
HANDLE
);
extern
unsigned
dbg_start_debuggee
(
LPSTR
cmdLine
);
/* tgt_minidump.c */
extern
void
minidump_write
(
const
char
*
,
const
EXCEPTION_RECORD
*
);
...
...
programs/winedbg/tgt_active.c
View file @
ac7be1e9
...
...
@@ -32,7 +32,7 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
winedbg
);
/*static*/
char
*
dbg_last_cmd_line
=
NULL
;
static
char
*
dbg_last_cmd_line
;
/*static*/
enum
dbg_action_mode
dbg_action_mode
;
struct
be_process_io
be_process_active_io
=
...
...
@@ -711,7 +711,7 @@ void dbg_wait_next_exception(DWORD cont, int count, int mode)
return
0
;
}
/*static*/
unsigned
dbg_start_debuggee
(
LPSTR
cmdLine
)
static
unsigned
dbg_start_debuggee
(
LPSTR
cmdLine
)
{
PROCESS_INFORMATION
info
;
STARTUPINFOA
startup
;
...
...
@@ -781,3 +781,94 @@ void dbg_run_debuggee(const char* args)
}
}
static
BOOL
str2int
(
const
char
*
str
,
DWORD
*
val
)
{
char
*
ptr
;
*
val
=
strtol
(
str
,
&
ptr
,
10
);
return
str
<
ptr
&&
!*
ptr
;
}
/******************************************************************
* dbg_active_attach
*
* Tries to attach to a running process
* Handles the <pid> or <pid> <evt> forms
*/
enum
dbg_start
dbg_active_attach
(
int
argc
,
char
*
argv
[])
{
DWORD
pid
,
evt
;
/* try the form <myself> pid */
if
(
argc
==
1
&&
str2int
(
argv
[
0
],
&
pid
)
&&
pid
!=
0
)
{
if
(
dbg_attach_debuggee
(
pid
,
FALSE
,
FALSE
))
{
dbg_curr_pid
=
pid
;
return
start_ok
;
}
return
start_error_init
;
}
/* try the form <myself> pid evt (Win32 JIT debugger) */
if
(
argc
==
2
&&
str2int
(
argv
[
0
],
&
pid
)
&&
pid
!=
0
&&
str2int
(
argv
[
1
],
&
evt
)
&&
evt
!=
0
)
{
if
(
!
dbg_attach_debuggee
(
pid
,
TRUE
,
FALSE
))
{
/* don't care about result */
SetEvent
((
HANDLE
)
evt
);
return
start_error_init
;
}
if
(
!
SetEvent
((
HANDLE
)
evt
))
{
WINE_ERR
(
"Invalid event handle: %lx
\n
"
,
evt
);
return
start_error_init
;
}
CloseHandle
((
HANDLE
)
evt
);
dbg_curr_pid
=
pid
;
return
start_ok
;
}
return
start_error_parse
;
}
/******************************************************************
* dbg_active_launch
*
* Launches a debuggee (with its arguments) from argc/argv
*/
enum
dbg_start
dbg_active_launch
(
int
argc
,
char
*
argv
[])
{
int
i
,
len
;
LPSTR
cmd_line
;
if
(
argc
==
0
)
return
start_error_parse
;
if
(
!
(
cmd_line
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
=
1
)))
{
oom_leave:
dbg_printf
(
"Out of memory
\n
"
);
return
start_error_init
;
}
cmd_line
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
len
+=
strlen
(
argv
[
i
])
+
1
;
if
(
!
(
cmd_line
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
cmd_line
,
len
)))
goto
oom_leave
;
strcat
(
cmd_line
,
argv
[
i
]);
cmd_line
[
len
-
2
]
=
' '
;
cmd_line
[
len
-
1
]
=
'\0'
;
}
if
(
!
dbg_start_debuggee
(
cmd_line
))
{
HeapFree
(
GetProcessHeap
(),
0
,
cmd_line
);
return
start_error_init
;
}
HeapFree
(
GetProcessHeap
(),
0
,
dbg_last_cmd_line
);
dbg_last_cmd_line
=
cmd_line
;
return
start_ok
;
}
programs/winedbg/winedbg.c
View file @
ac7be1e9
...
...
@@ -481,10 +481,13 @@ int main(int argc, char** argv)
/* Initialize internal vars */
if
(
!
dbg_load_internal_vars
())
return
-
1
;
/* as we don't care about exec name */
argc
--
;
argv
++
;
/* parse options */
while
(
argc
>
1
&&
argv
[
1
][
0
]
==
'-'
)
while
(
argc
>
0
&&
argv
[
0
][
0
]
==
'-'
)
{
if
(
!
strcmp
(
argv
[
1
],
"--command"
))
if
(
!
strcmp
(
argv
[
0
],
"--command"
))
{
char
path
[
MAX_PATH
],
file
[
MAX_PATH
];
DWORD
w
;
...
...
@@ -499,27 +502,27 @@ int main(int argc, char** argv)
dbg_printf
(
"Couldn't open temp file %s (%lu)
\n
"
,
file
,
GetLastError
());
return
1
;
}
WriteFile
(
hFile
,
argv
[
1
],
strlen
(
argv
[
1
]),
&
w
,
0
);
WriteFile
(
hFile
,
argv
[
0
],
strlen
(
argv
[
0
]),
&
w
,
0
);
WriteFile
(
hFile
,
"
\n
quit
\n
"
,
6
,
&
w
,
0
);
SetFilePointer
(
hFile
,
0
,
NULL
,
FILE_BEGIN
);
argc
--
;
argv
++
;
continue
;
}
if
(
!
strcmp
(
argv
[
1
],
"--file"
))
if
(
!
strcmp
(
argv
[
0
],
"--file"
))
{
argc
--
;
argv
++
;
hFile
=
CreateFileA
(
argv
[
1
],
GENERIC_READ
|
DELETE
,
0
,
hFile
=
CreateFileA
(
argv
[
0
],
GENERIC_READ
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
{
dbg_printf
(
"Couldn't open file %s (%lu)
\n
"
,
argv
[
1
],
GetLastError
());
dbg_printf
(
"Couldn't open file %s (%lu)
\n
"
,
argv
[
0
],
GetLastError
());
return
1
;
}
argc
--
;
argv
++
;
continue
;
}
if
(
!
strcmp
(
argv
[
1
],
"--auto"
))
if
(
!
strcmp
(
argv
[
0
],
"--auto"
))
{
if
(
dbg_action_mode
!=
none_mode
)
return
dbg_winedbg_usage
();
dbg_action_mode
=
automatic_mode
;
...
...
@@ -529,109 +532,45 @@ int main(int argc, char** argv)
dbg_houtput
=
GetStdHandle
(
STD_ERROR_HANDLE
);
continue
;
}
if
(
!
strcmp
(
argv
[
1
],
"--gdb"
))
if
(
!
strcmp
(
argv
[
0
],
"--gdb"
))
{
if
(
dbg_action_mode
!=
none_mode
)
return
dbg_winedbg_usage
();
dbg_action_mode
=
gdb_mode
;
argc
--
;
argv
++
;
continue
;
}
if
(
strcmp
(
argv
[
1
],
"--no-start"
)
==
0
&&
dbg_action_mode
==
gdb_mode
)
if
(
strcmp
(
argv
[
0
],
"--no-start"
)
==
0
&&
dbg_action_mode
==
gdb_mode
)
{
gdb_flags
|=
1
;
argc
--
;
argv
++
;
/* as we don't use argv[0] */
argc
--
;
argv
++
;
continue
;
}
if
(
strcmp
(
argv
[
1
],
"--with-xterm"
)
==
0
&&
dbg_action_mode
==
gdb_mode
)
if
(
strcmp
(
argv
[
0
],
"--with-xterm"
)
==
0
&&
dbg_action_mode
==
gdb_mode
)
{
gdb_flags
|=
2
;
argc
--
;
argv
++
;
/* as we don't use argv[0] */
argc
--
;
argv
++
;
continue
;
}
return
dbg_winedbg_usage
();
}
if
(
dbg_action_mode
==
none_mode
)
dbg_action_mode
=
winedbg_mode
;
/* try the form <myself> pid */
if
(
dbg_curr_pid
==
0
&&
argc
==
2
)
if
(
!
argc
||
dbg_active_attach
(
argc
,
argv
)
==
start_ok
||
dbg_active_launch
(
argc
,
argv
)
==
start_ok
)
{
char
*
ptr
;
/* don't save local vars in gdb mode */
if
(
dbg_action_mode
==
gdb_mode
&&
dbg_curr_pid
)
return
gdb_remote
(
gdb_flags
);
dbg_curr_pid
=
strtol
(
argv
[
1
],
&
ptr
,
10
);
if
(
dbg_curr_pid
==
0
||
ptr
!=
argv
[
1
]
+
strlen
(
argv
[
1
])
||
!
dbg_attach_debuggee
(
dbg_curr_pid
,
FALSE
,
FALSE
))
dbg_curr_pid
=
0
;
}
dbg_init_console
();
/* try the form <myself> pid evt (Win32 JIT debugger) */
if
(
dbg_curr_pid
==
0
&&
argc
==
3
)
{
HANDLE
hEvent
;
DWORD
pid
;
char
*
ptr
;
SymSetOptions
((
SymGetOptions
()
&
~
(
SYMOPT_UNDNAME
))
|
SYMOPT_LOAD_LINES
|
SYMOPT_DEFERRED_LOADS
|
SYMOPT_AUTO_PUBLICS
);
if
((
pid
=
strtol
(
argv
[
1
],
&
ptr
,
10
))
!=
0
&&
ptr
!=
NULL
&&
(
hEvent
=
(
HANDLE
)
strtol
(
argv
[
2
],
&
ptr
,
10
))
!=
0
&&
ptr
!=
NULL
)
{
if
(
!
dbg_attach_debuggee
(
pid
,
TRUE
,
FALSE
))
{
/* don't care about result */
SetEvent
(
hEvent
);
goto
leave
;
}
if
(
!
SetEvent
(
hEvent
))
{
WINE_ERR
(
"Invalid event handle: %p
\n
"
,
hEvent
);
goto
leave
;
}
CloseHandle
(
hEvent
);
dbg_curr_pid
=
pid
;
}
retv
=
dbg_main_loop
(
hFile
);
/* don't save modified variables in auto mode */
if
(
dbg_action_mode
!=
automatic_mode
)
dbg_save_internal_vars
();
}
if
(
dbg_curr_pid
==
0
&&
argc
>
1
)
{
int
i
,
len
;
LPSTR
cmdLine
;
if
(
!
(
cmdLine
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
=
1
)))
goto
oom_leave
;
cmdLine
[
0
]
=
'\0'
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
len
+=
strlen
(
argv
[
i
])
+
1
;
if
(
!
(
cmdLine
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
cmdLine
,
len
)))
goto
oom_leave
;
strcat
(
cmdLine
,
argv
[
i
]);
cmdLine
[
len
-
2
]
=
' '
;
cmdLine
[
len
-
1
]
=
'\0'
;
}
if
(
!
dbg_start_debuggee
(
cmdLine
))
{
dbg_printf
(
"Couldn't start process '%s'
\n
"
,
cmdLine
);
goto
leave
;
}
dbg_last_cmd_line
=
cmdLine
;
}
/* don't save local vars in gdb mode */
if
(
dbg_action_mode
==
gdb_mode
&&
dbg_curr_pid
)
return
gdb_remote
(
gdb_flags
);
dbg_init_console
();
SymSetOptions
((
SymGetOptions
()
&
~
(
SYMOPT_UNDNAME
))
|
SYMOPT_LOAD_LINES
|
SYMOPT_DEFERRED_LOADS
|
SYMOPT_AUTO_PUBLICS
);
retv
=
dbg_main_loop
(
hFile
);
/* don't save modified variables in auto mode */
if
(
dbg_action_mode
!=
automatic_mode
)
dbg_save_internal_vars
();
leave:
return
retv
;
oom_leave:
dbg_printf
(
"Out of memory
\n
"
);
return
retv
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment