From 716bc6f3aa790e168dad14b664eb5131404ab685 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sat, 30 Dec 2023 02:48:45 +0100 Subject: [PATCH] wip --- src/symbolize.h | 26 ++++---------------------- src/symbolize_unittest.cc | 11 ++++++----- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/symbolize.h b/src/symbolize.h index dfd5fec90..b5920bd37 100644 --- a/src/symbolize.h +++ b/src/symbolize.h @@ -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. @@ -86,26 +86,8 @@ #ifdef HAVE_SYMBOLIZE -# if defined(__ELF__) // defined by gcc -# if defined(__OpenBSD__) -# include -# else -# include -# endif - -# if !defined(GLOG_OS_ANDROID) -# include // 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 // For ElfW() macro. // If there is no ElfW macro, let's define it by ourself. # ifndef ElfW @@ -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_ { diff --git a/src/symbolize_unittest.cc b/src/symbolize_unittest.cc index 30945c141..05f9be62a 100644 --- a/src/symbolize_unittest.cc +++ b/src/symbolize_unittest.cc @@ -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) { @@ -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. @@ -449,7 +450,7 @@ __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) { @@ -457,7 +458,7 @@ int main(int argc, char** argv) { 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); @@ -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;