Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1175)

Unified Diff: base/profiler/win32_stack_frame_unwinder.h

Issue 1423583002: Stack sampling profiler: handle unloaded and unloading modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: fix gcc compile Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/profiler/test_support_library.cc ('k') | base/profiler/win32_stack_frame_unwinder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/win32_stack_frame_unwinder.h
diff --git a/base/profiler/win32_stack_frame_unwinder.h b/base/profiler/win32_stack_frame_unwinder.h
index 3e6c8f0e0a101888259f31c3639b8cf40701b354..18cd9d6e2bd319acca57d736a7432857a43f6425 100644
--- a/base/profiler/win32_stack_frame_unwinder.h
+++ b/base/profiler/win32_stack_frame_unwinder.h
@@ -10,6 +10,7 @@
#include "base/base_export.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/win/scoped_handle.h"
namespace base {
@@ -23,6 +24,26 @@ struct RUNTIME_FUNCTION {
using PRUNTIME_FUNCTION = RUNTIME_FUNCTION*;
#endif // !defined(_WIN64)
+// Traits class to adapt GenericScopedHandle for HMODULES.
+class ModuleHandleTraits : public win::HandleTraits {
+ public:
+ using Handle = HMODULE;
+
+ static bool BASE_EXPORT CloseHandle(HMODULE handle);
+ static bool BASE_EXPORT IsHandleValid(HMODULE handle);
+ static HMODULE BASE_EXPORT NullHandle();
+
+ BASE_EXPORT static const HMODULE kNonNullModuleForTesting;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleHandleTraits);
+};
+
+// HMODULE is not really a handle, and has reference count semantics, so the
+// standard VerifierTraits does not apply.
+using ScopedModuleHandle =
+ win::GenericScopedHandle<ModuleHandleTraits, win::DummyVerifierTraits>;
+
// Instances of this class are expected to be created and destroyed for each
// stack unwinding. This class is not used while the target thread is suspended,
// so may allocate from the default heap.
@@ -40,6 +61,12 @@ class BASE_EXPORT Win32StackFrameUnwinder {
DWORD64 program_counter,
PRUNTIME_FUNCTION runtime_function,
CONTEXT* context) = 0;
+
+ // Returns the module containing |program_counter|. Can return null if the
+ // module has been unloaded.
+ virtual ScopedModuleHandle GetModuleForProgramCounter(
+ DWORD64 program_counter) = 0;
+
protected:
UnwindFunctions();
@@ -50,7 +77,10 @@ class BASE_EXPORT Win32StackFrameUnwinder {
Win32StackFrameUnwinder();
~Win32StackFrameUnwinder();
- bool TryUnwind(CONTEXT* context);
+ // Attempts to unwind the frame represented by the stack and instruction
+ // pointers in |context|. If successful, updates |context| and provides the
+ // module associated with the frame in |module|.
+ bool TryUnwind(CONTEXT* context, ScopedModuleHandle* module);
private:
// This function is for internal and test purposes only.
« no previous file with comments | « base/profiler/test_support_library.cc ('k') | base/profiler/win32_stack_frame_unwinder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698