Index: src/platform-linux.cc |
diff --git a/src/platform-linux.cc b/src/platform-linux.cc |
index 398e9545688c0726e9946eeb0e4eff02b0658902..569561985f04b6bec76d4f6035a7f57557a89b99 100644 |
--- a/src/platform-linux.cc |
+++ b/src/platform-linux.cc |
@@ -68,6 +68,7 @@ |
#include "platform-posix.h" |
#include "platform.h" |
+#include "simulator.h" |
#include "v8threads.h" |
#include "vm-state-inl.h" |
@@ -1097,10 +1098,32 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
Sampler* sampler = isolate->logger()->sampler(); |
if (sampler == NULL || !sampler->IsActive()) return; |
+#if defined(USE_SIMULATOR) |
+#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
Sven Panne
2013/04/11 09:58:02
I think we can remove this #if...
|
+ Isolate::PerIsolateThreadData* per_thread_data = |
+ isolate->FindPerThreadDataForThisThread(); |
+ if (!per_thread_data) return; |
+ Simulator* sim = per_thread_data->simulator(); |
+ // Check if there is active simulator before allocating TickSample. |
+ if (!sim) return; |
+#endif |
+#endif // USE_SIMULATOR |
+ |
TickSample sample_obj; |
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
if (sample == NULL) sample = &sample_obj; |
+#if defined(USE_SIMULATOR) |
+#if V8_TARGET_ARCH_ARM |
+ sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); |
+ sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
+ sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); |
+#elif V8_TARGET_ARCH_MIPS |
+ sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); |
+ sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
+ sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); |
Sven Panne
2013/04/11 09:58:02
... and add an #else followed by #error here.
|
+#endif |
+#else |
// Extracting the sample from the context is extremely machine dependent. |
ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
mcontext_t& mcontext = ucontext->uc_mcontext; |
@@ -1132,6 +1155,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
#endif // V8_HOST_ARCH_* |
+#endif // USE_SIMULATOR |
sampler->SampleStack(sample); |
sampler->Tick(sample); |
#endif // __native_client__ |