Backed out changeset 8d539315541d (bug 1016629)

This commit is contained in:
Carsten "Tomcat" Book 2014-07-25 15:59:49 +02:00
parent 12b71a1f0a
commit be28caabab
3 changed files with 0 additions and 290 deletions

View File

@ -10,42 +10,19 @@
#include "nsScriptSecurityManager.h"
#include "jsfriendapi.h"
#include "prprf.h"
#include "shared-libraries.h"
#include "js/OldDebugAPI.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Move.h"
#include "mozilla/Scoped.h"
#include "google_breakpad/processor/call_stack.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/stack_frame_cpu.h"
#include "processor/basic_code_module.h"
#include "processor/basic_code_modules.h"
#if defined(MOZ_THREADSTACKHELPER_X86)
#include "processor/stackwalker_x86.h"
#elif defined(MOZ_THREADSTACKHELPER_X64)
#include "processor/stackwalker_amd64.h"
#elif defined(MOZ_THREADSTACKHELPER_ARM)
#include "processor/stackwalker_arm.h"
#endif
#include <string.h>
#include <vector>
#ifdef XP_LINUX
#include <unistd.h>
#include <sys/syscall.h>
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX)
#include <pthread.h>
#endif
#ifdef ANDROID
#ifndef SYS_gettid
#define SYS_gettid __NR_gettid
@ -59,15 +36,6 @@
#endif
#endif
#if defined(MOZ_THREADSTACKHELPER_X86) || \
defined(MOZ_THREADSTACKHELPER_X64) || \
defined(MOZ_THREADSTACKHELPER_ARM)
// On these architectures, the stack grows downwards (toward lower addresses).
#define MOZ_THREADSTACKHELPER_STACK_GROWS_DOWN
#else
#error "Unsupported architecture"
#endif
namespace mozilla {
void
@ -111,9 +79,6 @@ ThreadStackHelper::ThreadStackHelper()
: mStackToFill(nullptr)
#ifdef MOZ_THREADSTACKHELPER_PSEUDO
, mPseudoStack(mozilla_get_pseudo_stack())
#endif
#ifdef MOZ_THREADSTACKHELPER_NATIVE
, mContextToFill(nullptr)
#endif
, mMaxStackSize(Stack::sMaxInlineStorage)
, mMaxBufferSize(0)
@ -130,10 +95,6 @@ ThreadStackHelper::ThreadStackHelper()
#elif defined(XP_MACOSX)
mThreadID = mach_thread_self();
#endif
#ifdef MOZ_THREADSTACKHELPER_NATIVE
GetThreadStackBase();
#endif
}
ThreadStackHelper::~ThreadStackHelper()
@ -147,15 +108,6 @@ ThreadStackHelper::~ThreadStackHelper()
#endif
}
#ifdef MOZ_THREADSTACKHELPER_NATIVE
void ThreadStackHelper::GetThreadStackBase()
{
mThreadStackBase = 0;
// TODO get stack base for each platform
}
#endif // MOZ_THREADSTACKHELPER_NATIVE
namespace {
template <typename T>
class ScopedSetPtr
@ -207,10 +159,7 @@ ThreadStackHelper::GetStack(Stack& aStack)
MOZ_ASSERT(false);
return;
}
FillStackBuffer();
FillThreadContext();
MOZ_ALWAYS_TRUE(::ResumeThread(mThreadID) != DWORD(-1));
#elif defined(XP_MACOSX)
@ -218,197 +167,12 @@ ThreadStackHelper::GetStack(Stack& aStack)
MOZ_ASSERT(false);
return;
}
FillStackBuffer();
FillThreadContext();
MOZ_ALWAYS_TRUE(::thread_resume(mThreadID) == KERN_SUCCESS);
#endif
}
#ifdef MOZ_THREADSTACKHELPER_NATIVE
class ThreadStackHelper::CodeModulesProvider
: public google_breakpad::CodeModules {
private:
typedef google_breakpad::CodeModule CodeModule;
typedef google_breakpad::BasicCodeModule BasicCodeModule;
const SharedLibraryInfo mLibs;
mutable ScopedDeletePtr<BasicCodeModule> mModule;
public:
CodeModulesProvider() : mLibs(SharedLibraryInfo::GetInfoForSelf()) {}
virtual ~CodeModulesProvider() {}
virtual unsigned int module_count() const {
return mLibs.GetSize();
}
virtual const CodeModule* GetModuleForAddress(uint64_t address) const {
MOZ_CRASH("Not implemented");
}
virtual const CodeModule* GetMainModule() const {
return nullptr;
}
virtual const CodeModule* GetModuleAtSequence(unsigned int sequence) const {
MOZ_CRASH("Not implemented");
}
virtual const CodeModule* GetModuleAtIndex(unsigned int index) const {
const SharedLibrary& lib = mLibs.GetEntry(index);
mModule = new BasicCodeModule(lib.GetStart(), lib.GetEnd() - lib.GetStart(),
lib.GetName(), lib.GetBreakpadId(),
lib.GetName(), lib.GetBreakpadId(), "");
// Keep mModule valid until the next GetModuleAtIndex call.
return mModule;
}
virtual const CodeModules* Copy() const {
MOZ_CRASH("Not implemented");
}
};
class ThreadStackHelper::ThreadContext
: public google_breakpad::MemoryRegion {
public:
#if defined(MOZ_THREADSTACKHELPER_X86)
typedef MDRawContextX86 Context;
#elif defined(MOZ_THREADSTACKHELPER_X64)
typedef MDRawContextAMD64 Context;
#elif defined(MOZ_THREADSTACKHELPER_ARM)
typedef MDRawContextARM Context;
#endif
// Limit copied stack to 4kB
static const size_t kMaxStackSize = 0x1000;
// Limit unwound stack to 32 frames
static const unsigned int kMaxStackFrames = 32;
// Whether this structure contains valid data
bool mValid;
// Processor context
Context mContext;
// Stack area
ScopedDeleteArray<uint8_t> mStack;
// Start of stack area
uintptr_t mStackBase;
// Size of stack area
size_t mStackSize;
// End of stack area
const void* mStackEnd;
ThreadContext() : mValid(false)
, mStackBase(0)
, mStackSize(0)
, mStackEnd(nullptr) {}
virtual ~ThreadContext() {}
virtual uint64_t GetBase() const {
return uint64_t(mStackBase);
}
virtual uint32_t GetSize() const {
return mStackSize;
}
virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
private:
template <typename T>
bool GetMemoryAtAddressInternal(uint64_t address, T* value) const {
const intptr_t offset = intptr_t(address) - intptr_t(GetBase());
if (offset < 0 || uintptr_t(offset) > (GetSize() - sizeof(T))) {
return false;
}
*value = *reinterpret_cast<const T*>(&mStack[offset]);
return true;
}
};
#endif // MOZ_THREADSTACKHELPER_NATIVE
void
ThreadStackHelper::GetNativeStack(Stack& aStack)
{
#ifdef MOZ_THREADSTACKHELPER_NATIVE
ThreadContext context;
context.mStack = new uint8_t[ThreadContext::kMaxStackSize];
ScopedSetPtr<ThreadContext> contextPtr(mContextToFill, &context);
// Get pseudostack first and fill the thread context.
GetStack(aStack);
NS_ENSURE_TRUE_VOID(context.mValid);
CodeModulesProvider modulesProvider;
google_breakpad::BasicCodeModules modules(&modulesProvider);
google_breakpad::BasicSourceLineResolver resolver;
google_breakpad::StackFrameSymbolizer symbolizer(nullptr, &resolver);
#if defined(MOZ_THREADSTACKHELPER_X86)
google_breakpad::StackwalkerX86 stackWalker(
nullptr, &context.mContext, &context, &modules, &symbolizer);
#elif defined(MOZ_THREADSTACKHELPER_X64)
google_breakpad::StackwalkerAMD64 stackWalker(
nullptr, &context.mContext, &context, &modules, &symbolizer);
#elif defined(MOZ_THREADSTACKHELPER_ARM)
google_breakpad::StackwalkerARM stackWalker(
nullptr, &context.mContext, -1, &context, &modules, &symbolizer);
#else
#error "Unsupported architecture"
#endif
google_breakpad::CallStack callStack;
std::vector<const google_breakpad::CodeModule*> modules_without_symbols;
google_breakpad::Stackwalker::set_max_frames(ThreadContext::kMaxStackFrames);
google_breakpad::Stackwalker::
set_max_frames_scanned(ThreadContext::kMaxStackFrames);
NS_ENSURE_TRUE_VOID(stackWalker.Walk(&callStack, &modules_without_symbols));
const std::vector<google_breakpad::StackFrame*>& frames(*callStack.frames());
for (intptr_t i = frames.size() - 1; i >= 0; i--) {
const google_breakpad::StackFrame& frame = *frames[i];
if (!frame.module) {
continue;
}
const string& module = frame.module->code_file();
#if defined(XP_LINUX) || defined(XP_MACOSX)
const char PATH_SEP = '/';
#elif defined(XP_WIN)
const char PATH_SEP = '\\';
#endif
const char* const module_basename = strrchr(module.c_str(), PATH_SEP);
const char* const module_name = module_basename ?
module_basename + 1 : module.c_str();
char buffer[0x100];
size_t len = 0;
if (!frame.function_name.empty()) {
len = PR_snprintf(buffer, sizeof(buffer), "%s:%s",
module_name, frame.function_name.c_str());
} else {
len = PR_snprintf(buffer, sizeof(buffer), "%s:0x%p",
module_name, (intptr_t)
(frame.instruction - frame.module->base_address()));
}
if (len) {
aStack.AppendViaBuffer(buffer, len);
}
}
#endif // MOZ_THREADSTACKHELPER_NATIVE
}
#ifdef XP_LINUX
int ThreadStackHelper::sInitialized;
@ -421,7 +185,6 @@ ThreadStackHelper::FillStackHandler(int aSignal, siginfo_t* aInfo,
ThreadStackHelper* const helper =
reinterpret_cast<ThreadStackHelper*>(aInfo->si_value.sival_ptr);
helper->FillStackBuffer();
helper->FillThreadContext(aContext);
::sem_post(&helper->mSem);
}
@ -550,11 +313,6 @@ ThreadStackHelper::FillStackBuffer()
prevLabel = AppendJSEntry(entry, availableBufferSize, prevLabel);
continue;
}
#ifdef MOZ_THREADSTACKHELPER_NATIVE
if (mContextToFill) {
mContextToFill->mStackEnd = entry->stackAddress();
}
#endif
const char* const label = entry->label();
if (mStackToFill->IsSameAsEntry(prevLabel, label)) {
continue;
@ -575,17 +333,4 @@ ThreadStackHelper::FillStackBuffer()
#endif
}
void
ThreadStackHelper::FillThreadContext(void* aContext)
{
#ifdef MOZ_THREADSTACKHELPER_NATIVE
if (!mContextToFill) {
return;
}
// TODO fill context for each platform
#endif // MOZ_THREADSTACKHELPER_NATIVE
}
} // namespace mozilla

