Files
clang-p2996/lldb/source/Utility/ArchDefaultUnwindPlan.cpp
Greg Clayton e576ab2996 All UnwindPlan objects are now passed around as shared pointers.
ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture 
instead of being leaked for every frame.

Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and
ArchDefaultUnwindPlan_i386 interfaces.

There were sporadic crashes that were due to something leaking or being 
destroyed when doing stack crawls. This patch should clear up these issues.

llvm-svn: 125541
2011-02-15 00:19:15 +00:00

55 lines
1.6 KiB
C++

//===-- ArchDefaultUnwindPlan.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/PluginManager.h"
#include <map>
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/ArchDefaultUnwindPlan.h"
using namespace lldb;
using namespace lldb_private;
ArchDefaultUnwindPlanSP
ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch)
{
ArchDefaultUnwindPlanCreateInstance create_callback;
typedef std::map <const ArchSpec, ArchDefaultUnwindPlanSP> ArchDefaultUnwindPlanMap;
static ArchDefaultUnwindPlanMap g_plugin_map;
static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive);
Mutex::Locker locker (g_plugin_map_mutex);
ArchDefaultUnwindPlanMap::iterator pos = g_plugin_map.find (arch);
if (pos != g_plugin_map.end())
return pos->second;
for (uint32_t idx = 0;
(create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL;
++idx)
{
ArchDefaultUnwindPlanSP default_unwind_plan_sp (create_callback (arch));
if (default_unwind_plan_sp)
{
g_plugin_map[arch] = default_unwind_plan_sp;
return default_unwind_plan_sp;
}
}
return ArchDefaultUnwindPlanSP();
}
ArchDefaultUnwindPlan::ArchDefaultUnwindPlan ()
{
}
ArchDefaultUnwindPlan::~ArchDefaultUnwindPlan ()
{
}