Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abseil-cpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
abseil-cpp
Commits
ecc0033b
Commit
ecc0033b
authored
Oct 22, 2019
by
Loo Rong Jie
Committed by
Derek Mauro
Oct 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always enable proper symbolize implementation on Windows (#257)
parent
2796d500
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
17 deletions
+45
-17
absl/debugging/BUILD.bazel
+8
-2
absl/debugging/CMakeLists.txt
+3
-0
absl/debugging/symbolize.cc
+3
-6
absl/debugging/symbolize_test.cc
+29
-6
absl/debugging/symbolize_win32.inc
+2
-3
No files found.
absl/debugging/BUILD.bazel
View file @
ecc0033b
...
@@ -70,8 +70,14 @@ cc_library(
...
@@ -70,8 +70,14 @@ cc_library(
cc_test(
cc_test(
name = "symbolize_test",
name = "symbolize_test",
srcs = ["symbolize_test.cc"],
srcs = ["symbolize_test.cc"],
copts = ABSL_TEST_COPTS,
copts = ABSL_TEST_COPTS + select({
linkopts = ABSL_DEFAULT_LINKOPTS,
"//absl:windows": ["/Z7"],
"//conditions:default": [],
}),
linkopts = ABSL_DEFAULT_LINKOPTS + select({
"//absl:windows": ["/DEBUG"],
"//conditions:default": [],
}),
deps = [
deps = [
":stack_consumption",
":stack_consumption",
":symbolize",
":symbolize",
...
...
absl/debugging/CMakeLists.txt
View file @
ecc0033b
...
@@ -62,6 +62,9 @@ absl_cc_test(
...
@@ -62,6 +62,9 @@ absl_cc_test(
"symbolize_test.cc"
"symbolize_test.cc"
COPTS
COPTS
${
ABSL_TEST_COPTS
}
${
ABSL_TEST_COPTS
}
$<$<BOOL:
${
MSVC
}
>:-Z7>
LINKOPTS
$<$<BOOL:
${
MSVC
}
>:-DEBUG>
DEPS
DEPS
absl::stack_consumption
absl::stack_consumption
absl::symbolize
absl::symbolize
...
...
absl/debugging/symbolize.cc
View file @
ecc0033b
...
@@ -16,12 +16,9 @@
...
@@ -16,12 +16,9 @@
#if defined(ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE)
#if defined(ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE)
#include "absl/debugging/symbolize_elf.inc"
#include "absl/debugging/symbolize_elf.inc"
#elif defined(_WIN32) && defined(_DEBUG)
#elif defined(_WIN32)
// The Windows Symbolizer only works in debug mode. Note that _DEBUG
// The Windows Symbolizer only works if PDB files containing the debug info
// is the macro that defines whether or not MS C-Runtime debug info is
// are available to the program at runtime.
// available. Note that the PDB files containing the debug info must
// also be available to the program at runtime for the symbolizer to
// work.
#include "absl/debugging/symbolize_win32.inc"
#include "absl/debugging/symbolize_win32.inc"
#else
#else
#include "absl/debugging/symbolize_unimplemented.inc"
#include "absl/debugging/symbolize_unimplemented.inc"
...
...
absl/debugging/symbolize_test.cc
View file @
ecc0033b
...
@@ -35,10 +35,29 @@
...
@@ -35,10 +35,29 @@
using
testing
::
Contains
;
using
testing
::
Contains
;
#ifdef _WIN32
#define ABSL_SYMBOLIZE_TEST_NOINLINE __declspec(noinline)
#else
#define ABSL_SYMBOLIZE_TEST_NOINLINE ABSL_ATTRIBUTE_NOINLINE
#endif
// Functions to symbolize. Use C linkage to avoid mangled names.
// Functions to symbolize. Use C linkage to avoid mangled names.
extern
"C"
{
extern
"C"
{
void
nonstatic_func
()
{
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
}
ABSL_SYMBOLIZE_TEST_NOINLINE
void
nonstatic_func
()
{
static
void
static_func
()
{
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
}
// The next line makes this a unique function to prevent the compiler from
// folding identical functions together.
volatile
int
x
=
__LINE__
;
static_cast
<
void
>
(
x
);
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
}
ABSL_SYMBOLIZE_TEST_NOINLINE
static
void
static_func
()
{
// The next line makes this a unique function to prevent the compiler from
// folding identical functions together.
volatile
int
x
=
__LINE__
;
static_cast
<
void
>
(
x
);
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
}
}
// extern "C"
}
// extern "C"
struct
Foo
{
struct
Foo
{
...
@@ -46,7 +65,11 @@ struct Foo {
...
@@ -46,7 +65,11 @@ struct Foo {
};
};
// A C++ method that should have a mangled name.
// A C++ method that should have a mangled name.
void
ABSL_ATTRIBUTE_NOINLINE
Foo
::
func
(
int
)
{
ABSL_SYMBOLIZE_TEST_NOINLINE
void
Foo
::
func
(
int
)
{
// The next line makes this a unique function to prevent the compiler from
// folding identical functions together.
volatile
int
x
=
__LINE__
;
static_cast
<
void
>
(
x
);
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
();
}
}
...
@@ -449,14 +472,14 @@ void ABSL_ATTRIBUTE_NOINLINE TestWithReturnAddress() {
...
@@ -449,14 +472,14 @@ void ABSL_ATTRIBUTE_NOINLINE TestWithReturnAddress() {
#endif
#endif
}
}
#elif defined(_WIN32)
&& defined(_DEBUG)
#elif defined(_WIN32)
TEST
(
Symbolize
,
Basics
)
{
TEST
(
Symbolize
,
Basics
)
{
EXPECT_STREQ
(
"nonstatic_func"
,
TrySymbolize
((
void
*
)(
&
nonstatic_func
)));
EXPECT_STREQ
(
"nonstatic_func"
,
TrySymbolize
((
void
*
)(
&
nonstatic_func
)));
// The name of an internal linkage symbol is not specified; allow either a
// The name of an internal linkage symbol is not specified; allow either a
// mangled or an unmangled name here.
// mangled or an unmangled name here.
const
char
*
static_func_symbol
=
TrySymbolize
((
void
*
)(
&
static_func
));
const
char
*
static_func_symbol
=
TrySymbolize
((
void
*
)(
&
static_func
));
ASSERT_TRUE
(
static_func_symbol
!=
nullptr
);
ASSERT_TRUE
(
static_func_symbol
!=
nullptr
);
EXPECT_TRUE
(
strstr
(
static_func_symbol
,
"static_func"
)
!=
nullptr
);
EXPECT_TRUE
(
strstr
(
static_func_symbol
,
"static_func"
)
!=
nullptr
);
...
@@ -483,7 +506,7 @@ TEST(Symbolize, Truncation) {
...
@@ -483,7 +506,7 @@ TEST(Symbolize, Truncation) {
}
}
TEST
(
Symbolize
,
SymbolizeWithDemangling
)
{
TEST
(
Symbolize
,
SymbolizeWithDemangling
)
{
const
char
*
result
=
TrySymbolize
((
void
*
)(
&
Foo
::
func
));
const
char
*
result
=
TrySymbolize
((
void
*
)(
&
Foo
::
func
));
ASSERT_TRUE
(
result
!=
nullptr
);
ASSERT_TRUE
(
result
!=
nullptr
);
EXPECT_TRUE
(
strstr
(
result
,
"Foo::func"
)
!=
nullptr
)
<<
result
;
EXPECT_TRUE
(
strstr
(
result
,
"Foo::func"
)
!=
nullptr
)
<<
result
;
}
}
...
...
absl/debugging/symbolize_win32.inc
View file @
ecc0033b
...
@@ -57,9 +57,8 @@ bool Symbolize(const void *pc, char *out, int out_size) {
...
@@ -57,9 +57,8 @@ bool Symbolize(const void *pc, char *out, int out_size) {
if
(
out_size
<=
0
)
{
if
(
out_size
<=
0
)
{
return
false
;
return
false
;
}
}
std
::
aligned_storage
<
sizeof
(
SYMBOL_INFO
)
+
MAX_SYM_NAME
,
alignas
(
SYMBOL_INFO
)
char
buf
[
sizeof
(
SYMBOL_INFO
)
+
MAX_SYM_NAME
];
alignof
(
SYMBOL_INFO
)
>::
type
buf
;
SYMBOL_INFO
*
symbol
=
reinterpret_cast
<
SYMBOL_INFO
*>
(
buf
);
SYMBOL_INFO
*
symbol
=
reinterpret_cast
<
SYMBOL_INFO
*>
(
&
buf
);
symbol
->
SizeOfStruct
=
sizeof
(
SYMBOL_INFO
);
symbol
->
SizeOfStruct
=
sizeof
(
SYMBOL_INFO
);
symbol
->
MaxNameLen
=
MAX_SYM_NAME
;
symbol
->
MaxNameLen
=
MAX_SYM_NAME
;
if
(
!
SymFromAddr
(
process
,
reinterpret_cast
<
DWORD64
>
(
pc
),
nullptr
,
symbol
))
{
if
(
!
SymFromAddr
(
process
,
reinterpret_cast
<
DWORD64
>
(
pc
),
nullptr
,
symbol
))
{
...
...
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