View File

@ -30,20 +30,6 @@
# endif
#endif
#ifdef MOZ_THREADSTACKHELPER_PSEUDO
# define MOZ_THREADSTACKHELPER_NATIVE
# if defined(__i386__) || defined(_M_IX86)
# define MOZ_THREADSTACKHELPER_X86
# elif defined(__x86_64__) || defined(_M_X64)
# define MOZ_THREADSTACKHELPER_X64
# elif defined(__arm__) || defined(_M_ARM)
# define MOZ_THREADSTACKHELPER_ARM
# else
// Unsupported architecture
# undef MOZ_THREADSTACKHELPER_NATIVE
# endif
#endif
namespace mozilla {
/**
@ -65,28 +51,17 @@ private:
Stack* mStackToFill;
#ifdef MOZ_THREADSTACKHELPER_PSEUDO
const PseudoStack* const mPseudoStack;
#endif
#ifdef MOZ_THREADSTACKHELPER_NATIVE
class CodeModulesProvider;
class ThreadContext;
// Set to non-null if GetStack should get the thread context.
ThreadContext* mContextToFill;
intptr_t mThreadStackBase;
#endif
size_t mMaxStackSize;
size_t mMaxBufferSize;
bool PrepareStackBuffer(Stack& aStack);
void FillStackBuffer();
void FillThreadContext(void* aContext = nullptr);
#ifdef MOZ_THREADSTACKHELPER_PSEUDO
const char* AppendJSEntry(const volatile StackEntry* aEntry,
intptr_t& aAvailableBufferSize,
const char* aPrevLabel);
#endif
#ifdef MOZ_THREADSTACKHELPER_NATIVE
void GetThreadStackBase();
#endif
public:
/**
@ -113,14 +88,6 @@ public:
*/
void GetStack(Stack& aStack);
/**
* Retrieve the current native stack of the thread associated
* with this ThreadStackHelper.
*
* @param aNativeStack Stack instance to be filled.
*/
void GetNativeStack(Stack& aStack);
#if defined(XP_LINUX)
private:
static int sInitialized;

View File

@ -55,8 +55,6 @@ MSVC_ENABLE_PGO = True
LOCAL_INCLUDES += [
'../build',
'/caps',
'/toolkit/crashreporter/google-breakpad/src',
'/tools/profiler',
]
FAIL_ON_WARNINGS = True