Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Jan 10, 2024
1 parent ec84710 commit 716bc6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
26 changes: 4 additions & 22 deletions src/symbolize.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#ifndef GLOG_NO_SYMBOLIZE_DETECTION
# ifndef HAVE_SYMBOLIZE
// defined by gcc
# if defined(__ELF__) && defined(GLOG_OS_LINUX)
# if defined(HAVE_LINK_H) && defined(GLOG_OS_LINUX)
# define HAVE_SYMBOLIZE
# elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
// Use dladdr to symbolize.
Expand All @@ -86,26 +86,8 @@

#ifdef HAVE_SYMBOLIZE

# if defined(__ELF__) // defined by gcc
# if defined(__OpenBSD__)
# include <sys/exec_elf.h>
# else
# include <elf.h>
# endif

# if !defined(GLOG_OS_ANDROID)
# include <link.h> // For ElfW() macro.
# endif

// For systems where SIZEOF_VOID_P is not defined, determine it
// based on __LP64__ (defined by gcc on 64-bit systems)
# if !defined(SIZEOF_VOID_P)
# if defined(__LP64__)
# define SIZEOF_VOID_P 8
# else
# define SIZEOF_VOID_P 4
# endif
# endif
# if defined(HAVE_LINK_H)
# include <link.h> // For ElfW() macro.

// If there is no ElfW macro, let's define it by ourself.
# ifndef ElfW
Expand All @@ -130,7 +112,7 @@ bool GetSectionHeaderByName(int fd, const char* name, size_t name_len,
} // namespace glog_internal_namespace_
} // namespace google

# endif /* __ELF__ */
# endif /* HAVE_LINK_H */

namespace google {
inline namespace glog_internal_namespace_ {
Expand Down
11 changes: 6 additions & 5 deletions src/symbolize_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ using namespace google;

# define always_inline

# if defined(__ELF__) || defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
# if defined(HAVE_LINK_H) || defined(GLOG_OS_WINDOWS) || \
defined(GLOG_OS_CYGWIN)
// A wrapper function for Symbolize() to make the unit test simple.
static const char* TrySymbolize(void* pc, google::SymbolizeOptions options =
google::SymbolizeOptions::kNone) {
Expand All @@ -73,7 +74,7 @@ static const char* TrySymbolize(void* pc, google::SymbolizeOptions options =
}
# endif

# if defined(__ELF__)
# if defined(HAVE_LINK_H)

// This unit tests make sense only with GCC.
// Uses lots of GCC specific features.
Expand Down Expand Up @@ -449,15 +450,15 @@ __declspec(noinline) void TestWithReturnAddress() {
# endif
cout << "Test case TestWithReturnAddress passed." << endl;
}
# endif // __ELF__
# endif // HAVE_LINK_H
#endif // HAVE_STACKTRACE

int main(int argc, char** argv) {
FLAGS_logtostderr = true;
InitGoogleLogging(argv[0]);
InitGoogleTest(&argc, argv);
#if defined(HAVE_SYMBOLIZE) && defined(HAVE_STACKTRACE)
# if defined(__ELF__)
# if defined(HAVE_LINK_H)
// We don't want to get affected by the callback interface, that may be
// used to install some callback function at InitGoogle() time.
InstallSymbolizeCallback(nullptr);
Expand All @@ -472,7 +473,7 @@ int main(int argc, char** argv) {
# else // GLOG_OS_WINDOWS
printf("PASS (no symbolize_unittest support)\n");
return 0;
# endif // __ELF__
# endif // HAVE_LINK_H
#else
printf("PASS (no symbolize support)\n");
return 0;
Expand Down

0 comments on commit 716bc6f

Please sign in to comment.