Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
5c8ad491
Commit
5c8ad491
authored
Oct 18, 2008
by
Eric Pouech
Committed by
Alexandre Julliard
Oct 20, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winedbg: Use Unicode strings for all module references.
parent
01e69c71
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
116 additions
and
72 deletions
+116
-72
debugger.h
programs/winedbg/debugger.h
+5
-4
gdbproxy.c
programs/winedbg/gdbproxy.c
+17
-11
info.c
programs/winedbg/info.c
+2
-1
memory.c
programs/winedbg/memory.c
+19
-3
stack.c
programs/winedbg/stack.c
+2
-1
tgt_active.c
programs/winedbg/tgt_active.c
+28
-20
tgt_minidump.c
programs/winedbg/tgt_minidump.c
+8
-8
winedbg.c
programs/winedbg/winedbg.c
+35
-24
No files found.
programs/winedbg/debugger.h
View file @
5c8ad491
...
@@ -216,7 +216,7 @@ struct dbg_process
...
@@ -216,7 +216,7 @@ struct dbg_process
DWORD
pid
;
DWORD
pid
;
const
struct
be_process_io
*
process_io
;
const
struct
be_process_io
*
process_io
;
void
*
pio_data
;
void
*
pio_data
;
const
char
*
imageName
;
const
WCHAR
*
imageName
;
struct
dbg_thread
*
threads
;
struct
dbg_thread
*
threads
;
unsigned
continue_on_first_exception
:
1
,
unsigned
continue_on_first_exception
:
1
,
active_debuggee
:
1
;
active_debuggee
:
1
;
...
@@ -359,7 +359,7 @@ extern BOOL memory_get_current_pc(ADDRESS64* address);
...
@@ -359,7 +359,7 @@ extern BOOL memory_get_current_pc(ADDRESS64* address);
extern
BOOL
memory_get_current_stack
(
ADDRESS64
*
address
);
extern
BOOL
memory_get_current_stack
(
ADDRESS64
*
address
);
extern
BOOL
memory_get_current_frame
(
ADDRESS64
*
address
);
extern
BOOL
memory_get_current_frame
(
ADDRESS64
*
address
);
extern
BOOL
memory_get_string
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
in_debuggee
,
BOOL
unicode
,
char
*
buffer
,
int
size
);
extern
BOOL
memory_get_string
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
in_debuggee
,
BOOL
unicode
,
char
*
buffer
,
int
size
);
extern
BOOL
memory_get_string_indirect
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
unicode
,
char
*
buffer
,
int
size
);
extern
BOOL
memory_get_string_indirect
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
unicode
,
WCHAR
*
buffer
,
int
size
);
extern
BOOL
memory_get_register
(
DWORD
regno
,
DWORD
**
value
,
char
*
buffer
,
int
len
);
extern
BOOL
memory_get_register
(
DWORD
regno
,
DWORD
**
value
,
char
*
buffer
,
int
len
);
extern
void
memory_disassemble
(
const
struct
dbg_lvalue
*
,
const
struct
dbg_lvalue
*
,
int
instruction_count
);
extern
void
memory_disassemble
(
const
struct
dbg_lvalue
*
,
const
struct
dbg_lvalue
*
,
int
instruction_count
);
extern
BOOL
memory_disasm_one_insn
(
ADDRESS64
*
addr
);
extern
BOOL
memory_disasm_one_insn
(
ADDRESS64
*
addr
);
...
@@ -430,6 +430,7 @@ extern struct dbg_type types_find_type(unsigned long linear, const char* name,
...
@@ -430,6 +430,7 @@ extern struct dbg_type types_find_type(unsigned long linear, const char* name,
/* winedbg.c */
/* winedbg.c */
extern
void
dbg_outputA
(
const
char
*
buffer
,
int
len
);
extern
void
dbg_outputA
(
const
char
*
buffer
,
int
len
);
extern
void
dbg_outputW
(
const
WCHAR
*
buffer
,
int
len
);
extern
void
dbg_outputW
(
const
WCHAR
*
buffer
,
int
len
);
extern
const
char
*
dbg_W2A
(
const
WCHAR
*
buffer
,
unsigned
len
);
#ifdef __GNUC__
#ifdef __GNUC__
extern
int
dbg_printf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
extern
int
dbg_printf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
#else
#else
...
@@ -439,14 +440,14 @@ extern const struct dbg_internal_var* dbg_get_internal_var(const char*);
...
@@ -439,14 +440,14 @@ extern const struct dbg_internal_var* dbg_get_internal_var(const char*);
extern
BOOL
dbg_interrupt_debuggee
(
void
);
extern
BOOL
dbg_interrupt_debuggee
(
void
);
extern
unsigned
dbg_num_processes
(
void
);
extern
unsigned
dbg_num_processes
(
void
);
extern
struct
dbg_process
*
dbg_add_process
(
const
struct
be_process_io
*
pio
,
DWORD
pid
,
HANDLE
h
);
extern
struct
dbg_process
*
dbg_add_process
(
const
struct
be_process_io
*
pio
,
DWORD
pid
,
HANDLE
h
);
extern
void
dbg_set_process_name
(
struct
dbg_process
*
p
,
const
char
*
name
);
extern
void
dbg_set_process_name
(
struct
dbg_process
*
p
,
const
WCHAR
*
name
);
extern
struct
dbg_process
*
dbg_get_process
(
DWORD
pid
);
extern
struct
dbg_process
*
dbg_get_process
(
DWORD
pid
);
extern
struct
dbg_process
*
dbg_get_process_h
(
HANDLE
handle
);
extern
struct
dbg_process
*
dbg_get_process_h
(
HANDLE
handle
);
extern
void
dbg_del_process
(
struct
dbg_process
*
p
);
extern
void
dbg_del_process
(
struct
dbg_process
*
p
);
struct
dbg_thread
*
dbg_add_thread
(
struct
dbg_process
*
p
,
DWORD
tid
,
HANDLE
h
,
void
*
teb
);
struct
dbg_thread
*
dbg_add_thread
(
struct
dbg_process
*
p
,
DWORD
tid
,
HANDLE
h
,
void
*
teb
);
extern
struct
dbg_thread
*
dbg_get_thread
(
struct
dbg_process
*
p
,
DWORD
tid
);
extern
struct
dbg_thread
*
dbg_get_thread
(
struct
dbg_process
*
p
,
DWORD
tid
);
extern
void
dbg_del_thread
(
struct
dbg_thread
*
t
);
extern
void
dbg_del_thread
(
struct
dbg_thread
*
t
);
extern
BOOL
dbg_init
(
HANDLE
hProc
,
const
char
*
in
,
BOOL
invade
);
extern
BOOL
dbg_init
(
HANDLE
hProc
,
const
WCHAR
*
in
,
BOOL
invade
);
extern
BOOL
dbg_get_debuggee_info
(
HANDLE
hProcess
,
IMAGEHLP_MODULE
*
imh_mod
);
extern
BOOL
dbg_get_debuggee_info
(
HANDLE
hProcess
,
IMAGEHLP_MODULE
*
imh_mod
);
/* gdbproxy.c */
/* gdbproxy.c */
...
...
programs/winedbg/gdbproxy.c
View file @
5c8ad491
...
@@ -63,6 +63,7 @@
...
@@ -63,6 +63,7 @@
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
#include "tlhelp32.h"
#include "tlhelp32.h"
#include "wine/debug.h"
#define GDBPXY_TRC_LOWLEVEL 0x01
#define GDBPXY_TRC_LOWLEVEL 0x01
#define GDBPXY_TRC_PACKET 0x02
#define GDBPXY_TRC_PACKET 0x02
...
@@ -480,7 +481,10 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
...
@@ -480,7 +481,10 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
static
void
handle_debug_event
(
struct
gdb_context
*
gdbctx
,
DEBUG_EVENT
*
de
)
static
void
handle_debug_event
(
struct
gdb_context
*
gdbctx
,
DEBUG_EVENT
*
de
)
{
{
char
buffer
[
256
];
union
{
char
bufferA
[
256
];
WCHAR
buffer
[
256
];
}
u
;
dbg_curr_thread
=
dbg_get_thread
(
gdbctx
->
process
,
de
->
dwThreadId
);
dbg_curr_thread
=
dbg_get_thread
(
gdbctx
->
process
,
de
->
dwThreadId
);
...
@@ -493,19 +497,20 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
...
@@ -493,19 +497,20 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect
(
gdbctx
->
process
,
memory_get_string_indirect
(
gdbctx
->
process
,
de
->
u
.
CreateProcessInfo
.
lpImageName
,
de
->
u
.
CreateProcessInfo
.
lpImageName
,
de
->
u
.
CreateProcessInfo
.
fUnicode
,
de
->
u
.
CreateProcessInfo
.
fUnicode
,
buffer
,
sizeof
(
buffer
));
u
.
buffer
,
sizeof
(
u
.
buffer
)
/
sizeof
(
WCHAR
));
dbg_set_process_name
(
gdbctx
->
process
,
buffer
);
dbg_set_process_name
(
gdbctx
->
process
,
u
.
buffer
);
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
fprintf
(
stderr
,
"%04x:%04x: create process '%s'/%p @%p (%u<%u>)
\n
"
,
fprintf
(
stderr
,
"%04x:%04x: create process '%s'/%p @%p (%u<%u>)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
,
de
->
u
.
CreateProcessInfo
.
lpImageName
,
dbg_W2A
(
u
.
buffer
,
-
1
),
de
->
u
.
CreateProcessInfo
.
lpImageName
,
de
->
u
.
CreateProcessInfo
.
lpStartAddress
,
de
->
u
.
CreateProcessInfo
.
lpStartAddress
,
de
->
u
.
CreateProcessInfo
.
dwDebugInfoFileOffset
,
de
->
u
.
CreateProcessInfo
.
dwDebugInfoFileOffset
,
de
->
u
.
CreateProcessInfo
.
nDebugInfoSize
);
de
->
u
.
CreateProcessInfo
.
nDebugInfoSize
);
/* de->u.CreateProcessInfo.lpStartAddress; */
/* de->u.CreateProcessInfo.lpStartAddress; */
if
(
!
dbg_init
(
gdbctx
->
process
->
handle
,
buffer
,
TRUE
))
if
(
!
dbg_init
(
gdbctx
->
process
->
handle
,
u
.
buffer
,
TRUE
))
fprintf
(
stderr
,
"Couldn't initiate DbgHelp
\n
"
);
fprintf
(
stderr
,
"Couldn't initiate DbgHelp
\n
"
);
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
...
@@ -524,15 +529,16 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
...
@@ -524,15 +529,16 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect
(
gdbctx
->
process
,
memory_get_string_indirect
(
gdbctx
->
process
,
de
->
u
.
LoadDll
.
lpImageName
,
de
->
u
.
LoadDll
.
lpImageName
,
de
->
u
.
LoadDll
.
fUnicode
,
de
->
u
.
LoadDll
.
fUnicode
,
buffer
,
sizeof
(
buffer
));
u
.
buffer
,
sizeof
(
u
.
buffer
)
/
sizeof
(
WCHAR
));
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
fprintf
(
stderr
,
"%04x:%04x: loads DLL %s @%p (%u<%u>)
\n
"
,
fprintf
(
stderr
,
"%04x:%04x: loads DLL %s @%p (%u<%u>)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
,
de
->
u
.
LoadDll
.
lpBaseOfDll
,
dbg_W2A
(
u
.
buffer
,
-
1
),
de
->
u
.
LoadDll
.
lpBaseOfDll
,
de
->
u
.
LoadDll
.
dwDebugInfoFileOffset
,
de
->
u
.
LoadDll
.
dwDebugInfoFileOffset
,
de
->
u
.
LoadDll
.
nDebugInfoSize
);
de
->
u
.
LoadDll
.
nDebugInfoSize
);
SymLoadModule
(
gdbctx
->
process
->
handle
,
de
->
u
.
LoadDll
.
hFile
,
buffer
,
NULL
,
SymLoadModule
ExW
(
gdbctx
->
process
->
handle
,
de
->
u
.
LoadDll
.
hFile
,
u
.
buffer
,
NULL
,
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
,
0
);
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
,
0
,
NULL
,
0
);
break
;
break
;
case
UNLOAD_DLL_DEBUG_EVENT
:
case
UNLOAD_DLL_DEBUG_EVENT
:
...
@@ -594,10 +600,10 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
...
@@ -594,10 +600,10 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
assert
(
dbg_curr_thread
);
assert
(
dbg_curr_thread
);
memory_get_string
(
gdbctx
->
process
,
memory_get_string
(
gdbctx
->
process
,
de
->
u
.
DebugString
.
lpDebugStringData
,
TRUE
,
de
->
u
.
DebugString
.
lpDebugStringData
,
TRUE
,
de
->
u
.
DebugString
.
fUnicode
,
buffer
,
sizeof
(
buffer
));
de
->
u
.
DebugString
.
fUnicode
,
u
.
bufferA
,
sizeof
(
u
.
bufferA
));
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
fprintf
(
stderr
,
"%08x:%08x: output debug string (%s)
\n
"
,
fprintf
(
stderr
,
"%08x:%08x: output debug string (%s)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
);
de
->
dwProcessId
,
de
->
dwThreadId
,
u
.
bufferA
);
break
;
break
;
case
RIP_EVENT
:
case
RIP_EVENT
:
...
...
programs/winedbg/info.c
View file @
5c8ad491
...
@@ -501,7 +501,8 @@ void info_win32_threads(void)
...
@@ -501,7 +501,8 @@ void info_win32_threads(void)
struct
dbg_process
*
p
=
dbg_get_process
(
entry
.
th32OwnerProcessID
);
struct
dbg_process
*
p
=
dbg_get_process
(
entry
.
th32OwnerProcessID
);
dbg_printf
(
"%08x%s %s
\n
"
,
dbg_printf
(
"%08x%s %s
\n
"
,
entry
.
th32OwnerProcessID
,
p
?
" (D)"
:
""
,
p
?
p
->
imageName
:
""
);
entry
.
th32OwnerProcessID
,
p
?
" (D)"
:
""
,
p
?
dbg_W2A
(
p
->
imageName
,
-
1
)
:
""
);
lastProcessId
=
entry
.
th32OwnerProcessID
;
lastProcessId
=
entry
.
th32OwnerProcessID
;
}
}
dbg_printf
(
"
\t
%08x %4d%s
\n
"
,
dbg_printf
(
"
\t
%08x %4d%s
\n
"
,
...
...
programs/winedbg/memory.c
View file @
5c8ad491
...
@@ -259,16 +259,32 @@ BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee,
...
@@ -259,16 +259,32 @@ BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee,
return
TRUE
;
return
TRUE
;
}
}
BOOL
memory_get_string_indirect
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
unicode
,
char
*
buffer
,
int
size
)
BOOL
memory_get_string_indirect
(
struct
dbg_process
*
pcs
,
void
*
addr
,
BOOL
unicode
,
WCHAR
*
buffer
,
int
size
)
{
{
void
*
ad
;
void
*
ad
;
SIZE_T
sz
;
SIZE_T
sz
;
buffer
[
0
]
=
0
;
buffer
[
0
]
=
0
;
if
(
addr
&&
if
(
addr
&&
pcs
->
process_io
->
read
(
pcs
->
handle
,
addr
,
&
ad
,
sizeof
(
ad
),
&
sz
)
&&
sz
==
sizeof
(
ad
)
&&
ad
)
pcs
->
process_io
->
read
(
pcs
->
handle
,
addr
,
&
ad
,
sizeof
(
ad
),
&
sz
)
&&
sz
==
sizeof
(
ad
)
&&
ad
)
{
{
return
memory_get_string
(
pcs
,
ad
,
TRUE
,
unicode
,
buffer
,
size
);
LPSTR
buff
;
BOOL
ret
;
if
(
unicode
)
ret
=
pcs
->
process_io
->
read
(
pcs
->
handle
,
ad
,
buffer
,
size
*
sizeof
(
WCHAR
),
&
sz
)
&&
sz
!=
0
;
else
{
if
((
buff
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
ret
=
pcs
->
process_io
->
read
(
pcs
->
handle
,
ad
,
buff
,
size
,
&
sz
)
&&
sz
!=
0
;
MultiByteToWideChar
(
CP_ACP
,
0
,
buff
,
sz
,
buffer
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
buff
);
}
else
ret
=
FALSE
;
}
if
(
size
)
buffer
[
size
-
1
]
=
0
;
return
ret
;
}
}
return
FALSE
;
return
FALSE
;
}
}
...
...
programs/winedbg/stack.c
View file @
5c8ad491
...
@@ -391,7 +391,8 @@ static void backtrace_all(void)
...
@@ -391,7 +391,8 @@ static void backtrace_all(void)
}
}
dbg_printf
(
"
\n
Backtracing for thread %04x in process %04x (%s):
\n
"
,
dbg_printf
(
"
\n
Backtracing for thread %04x in process %04x (%s):
\n
"
,
entry
.
th32ThreadID
,
dbg_curr_pid
,
dbg_curr_process
->
imageName
);
entry
.
th32ThreadID
,
dbg_curr_pid
,
dbg_W2A
(
dbg_curr_process
->
imageName
,
-
1
));
backtrace_tid
(
dbg_curr_process
,
entry
.
th32ThreadID
);
backtrace_tid
(
dbg_curr_process
,
entry
.
th32ThreadID
);
}
}
while
(
Thread32Next
(
snapshot
,
&
entry
));
while
(
Thread32Next
(
snapshot
,
&
entry
));
...
...
programs/winedbg/tgt_active.c
View file @
5c8ad491
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "winternl.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/exception.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
winedbg
);
WINE_DEFAULT_DEBUG_CHANNEL
(
winedbg
);
...
@@ -418,16 +419,19 @@ static DWORD dbg_handle_exception(const EXCEPTION_RECORD* rec, BOOL first_chance
...
@@ -418,16 +419,19 @@ static DWORD dbg_handle_exception(const EXCEPTION_RECORD* rec, BOOL first_chance
static
BOOL
tgt_process_active_close_process
(
struct
dbg_process
*
pcs
,
BOOL
kill
);
static
BOOL
tgt_process_active_close_process
(
struct
dbg_process
*
pcs
,
BOOL
kill
);
static
void
fetch_module_name
(
void
*
name_addr
,
BOOL
unicode
,
void
*
mod_addr
,
static
void
fetch_module_name
(
void
*
name_addr
,
BOOL
unicode
,
void
*
mod_addr
,
char
*
buffer
,
size_t
bufsz
,
BOOL
is_pcs
)
WCHAR
*
buffer
,
size_t
bufsz
,
BOOL
is_pcs
)
{
{
static
WCHAR
pcspid
[]
=
{
'P'
,
'r'
,
'o'
,
'c'
,
'e'
,
's'
,
's'
,
'_'
,
'%'
,
'0'
,
'8'
,
'x'
,
0
};
static
WCHAR
dlladdr
[]
=
{
'D'
,
'L'
,
'L'
,
'_'
,
'%'
,
'0'
,
'8'
,
'l'
,
'x'
,
0
};
memory_get_string_indirect
(
dbg_curr_process
,
name_addr
,
unicode
,
buffer
,
bufsz
);
memory_get_string_indirect
(
dbg_curr_process
,
name_addr
,
unicode
,
buffer
,
bufsz
);
if
(
!
buffer
[
0
]
&&
if
(
!
buffer
[
0
]
&&
!
GetModuleFileNameEx
A
(
dbg_curr_process
->
handle
,
mod_addr
,
buffer
,
bufsz
))
!
GetModuleFileNameEx
W
(
dbg_curr_process
->
handle
,
mod_addr
,
buffer
,
bufsz
))
{
{
if
(
is_pcs
)
if
(
is_pcs
)
{
{
HMODULE
h
;
HMODULE
h
;
WORD
(
WINAPI
*
gpif
)(
HANDLE
,
LPSTR
,
DWORD
);
WORD
(
WINAPI
*
gpif
)(
HANDLE
,
LP
W
STR
,
DWORD
);
/* On Windows, when we get the process creation debug event for a process
/* On Windows, when we get the process creation debug event for a process
* created by winedbg, the modules' list is not initialized yet. Hence,
* created by winedbg, the modules' list is not initialized yet. Hence,
...
@@ -436,18 +440,21 @@ static void fetch_module_name(void* name_addr, BOOL unicode, void* mod_addr,
...
@@ -436,18 +440,21 @@ static void fetch_module_name(void* name_addr, BOOL unicode, void* mod_addr,
* give us the expected result
* give us the expected result
*/
*/
if
(
!
(
h
=
GetModuleHandleA
(
"psapi"
))
||
if
(
!
(
h
=
GetModuleHandleA
(
"psapi"
))
||
!
(
gpif
=
(
void
*
)
GetProcAddress
(
h
,
"GetProcessImageFileName"
))
||
!
(
gpif
=
(
void
*
)
GetProcAddress
(
h
,
"GetProcessImageFileName
W
"
))
||
!
(
gpif
)(
dbg_curr_process
->
handle
,
buffer
,
bufsz
))
!
(
gpif
)(
dbg_curr_process
->
handle
,
buffer
,
bufsz
))
snprintf
(
buffer
,
bufsz
,
"Process_%08x"
,
dbg_curr_pid
);
snprintf
W
(
buffer
,
bufsz
,
pcspid
,
dbg_curr_pid
);
}
}
else
else
snprintf
(
buffer
,
bufsz
,
"DLL_%p"
,
mod_addr
);
snprintf
W
(
buffer
,
bufsz
,
dlladdr
,
(
unsigned
long
)
mod_addr
);
}
}
}
}
static
unsigned
dbg_handle_debug_event
(
DEBUG_EVENT
*
de
)
static
unsigned
dbg_handle_debug_event
(
DEBUG_EVENT
*
de
)
{
{
char
buffer
[
256
];
union
{
char
bufferA
[
256
];
WCHAR
buffer
[
256
];
}
u
;
DWORD
cont
=
DBG_CONTINUE
;
DWORD
cont
=
DBG_CONTINUE
;
dbg_curr_pid
=
de
->
dwProcessId
;
dbg_curr_pid
=
de
->
dwProcessId
;
...
@@ -499,20 +506,21 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
...
@@ -499,20 +506,21 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name
(
de
->
u
.
CreateProcessInfo
.
lpImageName
,
fetch_module_name
(
de
->
u
.
CreateProcessInfo
.
lpImageName
,
de
->
u
.
CreateProcessInfo
.
fUnicode
,
de
->
u
.
CreateProcessInfo
.
fUnicode
,
de
->
u
.
CreateProcessInfo
.
lpBaseOfImage
,
de
->
u
.
CreateProcessInfo
.
lpBaseOfImage
,
buffer
,
sizeof
(
buffer
),
TRUE
);
u
.
buffer
,
sizeof
(
u
.
buffer
)
/
sizeof
(
WCHAR
),
TRUE
);
WINE_TRACE
(
"%04x:%04x: create process '%s'/%p @%p (%u<%u>)
\n
"
,
WINE_TRACE
(
"%04x:%04x: create process '%s'/%p @%p (%u<%u>)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
,
de
->
u
.
CreateProcessInfo
.
lpImageName
,
wine_dbgstr_w
(
u
.
buffer
),
de
->
u
.
CreateProcessInfo
.
lpImageName
,
de
->
u
.
CreateProcessInfo
.
lpStartAddress
,
de
->
u
.
CreateProcessInfo
.
lpStartAddress
,
de
->
u
.
CreateProcessInfo
.
dwDebugInfoFileOffset
,
de
->
u
.
CreateProcessInfo
.
dwDebugInfoFileOffset
,
de
->
u
.
CreateProcessInfo
.
nDebugInfoSize
);
de
->
u
.
CreateProcessInfo
.
nDebugInfoSize
);
dbg_set_process_name
(
dbg_curr_process
,
buffer
);
dbg_set_process_name
(
dbg_curr_process
,
u
.
buffer
);
if
(
!
dbg_init
(
dbg_curr_process
->
handle
,
buffer
,
FALSE
))
if
(
!
dbg_init
(
dbg_curr_process
->
handle
,
u
.
buffer
,
FALSE
))
dbg_printf
(
"Couldn't initiate DbgHelp
\n
"
);
dbg_printf
(
"Couldn't initiate DbgHelp
\n
"
);
if
(
!
SymLoadModule
(
dbg_curr_process
->
handle
,
de
->
u
.
CreateProcessInfo
.
hFile
,
buffer
,
NULL
,
if
(
!
SymLoadModule
ExW
(
dbg_curr_process
->
handle
,
de
->
u
.
CreateProcessInfo
.
hFile
,
u
.
buffer
,
NULL
,
(
unsigned
long
)
de
->
u
.
CreateProcessInfo
.
lpBaseOfImage
,
0
))
(
unsigned
long
)
de
->
u
.
CreateProcessInfo
.
lpBaseOfImage
,
0
,
NULL
,
0
))
dbg_printf
(
"couldn't load main module (%u)
\n
"
,
GetLastError
());
dbg_printf
(
"couldn't load main module (%u)
\n
"
,
GetLastError
());
WINE_TRACE
(
"%04x:%04x: create thread I @%p
\n
"
,
WINE_TRACE
(
"%04x:%04x: create thread I @%p
\n
"
,
...
@@ -593,22 +601,22 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
...
@@ -593,22 +601,22 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name
(
de
->
u
.
LoadDll
.
lpImageName
,
fetch_module_name
(
de
->
u
.
LoadDll
.
lpImageName
,
de
->
u
.
LoadDll
.
fUnicode
,
de
->
u
.
LoadDll
.
fUnicode
,
de
->
u
.
LoadDll
.
lpBaseOfDll
,
de
->
u
.
LoadDll
.
lpBaseOfDll
,
buffer
,
sizeof
(
buffer
),
FALSE
);
u
.
buffer
,
sizeof
(
u
.
buffer
)
/
sizeof
(
WCHAR
),
FALSE
);
WINE_TRACE
(
"%04x:%04x: loads DLL %s @%p (%u<%u>)
\n
"
,
WINE_TRACE
(
"%04x:%04x: loads DLL %s @%p (%u<%u>)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
,
de
->
u
.
LoadDll
.
lpBaseOfDll
,
wine_dbgstr_w
(
u
.
buffer
)
,
de
->
u
.
LoadDll
.
lpBaseOfDll
,
de
->
u
.
LoadDll
.
dwDebugInfoFileOffset
,
de
->
u
.
LoadDll
.
dwDebugInfoFileOffset
,
de
->
u
.
LoadDll
.
nDebugInfoSize
);
de
->
u
.
LoadDll
.
nDebugInfoSize
);
SymLoadModule
(
dbg_curr_process
->
handle
,
de
->
u
.
LoadDll
.
hFile
,
buffer
,
NULL
,
SymLoadModule
ExW
(
dbg_curr_process
->
handle
,
de
->
u
.
LoadDll
.
hFile
,
u
.
buffer
,
NULL
,
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
,
0
);
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
,
0
,
NULL
,
0
);
break_set_xpoints
(
FALSE
);
break_set_xpoints
(
FALSE
);
break_check_delayed_bp
();
break_check_delayed_bp
();
break_set_xpoints
(
TRUE
);
break_set_xpoints
(
TRUE
);
if
(
DBG_IVAR
(
BreakOnDllLoad
))
if
(
DBG_IVAR
(
BreakOnDllLoad
))
{
{
dbg_printf
(
"Stopping on DLL %s loading at 0x%08lx
\n
"
,
dbg_printf
(
"Stopping on DLL %s loading at 0x%08lx
\n
"
,
buffer
,
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
);
dbg_W2A
(
u
.
buffer
,
-
1
)
,
(
unsigned
long
)
de
->
u
.
LoadDll
.
lpBaseOfDll
);
if
(
dbg_fetch_context
())
cont
=
0
;
if
(
dbg_fetch_context
())
cont
=
0
;
}
}
break
;
break
;
...
@@ -631,9 +639,9 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
...
@@ -631,9 +639,9 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
memory_get_string
(
dbg_curr_process
,
memory_get_string
(
dbg_curr_process
,
de
->
u
.
DebugString
.
lpDebugStringData
,
TRUE
,
de
->
u
.
DebugString
.
lpDebugStringData
,
TRUE
,
de
->
u
.
DebugString
.
fUnicode
,
buffer
,
sizeof
(
buffer
));
de
->
u
.
DebugString
.
fUnicode
,
u
.
bufferA
,
sizeof
(
u
.
bufferA
));
WINE_TRACE
(
"%04x:%04x: output debug string (%s)
\n
"
,
WINE_TRACE
(
"%04x:%04x: output debug string (%s)
\n
"
,
de
->
dwProcessId
,
de
->
dwThreadId
,
buffer
);
de
->
dwProcessId
,
de
->
dwThreadId
,
u
.
bufferA
);
break
;
break
;
case
RIP_EVENT
:
case
RIP_EVENT
:
...
...
programs/winedbg/tgt_minidump.c
View file @
5c8ad491
...
@@ -172,9 +172,10 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
...
@@ -172,9 +172,10 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
MINIDUMP_MODULE_LIST
*
mml
;
MINIDUMP_MODULE_LIST
*
mml
;
MINIDUMP_MODULE
*
mm
;
MINIDUMP_MODULE
*
mm
;
MINIDUMP_STRING
*
mds
;
MINIDUMP_STRING
*
mds
;
char
exec_name
[
1024
];
WCHAR
exec_name
[
1024
];
WCHAR
nameW
[
1024
];
WCHAR
nameW
[
1024
];
unsigned
len
;
unsigned
len
;
static
WCHAR
default_exec_name
[]
=
{
'<'
,
'm'
,
'i'
,
'n'
,
'i'
,
'd'
,
'u'
,
'm'
,
'p'
,
'-'
,
'e'
,
'x'
,
'e'
,
'c'
,
'>'
,
0
};
/* fetch PID */
/* fetch PID */
if
(
MiniDumpReadDumpStream
(
data
->
mapping
,
MiscInfoStream
,
&
dir
,
&
stream
,
&
size
))
if
(
MiniDumpReadDumpStream
(
data
->
mapping
,
MiscInfoStream
,
&
dir
,
&
stream
,
&
size
))
...
@@ -185,25 +186,24 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
...
@@ -185,25 +186,24 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
}
}
/* fetch executable name (it's normally the first one in module list) */
/* fetch executable name (it's normally the first one in module list) */
strcpy
(
exec_name
,
"<minidump-exec>"
);
/* default */
lstrcpyW
(
exec_name
,
default_exec_name
);
if
(
MiniDumpReadDumpStream
(
data
->
mapping
,
ModuleListStream
,
&
dir
,
&
stream
,
&
size
))
if
(
MiniDumpReadDumpStream
(
data
->
mapping
,
ModuleListStream
,
&
dir
,
&
stream
,
&
size
))
{
{
mml
=
(
MINIDUMP_MODULE_LIST
*
)
stream
;
mml
=
(
MINIDUMP_MODULE_LIST
*
)
stream
;
if
(
mml
->
NumberOfModules
)
if
(
mml
->
NumberOfModules
)
{
{
char
*
ptr
;
WCHAR
*
ptr
;
mm
=
&
mml
->
Modules
[
0
];
mm
=
&
mml
->
Modules
[
0
];
mds
=
(
MINIDUMP_STRING
*
)((
char
*
)
data
->
mapping
+
mm
->
ModuleNameRva
);
mds
=
(
MINIDUMP_STRING
*
)((
char
*
)
data
->
mapping
+
mm
->
ModuleNameRva
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
mds
->
Buffer
,
len
=
mds
->
Length
/
2
;
mds
->
Length
/
sizeof
(
WCHAR
),
memcpy
(
exec_name
,
mds
->
Buffer
,
mds
->
Length
);
exec_name
,
sizeof
(
exec_name
)
-
1
,
NULL
,
NULL
);
exec_name
[
len
]
=
0
;
exec_name
[
len
]
=
0
;
for
(
ptr
=
exec_name
+
len
-
1
;
ptr
>=
exec_name
;
ptr
--
)
for
(
ptr
=
exec_name
+
len
-
1
;
ptr
>=
exec_name
;
ptr
--
)
{
{
if
(
*
ptr
==
'/'
||
*
ptr
==
'\\'
)
if
(
*
ptr
==
'/'
||
*
ptr
==
'\\'
)
{
{
memmove
(
exec_name
,
ptr
+
1
,
strlen
(
ptr
+
1
)
+
1
);
memmove
(
exec_name
,
ptr
+
1
,
(
lstrlenW
(
ptr
+
1
)
+
1
)
*
sizeof
(
WCHAR
)
);
break
;
break
;
}
}
}
}
...
@@ -264,7 +264,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
...
@@ -264,7 +264,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
break
;
break
;
}
}
dbg_printf
(
" %s was running on #%d %s CPU%s"
,
dbg_printf
(
" %s was running on #%d %s CPU%s"
,
exec_name
,
msi
->
u
.
s
.
NumberOfProcessors
,
str
,
dbg_W2A
(
exec_name
,
-
1
)
,
msi
->
u
.
s
.
NumberOfProcessors
,
str
,
msi
->
u
.
s
.
NumberOfProcessors
<
2
?
""
:
"s"
);
msi
->
u
.
s
.
NumberOfProcessors
<
2
?
""
:
"s"
);
switch
(
msi
->
MajorVersion
)
switch
(
msi
->
MajorVersion
)
{
{
...
...
programs/winedbg/winedbg.c
View file @
5c8ad491
...
@@ -125,22 +125,33 @@ void dbg_outputA(const char* buffer, int len)
...
@@ -125,22 +125,33 @@ void dbg_outputA(const char* buffer, int len)
}
}
}
}
void
dbg_outputW
(
const
WCHAR
*
buffer
,
int
len
)
const
char
*
dbg_W2A
(
const
WCHAR
*
buffer
,
unsigned
len
)
{
{
char
*
ansi
=
NULL
;
static
unsigned
ansilen
;
int
newlen
;
static
char
*
ansi
;
unsigned
newlen
;
/* do a serious Unicode to ANSI conversion
* FIXME: should CP_ACP be GetConsoleCP()?
*/
newlen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
len
,
NULL
,
0
,
NULL
,
NULL
);
newlen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
newlen
)
if
(
newlen
>
ansilen
)
{
{
if
(
!
(
ansi
=
HeapAlloc
(
GetProcessHeap
(),
0
,
newlen
)))
return
;
static
char
*
newansi
;
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
len
,
ansi
,
newlen
,
NULL
,
NULL
);
if
(
ansi
)
dbg_outputA
(
ansi
,
newlen
);
newansi
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
ansi
,
newlen
);
HeapFree
(
GetProcessHeap
(),
0
,
ansi
);
else
newansi
=
HeapAlloc
(
GetProcessHeap
(),
0
,
newlen
);
if
(
!
newansi
)
return
NULL
;
ansilen
=
newlen
;
ansi
=
newansi
;
}
}
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
len
,
ansi
,
newlen
,
NULL
,
NULL
);
return
ansi
;
}
void
dbg_outputW
(
const
WCHAR
*
buffer
,
int
len
)
{
const
char
*
ansi
=
dbg_W2A
(
buffer
,
len
);
if
(
ansi
)
dbg_outputA
(
ansi
,
strlen
(
ansi
));
/* FIXME: should CP_ACP be GetConsoleCP()? */
}
}
int
dbg_printf
(
const
char
*
format
,
...)
int
dbg_printf
(
const
char
*
format
,
...)
...
@@ -315,13 +326,13 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
...
@@ -315,13 +326,13 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
return
p
;
return
p
;
}
}
void
dbg_set_process_name
(
struct
dbg_process
*
p
,
const
char
*
imageName
)
void
dbg_set_process_name
(
struct
dbg_process
*
p
,
const
WCHAR
*
imageName
)
{
{
assert
(
p
->
imageName
==
NULL
);
assert
(
p
->
imageName
==
NULL
);
if
(
imageName
)
if
(
imageName
)
{
{
char
*
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
imageName
)
+
1
);
WCHAR
*
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
imageName
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
tmp
)
p
->
imageName
=
strcpy
(
tmp
,
imageName
);
if
(
tmp
)
p
->
imageName
=
lstrcpyW
(
tmp
,
imageName
);
}
}
}
}
...
@@ -352,29 +363,29 @@ void dbg_del_process(struct dbg_process* p)
...
@@ -352,29 +363,29 @@ void dbg_del_process(struct dbg_process* p)
* Initializes the dbghelp library, and also sets the application directory
* Initializes the dbghelp library, and also sets the application directory
* as a place holder for symbol searches.
* as a place holder for symbol searches.
*/
*/
BOOL
dbg_init
(
HANDLE
hProc
,
const
char
*
in
,
BOOL
invade
)
BOOL
dbg_init
(
HANDLE
hProc
,
const
WCHAR
*
in
,
BOOL
invade
)
{
{
BOOL
ret
;
BOOL
ret
;
ret
=
SymInitialize
(
hProc
,
NULL
,
invade
);
ret
=
SymInitialize
(
hProc
,
NULL
,
invade
);
if
(
ret
&&
in
)
if
(
ret
&&
in
)
{
{
const
char
*
last
;
const
WCHAR
*
last
;
for
(
last
=
in
+
strlen
(
in
)
-
1
;
last
>=
in
;
last
--
)
for
(
last
=
in
+
lstrlenW
(
in
)
-
1
;
last
>=
in
;
last
--
)
{
{
if
(
*
last
==
'/'
||
*
last
==
'\\'
)
if
(
*
last
==
'/'
||
*
last
==
'\\'
)
{
{
char
*
tmp
;
WCHAR
*
tmp
;
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1024
+
1
+
(
last
-
in
)
+
1
);
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
1024
+
1
+
(
last
-
in
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
tmp
&&
SymGetSearchPath
(
hProc
,
tmp
,
1024
))
if
(
tmp
&&
SymGetSearchPath
W
(
hProc
,
tmp
,
1024
))
{
{
char
*
x
=
tmp
+
strlen
(
tmp
);
WCHAR
*
x
=
tmp
+
lstrlenW
(
tmp
);
*
x
++
=
';'
;
*
x
++
=
';'
;
memcpy
(
x
,
in
,
last
-
in
);
memcpy
(
x
,
in
,
(
last
-
in
)
*
sizeof
(
WCHAR
)
);
x
[
last
-
in
]
=
'\0'
;
x
[
last
-
in
]
=
'\0'
;
ret
=
SymSetSearchPath
(
hProc
,
tmp
);
ret
=
SymSetSearchPath
W
(
hProc
,
tmp
);
}
}
else
ret
=
FALSE
;
else
ret
=
FALSE
;
HeapFree
(
GetProcessHeap
(),
0
,
tmp
);
HeapFree
(
GetProcessHeap
(),
0
,
tmp
);
...
...
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