Extend absl::Symbolize() tests for invalid PCs and dlopen() cache refresh. Add unit test coverage in `symbolize_test` for unmapped stack addresses, zero-page and top-page boundaries, and non-user-space 64-bit addresses interleaved with valid symbols, and warm up the symbolizer before `dlopen()` in `symbolize_dlopen_test` so dynamic-linker map refresh is exercised on an already-populated address map. PiperOrigin-RevId: 1014242955
diff --git a/absl/debugging/symbolize_test.cc b/absl/debugging/symbolize_test.cc index 9ee0abd..9184f97 100644 --- a/absl/debugging/symbolize_test.cc +++ b/absl/debugging/symbolize_test.cc
@@ -559,6 +559,23 @@ EXPECT_FALSE(absl::Symbolize(static_cast<char*>(region) + 8, symbol_buf, sizeof(symbol_buf))); } + +TEST(Symbolize, InvalidPCs) { + EXPECT_STREQ("nonstatic_func", + TrySymbolize(reinterpret_cast<void*>(&nonstatic_func))); + + char local_var = 0; + for (int i = 0; i < 2; ++i) { + EXPECT_EQ(nullptr, TrySymbolize(&local_var)); + EXPECT_EQ(nullptr, TrySymbolize(reinterpret_cast<void*>(uintptr_t{1}))); + EXPECT_EQ(nullptr, TrySymbolize(reinterpret_cast<void*>(uintptr_t{4095}))); + EXPECT_EQ(nullptr, TrySymbolize(reinterpret_cast<void*>(~uintptr_t{0}))); + EXPECT_EQ(nullptr, TrySymbolize(reinterpret_cast<void*>(intptr_t{-10000}))); + } + + EXPECT_STREQ("Foo::func()", + TrySymbolize(reinterpret_cast<void*>(&Foo::func))); +} #endif // ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE #endif // !ABSL_INTERNAL_HAVE_DARWIN_SYMBOLIZE && // !ABSL_INTERNAL_HAVE_EMSCRIPTEN_SYMBOLIZE