Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoann Laissus
wine
Commits
cbb7a172
Commit
cbb7a172
authored
25 years ago
by
Eric Pouech
Committed by
Alexandre Julliard
25 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added proc to start debugging process from its command line (by launching it).
parent
29d33a46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
debugger/winedbg.c
+69
-12
69 additions, 12 deletions
debugger/winedbg.c
miscemu/main.c
+14
-19
14 additions, 19 deletions
miscemu/main.c
with
83 additions
and
31 deletions
debugger/winedbg.c
+
69
−
12
View file @
cbb7a172
...
...
@@ -263,7 +263,7 @@ static BOOL DEBUG_HandleException( EXCEPTION_RECORD *rec, BOOL first_chance, BOO
DEBUG_CurrThread
->
dbg_exec_mode
,
DEBUG_CurrThread
->
dbg_exec_count
);
#endif
ret
=
DEBUG_Main
(
is_debug
,
force
);
ret
=
DEBUG_Main
(
is_debug
,
force
,
rec
->
ExceptionCode
);
#if 1
fprintf
(
stderr
,
"Exiting debugger PC=%lx EFL=%08lx mode=%d count=%d
\n
"
,
DEBUG_context
.
Eip
,
DEBUG_context
.
EFlags
,
...
...
@@ -273,18 +273,12 @@ static BOOL DEBUG_HandleException( EXCEPTION_RECORD *rec, BOOL first_chance, BOO
return
ret
;
}
static
DWORD
CALLBACK
DEBUG_MainLoop
(
LPVOID
pid
)
static
DWORD
CALLBACK
DEBUG_MainLoop
(
DWORD
pid
)
{
DEBUG_EVENT
de
;
char
buffer
[
256
];
DWORD
cont
;
TRACE
(
"WineDbg started on pid %ld
\n
"
,
(
DWORD
)
pid
);
if
(
!
DebugActiveProcess
((
DWORD
)
pid
))
TRACE
(
"Can't debug process %ld: %ld
\n
"
,
(
DWORD
)
pid
,
GetLastError
());
while
(
WaitForDebugEvent
(
&
de
,
INFINITE
))
{
cont
=
0L
;
...
...
@@ -463,17 +457,80 @@ static DWORD CALLBACK DEBUG_MainLoop(LPVOID pid)
ContinueDebugEvent
(
de
.
dwProcessId
,
de
.
dwThreadId
,
cont
);
}
TRACE
(
"WineDbg terminated on pid %ld
\n
"
,
(
DWORD
)
pid
);
TRACE
(
"WineDbg terminated on pid %ld
\n
"
,
pid
);
return
0L
;
}
#include
"thread.h"
#include
"process.h"
#include
"wingdi.h"
#include
"winuser.h"
static
DWORD
CALLBACK
DEBUG_StarterFromPID
(
LPVOID
pid
)
{
TRACE
(
"WineDbg started on pid %ld
\n
"
,
(
DWORD
)
pid
);
if
(
!
DebugActiveProcess
((
DWORD
)
pid
))
{
TRACE
(
"Can't debug process %ld: %ld
\n
"
,
(
DWORD
)
pid
,
GetLastError
());
return
0
;
}
return
DEBUG_MainLoop
((
DWORD
)
pid
);
}
void
DEBUG_
StartDebugger
(
DWORD
pid
)
void
DEBUG_
Attach
(
DWORD
pid
)
{
if
(
Options
.
debug
)
CreateThread
(
NULL
,
0
,
DEBUG_MainLoop
,
(
LPVOID
)
pid
,
0
,
NULL
);
CreateThread
(
NULL
,
0
,
DEBUG_StarterFromPID
,
(
LPVOID
)
pid
,
0
,
NULL
);
}
struct
dsfcl
{
HANDLE
hEvent
;
LPSTR
lpCmdLine
;
int
showWindow
;
DWORD
error
;
};
static
DWORD
CALLBACK
DEBUG_StarterFromCmdLine
(
LPVOID
p
)
{
PROCESS_INFORMATION
info
;
STARTUPINFOA
startup
;
BOOL
ok
=
TRUE
;
memset
(
&
startup
,
0
,
sizeof
(
startup
));
startup
.
cb
=
sizeof
(
startup
);
startup
.
dwFlags
=
STARTF_USESHOWWINDOW
;
startup
.
wShowWindow
=
((
struct
dsfcl
*
)
p
)
->
showWindow
;
/* any value >= 32 will do, simulate a correct handle value */
((
struct
dsfcl
*
)
p
)
->
error
=
0xFFFFFFFF
;
if
(
!
CreateProcessA
(
NULL
,
((
struct
dsfcl
*
)
p
)
->
lpCmdLine
,
NULL
,
NULL
,
FALSE
,
DEBUG_PROCESS
,
NULL
,
NULL
,
&
startup
,
&
info
))
{
((
struct
dsfcl
*
)
p
)
->
error
=
GetLastError
();
ok
=
FALSE
;
}
SetEvent
(((
struct
dsfcl
*
)
p
)
->
hEvent
);
if
(
ok
)
DEBUG_MainLoop
(
info
.
dwProcessId
);
return
0
;
}
DWORD
DEBUG_WinExec
(
LPSTR
lpCmdLine
,
int
sw
)
{
struct
dsfcl
s
;
BOOL
ret
;
if
((
s
.
hEvent
=
CreateEventA
(
NULL
,
FALSE
,
FALSE
,
NULL
)))
{
s
.
lpCmdLine
=
lpCmdLine
;
s
.
showWindow
=
sw
;
if
(
CreateThread
(
NULL
,
0
,
DEBUG_StarterFromCmdLine
,
(
LPVOID
)
&
s
,
0
,
NULL
))
{
WaitForSingleObject
(
s
.
hEvent
,
INFINITE
);
ret
=
s
.
error
;
}
else
{
ret
=
3
;
/* (dummy) error value for non created thread */
}
CloseHandle
(
s
.
hEvent
);
}
else
{
ret
=
1
;
/* (dummy) error value for non created event */
}
return
ret
;
}
This diff is collapsed.
Click to expand it.
miscemu/main.c
+
14
−
19
View file @
cbb7a172
...
...
@@ -21,7 +21,7 @@
static
int
MAIN_argc
;
static
char
**
MAIN_argv
;
extern
void
DEBUG_
StartDebugger
(
DWORD
);
extern
DWORD
DEBUG_
WinExec
(
LPSTR
lpCmdLine
,
int
sw
);
/***********************************************************************
* Main loop of initial task
...
...
@@ -29,6 +29,7 @@ extern void DEBUG_StartDebugger(DWORD);
void
MAIN_EmulatorRun
(
void
)
{
char
startProg
[
256
],
defProg
[
256
];
HINSTANCE
handle
;
int
i
,
tasks
=
0
;
MSG
msg
;
BOOL
err_msg
=
FALSE
;
...
...
@@ -70,31 +71,25 @@ void MAIN_EmulatorRun( void )
/* Load and run executables given on command line */
for
(
i
=
1
;
i
<
MAIN_argc
;
i
++
)
{
PROCESS_INFORMATION
info
;
STARTUPINFOA
startup
;
memset
(
&
startup
,
0
,
sizeof
(
startup
));
startup
.
cb
=
sizeof
(
startup
);
startup
.
dwFlags
=
STARTF_USESHOWWINDOW
;
startup
.
wShowWindow
=
SW_SHOWNORMAL
;
if
(
!
CreateProcessA
(
NULL
,
MAIN_argv
[
i
],
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
startup
,
&
info
))
{
if
(
Options
.
debug
)
{
handle
=
DEBUG_WinExec
(
MAIN_argv
[
i
],
SW_SHOWNORMAL
);
}
else
{
handle
=
WinExec
(
MAIN_argv
[
i
],
SW_SHOWNORMAL
);
}
if
(
handle
<
32
)
{
err_msg
=
TRUE
;
MESSAGE
(
"wine: can't exec '%s': "
,
MAIN_argv
[
i
]);
switch
(
GetLastError
()
)
switch
(
handle
)
{
case
2
:
MESSAGE
(
"file not found
\n
"
);
break
;
case
11
:
MESSAGE
(
"invalid exe file
\n
"
);
break
;
default:
MESSAGE
(
"error=%
l
d
\n
"
,
GetLastError
()
);
break
;
default:
MESSAGE
(
"error=%d
\n
"
,
handle
);
break
;
}
}
else
{
tasks
++
;
/* hack until wine debugger can be moved to a separate process */
DEBUG_StartDebugger
(
info
.
dwProcessId
);
}
else
tasks
++
;
}
if
(
!
tasks
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment