llvm-project/lldb/source/Expression/ClangPersistentVariables.cpp
Sean Callanan 5b26f27f46 I have brought LLDB up-to-date with top of tree
LLVM/Clang.  This brings in several fixes, including:

- Improvements in the Just-In-Time compiler's
  allocation of memory: the JIT now allocates
  memory in chunks of sections, improving its
  ability to generate relocations.  I have
  revamped the RecordingMemoryManager to reflect
  these changes, as well as to get the memory
  allocation and data copying out fo the
  ClangExpressionParser code.  Jim Grosbach wrote
  the updates to the JIT on the LLVM side.

- A new ExternalASTSource interface to allow LLDB to
  report accurate structure layout information to
  Clang.  Previously we could only report the sizes
  of fields, not their offsets.  This meant that if
  data structures included field alignment
  directives, we could not communicate the necessary
  alignment to Clang and accesses to the data would
  fail.  Now we can (and I have update the relevant
  test case).  Thanks to Doug Gregor for implementing
  the Clang side of this fix.

- The way Objective-C interfaces are completed by
  Clang has been made consistent with RecordDecls;
  with help from Doug Gregor and Greg Clayton I have
  ensured that this still works.

- I have eliminated all local LLVM and Clang patches,
  committing the ones that are still relevant to LLVM
  and Clang as needed.

I have tested the changes extensively locally, but
please let me know if they cause any trouble for you.

llvm-svn: 149775
2012-02-04 08:49:35 +00:00

90 lines
2.7 KiB
C++

//===-- ClangPersistentVariables.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/Expression/ClangPersistentVariables.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "llvm/ADT/StringMap.h"
using namespace lldb;
using namespace lldb_private;
ClangPersistentVariables::ClangPersistentVariables () :
ClangExpressionVariableList(),
m_next_persistent_variable_id (0)
{
}
ClangExpressionVariableSP
ClangPersistentVariables::CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp)
{
ClangExpressionVariableSP var_sp (CreateVariable(valobj_sp));
return var_sp;
}
ClangExpressionVariableSP
ClangPersistentVariables::CreatePersistentVariable (ExecutionContextScope *exe_scope,
const ConstString &name,
const TypeFromUser& user_type,
lldb::ByteOrder byte_order,
uint32_t addr_byte_size)
{
ClangExpressionVariableSP var_sp (GetVariable(name));
if (!var_sp)
var_sp = CreateVariable(exe_scope, name, user_type, byte_order, addr_byte_size);
return var_sp;
}
void
ClangPersistentVariables::RemovePersistentVariable (lldb::ClangExpressionVariableSP variable)
{
RemoveVariable(variable);
const char *name = variable->GetName().AsCString();
if (*name != '$')
return;
name++;
if (strtoul(name, NULL, 0) == m_next_persistent_variable_id - 1)
m_next_persistent_variable_id--;
}
ConstString
ClangPersistentVariables::GetNextPersistentVariableName ()
{
char name_cstr[256];
::snprintf (name_cstr, sizeof(name_cstr), "$%u", m_next_persistent_variable_id++);
ConstString name(name_cstr);
return name;
}
void
ClangPersistentVariables::RegisterPersistentType (const ConstString &name,
clang::TypeDecl *type_decl)
{
m_persistent_types.insert(std::pair<const char*, clang::TypeDecl*>(name.GetCString(), type_decl));
}
clang::TypeDecl *
ClangPersistentVariables::GetPersistentType (const ConstString &name)
{
PersistentTypeMap::const_iterator i = m_persistent_types.find(name.GetCString());
if (i == m_persistent_types.end())
return NULL;
else
return i->second;
}