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
Releases
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
Johnny Cai
wine
Commits
5052e072
Commit
5052e072
authored
21 years ago
by
Eric Pouech
Committed by
Alexandre Julliard
21 years ago
Browse files
Options
Downloads
Patches
Plain Diff
- added support for multi-thread in GDB remote read/write register(s)
commands - by default, internal errors are now verbose
parent
b650372b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
programs/winedbg/gdbproxy.c
+114
-79
114 additions, 79 deletions
programs/winedbg/gdbproxy.c
with
114 additions
and
79 deletions
programs/winedbg/gdbproxy.c
+
114
−
79
View file @
5052e072
...
...
@@ -3,7 +3,7 @@
* This allows to debug Wine (and any "emulated" program) under
* Linux using GDB
*
* Copyright (c) Eric Pouech 2002
* Copyright (c) Eric Pouech 2002
-2003
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -58,6 +58,7 @@
#define GDBPXY_TRC_COMMAND_ERROR 0x08
#define GDBPXY_TRC_WIN32_EVENT 0x10
#define GDBPXY_TRC_WIN32_ERROR 0x20
#define GDBPXY_TRC_COMMAND_FIXME 0x80
struct
gdb_ctx_Xpoint
{
...
...
@@ -83,8 +84,8 @@ struct gdb_context
int
out_len
;
int
out_curr_packet
;
/* generic GDB thread information */
unsigned
exec_thread
;
/* thread used in step & continue */
unsigned
other_thread
;
/* thread to be used in any other operation */
DBG_THREAD
*
exec_thread
;
/* thread used in step & continue */
DBG_THREAD
*
other_thread
;
/* thread to be used in any other operation */
unsigned
trace
;
/* current Win32 trap env */
unsigned
last_sig
;
...
...
@@ -262,10 +263,10 @@ static size_t cpu_register_map[] = {
static
const
size_t
cpu_num_regs
=
(
sizeof
(
cpu_register_map
)
/
sizeof
(
cpu_register_map
[
0
]));
static
inline
unsigned
long
*
cpu_register
(
struct
gdb_context
*
gdb
ctx
,
unsigned
idx
)
static
inline
unsigned
long
*
cpu_register
(
const
CONTEXT
*
ctx
,
unsigned
idx
)
{
assert
(
idx
<
cpu_num_regs
);
return
(
unsigned
long
*
)((
char
*
)
&
gdbctx
->
context
+
cpu_register_map
[
idx
]);
return
(
unsigned
long
*
)((
char
*
)
ctx
+
cpu_register_map
[
idx
]);
}
static
inline
BOOL
cpu_enter_stepping
(
struct
gdb_context
*
gdbctx
)
...
...
@@ -496,6 +497,26 @@ static inline BOOL cpu_remove_Xpoint(struct gdb_context* gdbctx,
* =============================================== *
*/
static
BOOL
fetch_context
(
struct
gdb_context
*
gdbctx
,
HANDLE
h
,
CONTEXT
*
ctx
)
{
ctx
->
ContextFlags
=
CONTEXT_CONTROL
|
CONTEXT_INTEGER
#ifdef CONTEXT_SEGMENTS
|
CONTEXT_SEGMENTS
#endif
#ifdef CONTEXT_DEBUG_REGISTERS
|
CONTEXT_DEBUG_REGISTERS
#endif
;
if
(
!
GetThreadContext
(
h
,
ctx
))
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"Can't get thread's context
\n
"
);
return
FALSE
;
}
return
TRUE
;
}
static
BOOL
handle_exception
(
struct
gdb_context
*
gdbctx
,
EXCEPTION_DEBUG_INFO
*
exc
)
{
EXCEPTION_RECORD
*
rec
=
&
exc
->
ExceptionRecord
;
...
...
@@ -550,7 +571,7 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
break
;
default:
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_EVENT
)
fprintf
(
stderr
,
"
u
nhandled exception code %08lx
\n
"
,
rec
->
ExceptionCode
);
fprintf
(
stderr
,
"
U
nhandled exception code %08lx
\n
"
,
rec
->
ExceptionCode
);
gdbctx
->
last_sig
=
SIGABRT
;
ret
=
TRUE
;
break
;
...
...
@@ -659,22 +680,10 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
u
.
Exception
.
ExceptionRecord
.
ExceptionCode
);
gdbctx
->
context
.
ContextFlags
=
CONTEXT_CONTROL
|
CONTEXT_INTEGER
#ifdef CONTEXT_SEGMENTS
|
CONTEXT_SEGMENTS
#endif
#ifdef CONTEXT_DEBUG_REGISTERS
|
CONTEXT_DEBUG_REGISTERS
#endif
;
if
(
!
GetThreadContext
(
DEBUG_CurrThread
->
handle
,
&
gdbctx
->
context
))
if
(
fetch_context
(
gdbctx
,
DEBUG_CurrThread
->
handle
,
&
gdbctx
->
context
))
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"Can't get thread's context
\n
"
);
break
;
gdbctx
->
in_trap
=
handle_exception
(
gdbctx
,
&
de
->
u
.
Exception
);
}
gdbctx
->
in_trap
=
handle_exception
(
gdbctx
,
&
de
->
u
.
Exception
);
break
;
case
CREATE_THREAD_DEBUG_EVENT
:
...
...
@@ -695,6 +704,8 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
de
->
dwProcessId
,
de
->
dwThreadId
,
de
->
u
.
ExitThread
.
dwExitCode
);
assert
(
DEBUG_CurrThread
);
if
(
DEBUG_CurrThread
==
gdbctx
->
exec_thread
)
gdbctx
->
exec_thread
=
NULL
;
if
(
DEBUG_CurrThread
==
gdbctx
->
other_thread
)
gdbctx
->
other_thread
=
NULL
;
DEBUG_DelThread
(
DEBUG_CurrThread
);
break
;
...
...
@@ -741,14 +752,14 @@ static void resume_debuggee(struct gdb_context* gdbctx, unsigned long cont)
{
if
(
!
SetThreadContext
(
DEBUG_CurrThread
->
handle
,
&
gdbctx
->
context
))
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"
c
annot set c
tx on
%lu
\n
"
,
DEBUG_CurrThread
->
tid
);
fprintf
(
stderr
,
"
C
annot set c
ontext on thread
%lu
\n
"
,
DEBUG_CurrThread
->
tid
);
if
(
!
ContinueDebugEvent
(
gdbctx
->
process
->
pid
,
DEBUG_CurrThread
->
tid
,
cont
))
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"
c
annot continue on %lu (%lu)
\n
"
,
fprintf
(
stderr
,
"
C
annot continue on %lu (%lu)
\n
"
,
DEBUG_CurrThread
->
tid
,
cont
);
}
else
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"
c
annot find last thread (%lu)
\n
"
,
DEBUG_CurrThread
->
tid
);
fprintf
(
stderr
,
"
C
annot find last thread (%lu)
\n
"
,
DEBUG_CurrThread
->
tid
);
}
static
void
wait_for_debuggee
(
struct
gdb_context
*
gdbctx
)
...
...
@@ -997,7 +1008,7 @@ static enum packet_return packet_reply_status(struct gdb_context* gdbctx)
*/
packet_reply_val
(
gdbctx
,
i
,
1
);
packet_reply_catc
(
gdbctx
,
':'
);
packet_reply_hex_to
(
gdbctx
,
cpu_register
(
gdbctx
,
i
),
4
);
packet_reply_hex_to
(
gdbctx
,
cpu_register
(
&
gdbctx
->
context
,
i
),
4
);
packet_reply_catc
(
gdbctx
,
';'
);
}
}
...
...
@@ -1033,10 +1044,10 @@ static enum packet_return packet_continue(struct gdb_context* gdbctx)
{
/* FIXME: add support for address in packet */
assert
(
gdbctx
->
in_packet_len
==
0
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
ERROR
)
fprintf
(
stderr
,
"NIY: cont on %u, while last thd is %lu
\n
"
,
gdbctx
->
exec_thread
,
DEBUG_CurrThread
->
tid
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
FIXME
)
fprintf
(
stderr
,
"NIY: cont on %
l
u, while last th
rea
d is %lu
\n
"
,
gdbctx
->
exec_thread
->
tid
,
DEBUG_CurrThread
->
tid
);
resume_debuggee
(
gdbctx
,
DBG_CONTINUE
);
wait_for_debuggee
(
gdbctx
);
return
packet_reply_status
(
gdbctx
);
...
...
@@ -1048,10 +1059,10 @@ static enum packet_return packet_continue_signal(struct gdb_context* gdbctx)
/* FIXME: add support for address in packet */
assert
(
gdbctx
->
in_packet_len
==
2
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
ERROR
)
fprintf
(
stderr
,
"NIY: cont/sig on %u, while last thd is %lu
\n
"
,
gdbctx
->
exec_thread
,
DEBUG_CurrThread
->
tid
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
FIXME
)
fprintf
(
stderr
,
"NIY: cont/sig on %
l
u, while last th
rea
d is %lu
\n
"
,
gdbctx
->
exec_thread
->
tid
,
DEBUG_CurrThread
->
tid
);
hex_from
(
&
sig
,
gdbctx
->
in_packet
,
1
);
/* cannot change signals on the fly */
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND
)
...
...
@@ -1072,20 +1083,22 @@ static enum packet_return packet_detach(struct gdb_context* gdbctx)
static
enum
packet_return
packet_read_registers
(
struct
gdb_context
*
gdbctx
)
{
int
i
;
CONTEXT
ctx
;
CONTEXT
*
pctx
=
&
gdbctx
->
context
;
assert
(
gdbctx
->
in_trap
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"NIY: read regs on %u, while last thd is %lu
\n
"
,
gdbctx
->
other_thread
,
DEBUG_CurrThread
->
tid
);
packet_reply_open
(
gdbctx
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
{
if
(
!
fetch_context
(
gdbctx
,
gdbctx
->
other_thread
->
handle
,
pctx
=
&
ctx
))
return
packet_error
;
}
packet_reply_open
(
gdbctx
);
for
(
i
=
0
;
i
<
cpu_num_regs
;
i
++
)
{
packet_reply_hex_to
(
gdbctx
,
cpu_register
(
gdb
ctx
,
i
),
4
);
packet_reply_hex_to
(
gdbctx
,
cpu_register
(
p
ctx
,
i
),
4
);
}
packet_reply_close
(
gdbctx
);
return
packet_done
;
}
...
...
@@ -1093,15 +1106,25 @@ static enum packet_return packet_read_registers(struct gdb_context* gdbctx)
static
enum
packet_return
packet_write_registers
(
struct
gdb_context
*
gdbctx
)
{
unsigned
i
;
CONTEXT
ctx
;
CONTEXT
*
pctx
=
&
gdbctx
->
context
;
assert
(
gdbctx
->
in_trap
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"NIY: write regs on %u, while last thd is %lu
\n
"
,
gdbctx
->
other_thread
,
DEBUG_CurrThread
->
tid
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
{
if
(
!
fetch_context
(
gdbctx
,
gdbctx
->
other_thread
->
handle
,
pctx
=
&
ctx
))
return
packet_error
;
}
if
(
gdbctx
->
in_packet_len
<
cpu_num_regs
*
2
)
return
packet_error
;
for
(
i
=
0
;
i
<
cpu_num_regs
;
i
++
)
hex_from
(
cpu_register
(
gdbctx
,
i
),
&
gdbctx
->
in_packet
[
8
*
i
],
4
);
hex_from
(
cpu_register
(
pctx
,
i
),
&
gdbctx
->
in_packet
[
8
*
i
],
4
);
if
(
pctx
!=
&
gdbctx
->
context
&&
!
SetThreadContext
(
gdbctx
->
other_thread
->
handle
,
pctx
))
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"Cannot set context on thread %lu
\n
"
,
gdbctx
->
other_thread
->
tid
);
return
packet_error
;
}
return
packet_ok
;
}
...
...
@@ -1140,9 +1163,9 @@ static enum packet_return packet_thread(struct gdb_context* gdbctx)
return
packet_error
;
}
if
(
gdbctx
->
in_packet
[
0
]
==
'c'
)
gdbctx
->
exec_thread
=
thread
;
gdbctx
->
exec_thread
=
DEBUG_GetThread
(
gdbctx
->
process
,
thread
)
;
else
gdbctx
->
other_thread
=
thread
;
gdbctx
->
other_thread
=
DEBUG_GetThread
(
gdbctx
->
process
,
thread
)
;
return
packet_ok
;
default:
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
...
...
@@ -1162,7 +1185,7 @@ static enum packet_return packet_read_memory(struct gdb_context* gdbctx)
/* FIXME:check in_packet_len for reading %p,%x */
if
(
sscanf
(
gdbctx
->
in_packet
,
"%p,%x"
,
&
addr
,
&
len
)
!=
2
)
return
packet_error
;
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND
)
fprintf
(
stderr
,
"
r
ead mem at %p for %u bytes
\n
"
,
addr
,
len
);
fprintf
(
stderr
,
"
R
ead mem at %p for %u bytes
\n
"
,
addr
,
len
);
for
(
nread
=
0
;
nread
<
len
>
0
;
nread
+=
r
,
addr
+=
r
)
{
blk_len
=
min
(
sizeof
(
buffer
),
len
-
nread
);
...
...
@@ -1194,7 +1217,7 @@ static enum packet_return packet_write_memory(struct gdb_context* gdbctx)
if
(
ptr
==
NULL
)
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"
c
annot find ':' in %*.*s
\n
"
,
fprintf
(
stderr
,
"
C
annot find ':' in %*.*s
\n
"
,
gdbctx
->
in_packet_len
,
gdbctx
->
in_packet_len
,
gdbctx
->
in_packet
);
return
packet_error
;
}
...
...
@@ -1203,18 +1226,18 @@ static enum packet_return packet_write_memory(struct gdb_context* gdbctx)
if
(
sscanf
(
gdbctx
->
in_packet
,
"%p,%x"
,
&
addr
,
&
len
)
!=
2
)
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"
c
annot scan addr,len in %s
\n
"
,
gdbctx
->
in_packet
);
fprintf
(
stderr
,
"
C
annot scan addr,len in %s
\n
"
,
gdbctx
->
in_packet
);
return
packet_error
;
}
if
(
ptr
-
gdbctx
->
in_packet
+
len
*
2
!=
gdbctx
->
in_packet_len
)
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"
w
rong sizes %u <> %u
\n
"
,
fprintf
(
stderr
,
"
W
rong sizes %u <> %u
\n
"
,
ptr
-
gdbctx
->
in_packet
+
len
*
2
,
gdbctx
->
in_packet_len
);
return
packet_error
;
}
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND
)
fprintf
(
stderr
,
"
w
rite %u bytes at %p
\n
"
,
len
,
addr
);
fprintf
(
stderr
,
"
W
rite %u bytes at %p
\n
"
,
len
,
addr
);
while
(
len
>
0
)
{
blk_len
=
min
(
sizeof
(
buffer
),
len
);
...
...
@@ -1238,12 +1261,10 @@ static enum packet_return packet_write_register(struct gdb_context* gdbctx)
unsigned
reg
;
char
*
ptr
;
char
*
end
;
CONTEXT
ctx
;
CONTEXT
*
pctx
=
&
gdbctx
->
context
;
assert
(
gdbctx
->
in_trap
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"NIY: read reg on %u, while last thd is %lu
\n
"
,
gdbctx
->
other_thread
,
DEBUG_CurrThread
->
tid
);
ptr
=
memchr
(
gdbctx
->
in_packet
,
'='
,
gdbctx
->
in_packet_len
);
*
ptr
++
=
'\0'
;
...
...
@@ -1251,7 +1272,7 @@ static enum packet_return packet_write_register(struct gdb_context* gdbctx)
if
(
end
==
NULL
||
reg
>
cpu_num_regs
)
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"
i
nvalid register index %s
\n
"
,
gdbctx
->
in_packet
);
fprintf
(
stderr
,
"
I
nvalid register index %s
\n
"
,
gdbctx
->
in_packet
);
/* FIXME: if just the reg is above cpu_num_regs, don't tell gdb
* it wouldn't matter too much, and it fakes our support for all regs
*/
...
...
@@ -1260,7 +1281,7 @@ static enum packet_return packet_write_register(struct gdb_context* gdbctx)
if
(
ptr
+
8
-
gdbctx
->
in_packet
!=
gdbctx
->
in_packet_len
)
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_ERROR
)
fprintf
(
stderr
,
"
w
rong sizes %u <> %u
\n
"
,
fprintf
(
stderr
,
"
W
rong sizes %u <> %u
\n
"
,
ptr
+
8
-
gdbctx
->
in_packet
,
gdbctx
->
in_packet_len
);
return
packet_error
;
}
...
...
@@ -1268,7 +1289,21 @@ static enum packet_return packet_write_register(struct gdb_context* gdbctx)
fprintf
(
stderr
,
"Writing reg %u <= %*.*s
\n
"
,
reg
,
gdbctx
->
in_packet_len
-
(
ptr
-
gdbctx
->
in_packet
),
gdbctx
->
in_packet_len
-
(
ptr
-
gdbctx
->
in_packet
),
ptr
);
hex_from
(
cpu_register
(
gdbctx
,
reg
),
ptr
,
4
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
other_thread
&&
gdbctx
->
other_thread
)
{
if
(
!
fetch_context
(
gdbctx
,
gdbctx
->
other_thread
->
handle
,
pctx
=
&
ctx
))
return
packet_error
;
}
hex_from
(
cpu_register
(
pctx
,
reg
),
ptr
,
4
);
if
(
pctx
!=
&
gdbctx
->
context
&&
!
SetThreadContext
(
gdbctx
->
other_thread
->
handle
,
pctx
))
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_WIN32_ERROR
)
fprintf
(
stderr
,
"Cannot set context for thread %lu
\n
"
,
gdbctx
->
other_thread
->
tid
);
return
packet_error
;
}
return
packet_ok
;
}
...
...
@@ -1646,10 +1681,10 @@ static enum packet_return packet_step(struct gdb_context* gdbctx)
{
/* FIXME: add support for address in packet */
assert
(
gdbctx
->
in_packet_len
==
0
);
if
(
DEBUG_CurrThread
->
tid
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
ERROR
)
fprintf
(
stderr
,
"NIY: step on %u, while last thd is %lu
\n
"
,
gdbctx
->
exec_thread
,
DEBUG_CurrThread
->
tid
);
if
(
DEBUG_CurrThread
!=
gdbctx
->
exec_thread
&&
gdbctx
->
exec_thread
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND_
FIXME
)
fprintf
(
stderr
,
"NIY: step on %
l
u, while last th
rea
d is %lu
\n
"
,
gdbctx
->
exec_thread
->
tid
,
DEBUG_CurrThread
->
tid
);
if
(
!
cpu_enter_stepping
(
gdbctx
))
return
packet_error
;
resume_debuggee
(
gdbctx
,
DBG_CONTINUE
);
wait_for_debuggee
(
gdbctx
);
...
...
@@ -1666,7 +1701,7 @@ static enum packet_return packet_step_signal(struct gdb_context* gdbctx)
assert(gdbctx->in_packet_len == 2);
if (DEBUG_CurrThread->tid != gdbctx->exec_thread && gdbctx->exec_thread)
if (gdbctx->trace & GDBPXY_TRC_COMMAND_ERROR)
fprintf(stderr, "NIY: step/sig on %u, while last thd is %u\n",
fprintf(stderr, "NIY: step/sig on %u, while last th
rea
d is %u\n",
gdbctx->exec_thread, DEBUG_CurrThread->tid);
hex_from(&sig, gdbctx->in_packet, 1);
/* cannot change signals on the fly */
...
...
@@ -1705,7 +1740,7 @@ static enum packet_return packet_remove_breakpoint(struct gdb_context* gdbctx)
sscanf
(
gdbctx
->
in_packet
+
2
,
"%p,%x"
,
&
addr
,
&
len
)
!=
2
)
return
packet_error
;
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND
)
fprintf
(
stderr
,
"
r
emove bp %p[%u] typ=%c
\n
"
,
fprintf
(
stderr
,
"
R
emove bp %p[%u] typ=%c
\n
"
,
addr
,
len
,
gdbctx
->
in_packet
[
0
]);
for
(
xpt
=
&
gdbctx
->
Xpoints
[
NUM_XPOINT
-
1
];
xpt
>=
gdbctx
->
Xpoints
;
xpt
--
)
{
...
...
@@ -1735,7 +1770,7 @@ static enum packet_return packet_set_breakpoint(struct gdb_context* gdbctx)
sscanf
(
gdbctx
->
in_packet
+
2
,
"%p,%x"
,
&
addr
,
&
len
)
!=
2
)
return
packet_error
;
if
(
gdbctx
->
trace
&
GDBPXY_TRC_COMMAND
)
fprintf
(
stderr
,
"
s
et bp %p[%u] typ=%c
\n
"
,
fprintf
(
stderr
,
"
S
et bp %p[%u] typ=%c
\n
"
,
addr
,
len
,
gdbctx
->
in_packet
[
0
]);
/* because of packet command handling, this should be made idempotent */
for
(
xpt
=
&
gdbctx
->
Xpoints
[
NUM_XPOINT
-
1
];
xpt
>=
gdbctx
->
Xpoints
;
xpt
--
)
...
...
@@ -1810,7 +1845,7 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
while
((
ret
&
packet_last_f
)
==
0
)
{
if
(
gdbctx
->
in_len
&&
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
))
fprintf
(
stderr
,
"
i
n-buf: %*.*s
\n
"
,
fprintf
(
stderr
,
"
I
n-buf: %*.*s
\n
"
,
gdbctx
->
in_len
,
gdbctx
->
in_len
,
gdbctx
->
in_buf
);
ptr
=
memchr
(
gdbctx
->
in_buf
,
'$'
,
gdbctx
->
in_len
);
if
(
ptr
==
NULL
)
return
FALSE
;
...
...
@@ -1818,7 +1853,7 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
{
int
glen
=
ptr
-
gdbctx
->
in_buf
;
/* garbage len */
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
r
emoving garbage: %*.*s
\n
"
,
fprintf
(
stderr
,
"
R
emoving garbage: %*.*s
\n
"
,
glen
,
glen
,
gdbctx
->
in_buf
);
gdbctx
->
in_len
-=
glen
;
memmove
(
gdbctx
->
in_buf
,
ptr
,
gdbctx
->
in_len
);
...
...
@@ -1847,7 +1882,7 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
}
if
(
i
==
sizeof
(
packet_entries
)
/
sizeof
(
packet_entries
[
0
]))
{
if
(
gdbctx
->
trace
&
GDBPXY_TRC_
PACKET
)
if
(
gdbctx
->
trace
&
GDBPXY_TRC_
COMMAND_ERROR
)
fprintf
(
stderr
,
"Unknown packet request %*.*s
\n
"
,
plen
,
plen
,
&
gdbctx
->
in_buf
[
1
]);
}
...
...
@@ -1869,7 +1904,7 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
case
packet_done
:
break
;
}
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
r
eply-full: %*.*s
\n
"
,
fprintf
(
stderr
,
"
R
eply-full: %*.*s
\n
"
,
gdbctx
->
out_len
,
gdbctx
->
out_len
,
gdbctx
->
out_buf
);
i
=
write
(
gdbctx
->
sock
,
gdbctx
->
out_buf
,
gdbctx
->
out_len
);
assert
(
i
==
gdbctx
->
out_len
);
...
...
@@ -1889,17 +1924,17 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
* - one managing the packets for gdb
* - the second one managing the commands...
* This would allow us also the reply with the '+' character (Ack of
* the command) way sooner than what we do
k
now
* the command) way sooner than what we do now
*/
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
d
ropping packet, I was too slow to respond
\n
"
);
fprintf
(
stderr
,
"
D
ropping packet, I was too slow to respond
\n
"
);
}
}
else
{
write
(
gdbctx
->
sock
,
"+"
,
1
);
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
d
ropping packet, invalid checksum %d <> %d
\n
"
,
in_cksum
,
loc_cksum
);
fprintf
(
stderr
,
"
D
ropping packet, invalid checksum %d <> %d
\n
"
,
in_cksum
,
loc_cksum
);
}
gdbctx
->
in_len
-=
plen
+
4
;
memmove
(
gdbctx
->
in_buf
,
end
+
3
,
gdbctx
->
in_len
);
...
...
@@ -1958,7 +1993,7 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl
ptr
=
getenv
(
"WINELOADER"
);
strcpy
(
wine_path
,
ptr
?
ptr
:
"wine"
);
fprintf
(
stderr
,
"
u
sing wine_path: %s
\n
"
,
wine_path
);
fprintf
(
stderr
,
"
U
sing wine_path: %s
\n
"
,
wine_path
);
read_elf_info
(
wine_path
,
gdbctx
->
wine_segs
);
/* step 3: fire up gdb (if requested) */
...
...
@@ -1987,7 +2022,7 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl
if
((
f
=
fdopen
(
fd
,
"w+"
))
==
NULL
)
return
FALSE
;
fprintf
(
f
,
"file %s
\n
"
,
wine_path
);
fprintf
(
f
,
"target remote localhost:%d
\n
"
,
ntohs
(
s_addrs
.
sin_port
));
fprintf
(
f
,
"monitor trace=
0
\n
"
);
fprintf
(
f
,
"monitor trace=
%d
\n
"
,
GDBPXY_TRC_COMMAND_FIXME
);
fprintf
(
f
,
"set prompt Wine-gdb>
\\
\n
"
);
/* gdb 5.1 seems to require it, won't hurt anyway */
fprintf
(
f
,
"sharedlibrary
\n
"
);
...
...
@@ -2031,11 +2066,11 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl
break
;
case
0
:
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
p
oll for cnx failed (timeout)
\n
"
);
fprintf
(
stderr
,
"
P
oll for cnx failed (timeout)
\n
"
);
return
FALSE
;
case
-
1
:
if
(
gdbctx
->
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
p
oll for cnx failed (error)
\n
"
);
fprintf
(
stderr
,
"
P
oll for cnx failed (error)
\n
"
);
return
FALSE
;
default:
assert
(
0
);
...
...
@@ -2059,10 +2094,10 @@ static BOOL gdb_init_context(struct gdb_context* gdbctx, unsigned flags)
gdbctx
->
out_len
=
0
;
gdbctx
->
out_curr_packet
=
-
1
;
gdbctx
->
exec_thread
=
gdbctx
->
other_thread
=
0
;
gdbctx
->
exec_thread
=
gdbctx
->
other_thread
=
NULL
;
gdbctx
->
last_sig
=
0
;
gdbctx
->
in_trap
=
FALSE
;
gdbctx
->
trace
=
/*GDBPXY_TRC_PACKET | GDBPXY_TRC_COMMAND |*/
GDBPXY_TRC_COMMAND_ERROR
|
GDBPXY_TRC_WIN32_EVENT
;
gdbctx
->
trace
=
/*GDBPXY_TRC_PACKET | GDBPXY_TRC_COMMAND |*/
GDBPXY_TRC_COMMAND_ERROR
|
GDBPXY_TRC_COMMAND_FIXME
|
GDBPXY_TRC_WIN32_EVENT
;
gdbctx
->
process
=
NULL
;
for
(
i
=
0
;
i
<
NUM_XPOINT
;
i
++
)
gdbctx
->
Xpoints
[
i
].
type
=
-
1
;
...
...
@@ -2124,7 +2159,7 @@ BOOL DEBUG_GdbRemote(unsigned flags)
break
;
case
-
1
:
if
(
gdbctx
.
trace
&
GDBPXY_TRC_LOWLEVEL
)
fprintf
(
stderr
,
"
p
oll failed
\n
"
);
fprintf
(
stderr
,
"
P
oll failed
\n
"
);
doLoop
=
FALSE
;
break
;
}
...
...
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