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
601a1364
Commit
601a1364
authored
Feb 04, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Moved SymEnumLines to symbol.c to reuse the regex support.
parent
768954b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
113 deletions
+109
-113
source.c
dlls/dbghelp/source.c
+0
-113
symbol.c
dlls/dbghelp/symbol.c
+109
-0
No files found.
dlls/dbghelp/source.c
View file @
601a1364
...
...
@@ -26,9 +26,6 @@
#include "dbghelp_private.h"
#include "wine/debug.h"
#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL
(
dbghelp
);
...
...
@@ -154,116 +151,6 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
return
TRUE
;
}
static
inline
void
re_append
(
char
**
mask
,
unsigned
*
len
,
char
ch
)
{
*
mask
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
mask
,
++
(
*
len
));
(
*
mask
)[
*
len
-
2
]
=
ch
;
}
static
BOOL
compile_regex
(
regex_t
*
re
,
const
char
*
srcfile
)
{
char
*
mask
;
unsigned
len
=
1
;
mask
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1
);
re_append
(
&
mask
,
&
len
,
'^'
);
if
(
!
srcfile
||
!*
srcfile
)
re_append
(
&
mask
,
&
len
,
'*'
);
else
while
(
*
srcfile
)
{
switch
(
*
srcfile
)
{
case
'\\'
:
case
'/'
:
re_append
(
&
mask
,
&
len
,
'['
);
re_append
(
&
mask
,
&
len
,
'\\'
);
re_append
(
&
mask
,
&
len
,
'\\'
);
re_append
(
&
mask
,
&
len
,
'/'
);
re_append
(
&
mask
,
&
len
,
']'
);
break
;
case
'.'
:
re_append
(
&
mask
,
&
len
,
'\\'
);
re_append
(
&
mask
,
&
len
,
'.'
);
break
;
default:
re_append
(
&
mask
,
&
len
,
*
srcfile
);
break
;
}
srcfile
++
;
}
re_append
(
&
mask
,
&
len
,
'$'
);
mask
[
len
-
1
]
=
'\0'
;
len
=
regcomp
(
re
,
mask
,
REG_NOSUB
);
HeapFree
(
GetProcessHeap
(),
0
,
mask
);
if
(
len
)
{
FIXME
(
"Couldn't compile %s
\n
"
,
mask
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
}
/******************************************************************
* SymEnumLines (DBGHELP.@)
*
*/
BOOL
WINAPI
SymEnumLines
(
HANDLE
hProcess
,
ULONG64
base
,
PCSTR
compiland
,
PCSTR
srcfile
,
PSYM_ENUMLINES_CALLBACK
cb
,
PVOID
user
)
{
struct
module_pair
pair
;
struct
hash_table_iter
hti
;
struct
symt_ht
*
sym
;
regex_t
re
;
struct
line_info
*
dli
;
void
*
ptr
;
SRCCODEINFO
sci
;
const
char
*
file
;
if
(
!
cb
)
return
FALSE
;
if
(
!
(
dbghelp_options
&
SYMOPT_LOAD_LINES
))
return
TRUE
;
pair
.
pcs
=
process_find_by_handle
(
hProcess
);
if
(
!
pair
.
pcs
)
return
FALSE
;
if
(
compiland
)
FIXME
(
"Unsupported yet (filtering on compiland %s)
\n
"
,
compiland
);
pair
.
requested
=
module_find_by_addr
(
pair
.
pcs
,
base
,
DMT_UNKNOWN
);
if
(
!
module_get_debug
(
&
pair
))
return
FALSE
;
if
(
!
compile_regex
(
&
re
,
srcfile
))
return
FALSE
;
sci
.
SizeOfStruct
=
sizeof
(
sci
);
sci
.
ModBase
=
base
;
hash_table_iter_init
(
&
pair
.
effective
->
ht_symbols
,
&
hti
,
NULL
);
while
((
ptr
=
hash_table_iter_up
(
&
hti
)))
{
unsigned
int
i
;
sym
=
GET_ENTRY
(
ptr
,
struct
symt_ht
,
hash_elt
);
if
(
sym
->
symt
.
tag
!=
SymTagFunction
)
continue
;
sci
.
FileName
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
vector_length
(
&
((
struct
symt_function
*
)
sym
)
->
vlines
);
i
++
)
{
dli
=
vector_at
(
&
((
struct
symt_function
*
)
sym
)
->
vlines
,
i
);
if
(
dli
->
is_source_file
)
{
file
=
source_get
(
pair
.
effective
,
dli
->
u
.
source_file
);
if
(
regexec
(
&
re
,
file
,
0
,
NULL
,
0
)
!=
0
)
file
=
""
;
strcpy
(
sci
.
FileName
,
file
);
}
else
if
(
sci
.
FileName
[
0
])
{
sci
.
Key
=
dli
;
sci
.
Obj
[
0
]
=
'\0'
;
/* FIXME */
sci
.
LineNumber
=
dli
->
line_number
;
sci
.
Address
=
dli
->
u
.
pc_offset
;
if
(
!
cb
(
&
sci
,
user
))
break
;
}
}
}
regfree
(
&
re
);
return
TRUE
;
}
/******************************************************************
* SymGetSourceFileToken (DBGHELP.@)
*
...
...
dlls/dbghelp/symbol.c
View file @
601a1364
...
...
@@ -123,6 +123,48 @@ static void compile_regex(const char* str, int numchar, regex_t* re, BOOL _case)
HeapFree
(
GetProcessHeap
(),
0
,
mask
);
}
static
BOOL
compile_file_regex
(
regex_t
*
re
,
const
char
*
srcfile
)
{
char
*
mask
,
*
p
;
BOOL
ret
;
p
=
mask
=
HeapAlloc
(
GetProcessHeap
(),
0
,
5
*
strlen
(
srcfile
)
+
4
);
*
p
++
=
'^'
;
if
(
!
srcfile
||
!*
srcfile
)
*
p
++
=
'*'
;
else
while
(
*
srcfile
)
{
switch
(
*
srcfile
)
{
case
'\\'
:
case
'/'
:
*
p
++
=
'['
;
*
p
++
=
'\\'
;
*
p
++
=
'\\'
;
*
p
++
=
'/'
;
*
p
++
=
']'
;
break
;
case
'.'
:
*
p
++
=
'\\'
;
*
p
++
=
'.'
;
break
;
default:
*
p
++
=
*
srcfile
;
break
;
}
srcfile
++
;
}
*
p
++
=
'$'
;
*
p
=
0
;
ret
=
!
regcomp
(
re
,
mask
,
REG_NOSUB
);
HeapFree
(
GetProcessHeap
(),
0
,
mask
);
if
(
!
ret
)
{
FIXME
(
"Couldn't compile %s
\n
"
,
mask
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
}
return
ret
;
}
static
int
match_regexp
(
const
regex_t
*
re
,
const
char
*
str
)
{
return
!
regexec
(
re
,
str
,
0
,
NULL
,
0
);
...
...
@@ -148,6 +190,12 @@ static void compile_regex(const char* str, int numchar, regex_t* re, BOOL _case)
re
->
icase
=
_case
;
}
static
BOOL
compile_file_regex
(
regex_t
*
re
,
const
char
*
srcfile
)
{
compile_regex
(
srcfile
,
-
1
,
re
,
FALSE
);
return
TRUE
;
}
static
int
match_regexp
(
const
regex_t
*
re
,
const
char
*
str
)
{
if
(
re
->
icase
)
return
!
lstrcmpiA
(
re
->
str
,
str
);
...
...
@@ -1797,3 +1845,64 @@ BOOL WINAPI SymSetScopeFromAddr(HANDLE hProcess, ULONG64 addr)
if
(
!
(
pcs
=
process_find_by_handle
(
hProcess
)))
return
FALSE
;
return
TRUE
;
}
/******************************************************************
* SymEnumLines (DBGHELP.@)
*
*/
BOOL
WINAPI
SymEnumLines
(
HANDLE
hProcess
,
ULONG64
base
,
PCSTR
compiland
,
PCSTR
srcfile
,
PSYM_ENUMLINES_CALLBACK
cb
,
PVOID
user
)
{
struct
module_pair
pair
;
struct
hash_table_iter
hti
;
struct
symt_ht
*
sym
;
regex_t
re
;
struct
line_info
*
dli
;
void
*
ptr
;
SRCCODEINFO
sci
;
const
char
*
file
;
if
(
!
cb
)
return
FALSE
;
if
(
!
(
dbghelp_options
&
SYMOPT_LOAD_LINES
))
return
TRUE
;
pair
.
pcs
=
process_find_by_handle
(
hProcess
);
if
(
!
pair
.
pcs
)
return
FALSE
;
if
(
compiland
)
FIXME
(
"Unsupported yet (filtering on compiland %s)
\n
"
,
compiland
);
pair
.
requested
=
module_find_by_addr
(
pair
.
pcs
,
base
,
DMT_UNKNOWN
);
if
(
!
module_get_debug
(
&
pair
))
return
FALSE
;
if
(
!
compile_file_regex
(
&
re
,
srcfile
))
return
FALSE
;
sci
.
SizeOfStruct
=
sizeof
(
sci
);
sci
.
ModBase
=
base
;
hash_table_iter_init
(
&
pair
.
effective
->
ht_symbols
,
&
hti
,
NULL
);
while
((
ptr
=
hash_table_iter_up
(
&
hti
)))
{
unsigned
int
i
;
sym
=
GET_ENTRY
(
ptr
,
struct
symt_ht
,
hash_elt
);
if
(
sym
->
symt
.
tag
!=
SymTagFunction
)
continue
;
sci
.
FileName
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
vector_length
(
&
((
struct
symt_function
*
)
sym
)
->
vlines
);
i
++
)
{
dli
=
vector_at
(
&
((
struct
symt_function
*
)
sym
)
->
vlines
,
i
);
if
(
dli
->
is_source_file
)
{
file
=
source_get
(
pair
.
effective
,
dli
->
u
.
source_file
);
if
(
!
match_regexp
(
&
re
,
file
))
file
=
""
;
strcpy
(
sci
.
FileName
,
file
);
}
else
if
(
sci
.
FileName
[
0
])
{
sci
.
Key
=
dli
;
sci
.
Obj
[
0
]
=
'\0'
;
/* FIXME */
sci
.
LineNumber
=
dli
->
line_number
;
sci
.
Address
=
dli
->
u
.
pc_offset
;
if
(
!
cb
(
&
sci
,
user
))
break
;
}
}
}
regfree
(
&
re
);
return
TRUE
;
}
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