summaryrefslogtreecommitdiff
path: root/absl/debugging/symbolize_emscripten.inc
diff options
context:
space:
mode:
authorGravatar Tom Rybka <trybka@google.com>2023-07-06 09:11:49 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-07-06 09:12:45 -0700
commitc26cd952ae342ac519fd9f98b67e6152f135c6ce (patch)
treed6d2900dbfc0d7b2fd5aad581a2377f0e54ee39c /absl/debugging/symbolize_emscripten.inc
parent512af68a1d397cd2cfa1ac9c6eca7694bf75f2b0 (diff)
symbolize_test: Add an indirection for getting the PC from function ptr.
Don't assume that function ptr == PC. Adds a redirection mechanism, GetPCFromFnPtr, and enables more test cases for Emscripten/Wasm. On many (most?) platforms, the address of a function ptr is the same as its Program Counter (PC) for the purpose of most things, including symbolization. In Emscripten WebAssembly, the function ptr is just an index into a table of functions. However, the name section maps function names to their literal offsets into a Wasm binary. The WasmOffsetConverter is actually capable of both indirections, so we can effectively go from function ptr to offset into the binary (which is typically the "PC" for other Stack dumping things in Wasm, including `emscripten_pc_get_function`). More info: https://www.w3.org/TR/wasm-js-api-2/#exported-function-exotic-objects Also fix Emscripten symbolize handling for `nullptr` now that we have tests for that. PiperOrigin-RevId: 546006678 Change-Id: I0d4015ca9035b004158451b36c933cad009184ba
Diffstat (limited to 'absl/debugging/symbolize_emscripten.inc')
-rw-r--r--absl/debugging/symbolize_emscripten.inc3
1 files changed, 3 insertions, 0 deletions
diff --git a/absl/debugging/symbolize_emscripten.inc b/absl/debugging/symbolize_emscripten.inc
index c226c456..a0f344dd 100644
--- a/absl/debugging/symbolize_emscripten.inc
+++ b/absl/debugging/symbolize_emscripten.inc
@@ -50,6 +50,9 @@ bool Symbolize(const void* pc, char* out, int out_size) {
if (!HaveOffsetConverter()) {
return false;
}
+ if (pc == nullptr || out_size <= 0) {
+ return false;
+ }
const char* func_name = emscripten_pc_get_function(pc);
if (func_name == nullptr) {
return false;