summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-08-11 15:51:40 +0000
committerReid Kleckner <rnk@google.com>2015-08-11 15:51:40 +0000
commit7d9e1e125930404a7ebce2e8d584b34a9065d530 (patch)
tree41e0a50188ff1cf634f84ced36f4fe0e4f42d7ad /compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
parent863bfdbfb446adaef767ff514d1f2ffb5d489562 (diff)
downloadbcm5719-llvm-7d9e1e125930404a7ebce2e8d584b34a9065d530.tar.gz
bcm5719-llvm-7d9e1e125930404a7ebce2e8d584b34a9065d530.zip
[Windows] Use llvm-symbolizer before using dbghelp
Summary: llvm-symbolizer understands both PDBs and DWARF, so it's a better bet if it's available. It prints out the function parameter types and column numbers, so I needed to churn the expected test output a bit. This makes most of the llvm-symbolizer subprocessing code target-independent. Pipes on all platforms use fd_t, and we can use the portable ReadFromFile / WriteToFile wrappers in symbolizer_sanitizer.cc. Only the pipe creation and process spawning is Windows-specific. Please check that the libcdep layering is still correct. I don't know how to reproduce the build configuration that relies on that. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11791 llvm-svn: 244616
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h57
1 files changed, 49 insertions, 8 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
index 350e2a785dd..ac9a5e4a766 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
@@ -74,21 +74,27 @@ class SymbolizerProcess {
explicit SymbolizerProcess(const char *path, bool use_forkpty = false);
const char *SendCommand(const char *command);
- private:
- bool Restart();
- const char *SendCommandImpl(const char *command);
- bool ReadFromSymbolizer(char *buffer, uptr max_length);
- bool WriteToSymbolizer(const char *buffer, uptr length);
- bool StartSymbolizerSubprocess();
-
+ protected:
virtual bool ReachedEndOfOutput(const char *buffer, uptr length) const {
UNIMPLEMENTED();
}
- virtual void ExecuteWithDefaultArgs(const char *path_to_binary) const {
+ /// The maximum number of arguments required to invoke a tool process.
+ enum { kArgVMax = 6 };
+
+ /// Fill in an argv array to invoke the child process.
+ virtual void GetArgV(const char *path_to_binary,
+ const char *(&argv)[kArgVMax]) const {
UNIMPLEMENTED();
}
+ private:
+ bool Restart();
+ const char *SendCommandImpl(const char *command);
+ bool ReadFromSymbolizer(char *buffer, uptr max_length);
+ bool WriteToSymbolizer(const char *buffer, uptr length);
+ bool StartSymbolizerSubprocess();
+
const char *path_;
fd_t input_fd_;
fd_t output_fd_;
@@ -104,6 +110,41 @@ class SymbolizerProcess {
bool use_forkpty_;
};
+class LLVMSymbolizerProcess;
+
+// This tool invokes llvm-symbolizer in a subprocess. It should be as portable
+// as the llvm-symbolizer tool is.
+class LLVMSymbolizer : public SymbolizerTool {
+ public:
+ explicit LLVMSymbolizer(const char *path, LowLevelAllocator *allocator);
+
+ bool SymbolizePC(uptr addr, SymbolizedStack *stack) override;
+
+ bool SymbolizeData(uptr addr, DataInfo *info) override;
+
+ private:
+ const char *SendCommand(bool is_data, const char *module_name,
+ uptr module_offset);
+
+ LLVMSymbolizerProcess *symbolizer_process_;
+ static const uptr kBufferSize = 16 * 1024;
+ char buffer_[kBufferSize];
+};
+
+// Parses one or more two-line strings in the following format:
+// <function_name>
+// <file_name>:<line_number>[:<column_number>]
+// Used by LLVMSymbolizer, Addr2LinePool and InternalSymbolizer, since all of
+// them use the same output format. Returns true if any useful debug
+// information was found.
+void ParseSymbolizePCOutput(const char *str, SymbolizedStack *res);
+
+// Parses a two-line string in the following format:
+// <symbol_name>
+// <start_address> <size>
+// Used by LLVMSymbolizer and InternalSymbolizer.
+void ParseSymbolizeDataOutput(const char *str, DataInfo *info);
+
} // namespace __sanitizer
#endif // SANITIZER_SYMBOLIZER_INTERNAL_H
OpenPOWER on IntegriCloud