The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
|
|
|
|
// C++ Includes
|
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/lldb-public.h"
|
|
|
|
#include "lldb/lldb-enumerations.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/FormatClasses.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
2011-08-03 01:27:39 +08:00
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2011-07-24 08:14:56 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
#include "lldb/Symbol/ClangASTType.h"
|
|
|
|
#include "lldb/Target/StackFrame.h"
|
2011-07-24 08:14:56 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2011-08-23 08:32:52 +08:00
|
|
|
ValueFormat::ValueFormat (lldb::Format f,
|
|
|
|
bool casc,
|
|
|
|
bool skipptr,
|
|
|
|
bool skipref) :
|
|
|
|
m_cascades(casc),
|
|
|
|
m_skip_pointers(skipptr),
|
|
|
|
m_skip_references(skipref),
|
|
|
|
m_format (f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
std::string
|
|
|
|
ValueFormat::FormatObject(lldb::ValueObjectSP object)
|
|
|
|
{
|
|
|
|
if (!object.get())
|
|
|
|
return "NULL";
|
|
|
|
|
|
|
|
StreamString sstr;
|
|
|
|
|
|
|
|
if (ClangASTType::DumpTypeValue (object->GetClangAST(), // The clang AST
|
|
|
|
object->GetClangType(), // The clang type to display
|
|
|
|
&sstr,
|
|
|
|
m_format, // Format to display this type with
|
|
|
|
object->GetDataExtractor(), // Data to extract from
|
|
|
|
0, // Byte offset into "data"
|
|
|
|
object->GetByteSize(), // Byte size of item in "data"
|
|
|
|
object->GetBitfieldBitSize(), // Bitfield bit size
|
|
|
|
object->GetBitfieldBitOffset())) // Bitfield bit offset
|
|
|
|
return (sstr.GetString());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ("unsufficient data for value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:32:52 +08:00
|
|
|
SummaryFormat::SummaryFormat(bool casc,
|
|
|
|
bool skipptr,
|
|
|
|
bool skipref,
|
|
|
|
bool nochildren,
|
|
|
|
bool novalue,
|
|
|
|
bool oneliner) :
|
|
|
|
m_cascades(casc),
|
|
|
|
m_skip_pointers(skipptr),
|
|
|
|
m_skip_references(skipref),
|
|
|
|
m_dont_show_children(nochildren),
|
|
|
|
m_dont_show_value(novalue),
|
|
|
|
m_show_members_oneliner(oneliner)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StringSummaryFormat::StringSummaryFormat(bool casc,
|
|
|
|
bool skipptr,
|
|
|
|
bool skipref,
|
|
|
|
bool nochildren,
|
|
|
|
bool novalue,
|
|
|
|
bool oneliner,
|
|
|
|
std::string f) :
|
|
|
|
SummaryFormat(casc,
|
|
|
|
skipptr,
|
|
|
|
skipref,
|
|
|
|
nochildren,
|
|
|
|
novalue,
|
|
|
|
oneliner),
|
|
|
|
m_format(f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
std::string
|
|
|
|
StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
|
|
|
|
{
|
|
|
|
if (!object.get())
|
|
|
|
return "NULL";
|
|
|
|
|
|
|
|
StreamString s;
|
|
|
|
ExecutionContext exe_ctx;
|
|
|
|
object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
|
|
|
|
SymbolContext sc;
|
|
|
|
if (exe_ctx.frame)
|
|
|
|
sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
|
|
|
|
|
|
|
|
if (m_show_members_oneliner)
|
|
|
|
{
|
2011-08-18 06:13:59 +08:00
|
|
|
ValueObjectSP synth_valobj = object->GetSyntheticValue(lldb::eUseSyntheticFilter);
|
|
|
|
const uint32_t num_children = synth_valobj->GetNumChildren();
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
if (num_children)
|
|
|
|
{
|
|
|
|
s.PutChar('(');
|
|
|
|
|
|
|
|
for (uint32_t idx=0; idx<num_children; ++idx)
|
|
|
|
{
|
2011-08-18 06:13:59 +08:00
|
|
|
lldb::ValueObjectSP child_sp(synth_valobj->GetChildAtIndex(idx, true));
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
if (child_sp.get())
|
|
|
|
{
|
|
|
|
if (idx)
|
|
|
|
s.PutCString(", ");
|
|
|
|
s.PutCString(child_sp.get()->GetName().AsCString());
|
|
|
|
s.PutChar('=');
|
2011-08-04 10:34:29 +08:00
|
|
|
child_sp.get()->GetPrintableRepresentation(s);
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s.PutChar(')');
|
|
|
|
|
|
|
|
return s.GetString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get()))
|
|
|
|
return s.GetString();
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
StringSummaryFormat::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf ("`%s`%s%s%s%s%s%s", m_format.c_str(),
|
|
|
|
m_cascades ? "" : " (not cascading)",
|
|
|
|
m_dont_show_children ? "" : " (show children)",
|
|
|
|
m_dont_show_value ? " (hide value)" : "",
|
|
|
|
m_show_members_oneliner ? " (one-line printout)" : "",
|
|
|
|
m_skip_pointers ? " (skip pointers)" : "",
|
|
|
|
m_skip_references ? " (skip references)" : "");
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:32:52 +08:00
|
|
|
ScriptSummaryFormat::ScriptSummaryFormat(bool casc,
|
|
|
|
bool skipptr,
|
|
|
|
bool skipref,
|
|
|
|
bool nochildren,
|
|
|
|
bool novalue,
|
|
|
|
bool oneliner,
|
|
|
|
std::string fname,
|
|
|
|
std::string pscri) :
|
|
|
|
SummaryFormat(casc,
|
|
|
|
skipptr,
|
|
|
|
skipref,
|
|
|
|
nochildren,
|
|
|
|
novalue,
|
|
|
|
oneliner),
|
|
|
|
m_function_name(fname),
|
|
|
|
m_python_script(pscri)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
std::string
|
|
|
|
ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object)
|
|
|
|
{
|
2011-08-03 01:27:39 +08:00
|
|
|
lldb::ValueObjectSP target_object;
|
|
|
|
if (object->GetIsExpressionResult() &&
|
|
|
|
ClangASTContext::IsPointerType(object->GetClangType()) &&
|
|
|
|
object->GetValue().GetValueType() == Value::eValueTypeHostAddress)
|
|
|
|
{
|
|
|
|
// when using the expression parser, an additional layer of "frozen data"
|
|
|
|
// can be created, which is basically a byte-exact copy of the data returned
|
|
|
|
// by the expression, but in host memory. because Python code might need to read
|
|
|
|
// into the object memory in non-obvious ways, we need to hand it the target version
|
|
|
|
// of the expression output
|
2011-08-22 10:49:39 +08:00
|
|
|
lldb::addr_t tgt_address = object->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
|
2011-08-03 01:27:39 +08:00
|
|
|
target_object = ValueObjectConstResult::Create (object->GetExecutionContextScope(),
|
|
|
|
object->GetClangAST(),
|
|
|
|
object->GetClangType(),
|
|
|
|
object->GetName(),
|
|
|
|
tgt_address,
|
|
|
|
eAddressTypeLoad,
|
|
|
|
object->GetUpdatePoint().GetProcessSP()->GetAddressByteSize());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
target_object = object;
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(),
|
2011-08-03 01:27:39 +08:00
|
|
|
target_object).c_str());
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ScriptSummaryFormat::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf ("%s%s%s%s%s%s\n%s", m_cascades ? "" : " (not cascading)",
|
|
|
|
m_dont_show_children ? "" : " (show children)",
|
|
|
|
m_dont_show_value ? " (hide value)" : "",
|
|
|
|
m_show_members_oneliner ? " (one-line printout)" : "",
|
|
|
|
m_skip_pointers ? " (skip pointers)" : "",
|
|
|
|
m_skip_references ? " (skip references)" : "",
|
|
|
|
m_python_script.c_str());
|
|
|
|
return sstr.GetString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-07-22 08:16:08 +08:00
|
|
|
std::string
|
|
|
|
SyntheticFilter::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf("%s%s%s {\n",
|
|
|
|
m_cascades ? "" : " (not cascading)",
|
|
|
|
m_skip_pointers ? " (skip pointers)" : "",
|
|
|
|
m_skip_references ? " (skip references)" : "");
|
|
|
|
|
|
|
|
for (int i = 0; i < GetCount(); i++)
|
|
|
|
{
|
|
|
|
sstr.Printf(" %s\n",
|
|
|
|
GetExpressionPathAtIndex(i).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
sstr.Printf("}");
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
2011-07-24 08:14:56 +08:00
|
|
|
|
2011-08-20 05:13:46 +08:00
|
|
|
std::string
|
|
|
|
SyntheticArrayView::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf("%s%s%s {\n",
|
|
|
|
m_cascades ? "" : " (not cascading)",
|
|
|
|
m_skip_pointers ? " (skip pointers)" : "",
|
|
|
|
m_skip_references ? " (skip references)" : "");
|
|
|
|
SyntheticArrayRange* ptr = &m_head;
|
|
|
|
while (ptr && ptr != m_tail)
|
|
|
|
{
|
|
|
|
if (ptr->GetLow() == ptr->GetHigh())
|
|
|
|
sstr.Printf(" [%d]\n",
|
|
|
|
ptr->GetLow());
|
|
|
|
else
|
|
|
|
sstr.Printf(" [%d-%d]\n",
|
|
|
|
ptr->GetLow(),
|
|
|
|
ptr->GetHigh());
|
|
|
|
ptr = ptr->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
sstr.Printf("}");
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
|
|
|
|
2011-07-24 08:14:56 +08:00
|
|
|
SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass,
|
|
|
|
lldb::ValueObjectSP be) :
|
2011-08-22 10:49:39 +08:00
|
|
|
SyntheticChildrenFrontEnd(be),
|
|
|
|
m_python_class(pclass)
|
2011-07-24 08:14:56 +08:00
|
|
|
{
|
2011-07-26 00:59:05 +08:00
|
|
|
if (be.get() == NULL)
|
|
|
|
{
|
|
|
|
m_interpreter = NULL;
|
|
|
|
m_wrapper = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-03 01:27:39 +08:00
|
|
|
if (be->GetIsExpressionResult() &&
|
|
|
|
ClangASTContext::IsPointerType(be->GetClangType()) &&
|
|
|
|
be->GetValue().GetValueType() == Value::eValueTypeHostAddress)
|
|
|
|
{
|
|
|
|
// when using the expression parser, an additional layer of "frozen data"
|
|
|
|
// can be created, which is basically a byte-exact copy of the data returned
|
|
|
|
// by the expression, but in host memory. because Python code might need to read
|
|
|
|
// into the object memory in non-obvious ways, we need to hand it the target version
|
|
|
|
// of the expression output
|
2011-08-22 10:49:39 +08:00
|
|
|
lldb::addr_t tgt_address = be->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
|
2011-08-03 01:27:39 +08:00
|
|
|
m_backend = ValueObjectConstResult::Create (be->GetExecutionContextScope(),
|
|
|
|
be->GetClangAST(),
|
|
|
|
be->GetClangType(),
|
|
|
|
be->GetName(),
|
|
|
|
tgt_address,
|
|
|
|
eAddressTypeLoad,
|
|
|
|
be->GetUpdatePoint().GetProcessSP()->GetAddressByteSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_interpreter = m_backend->GetUpdatePoint().GetTargetSP()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
|
2011-07-26 00:59:05 +08:00
|
|
|
|
|
|
|
if (m_interpreter == NULL)
|
|
|
|
m_wrapper = NULL;
|
|
|
|
else
|
|
|
|
m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
|
2011-07-24 08:14:56 +08:00
|
|
|
}
|
|
|
|
|
2011-08-23 08:32:52 +08:00
|
|
|
lldb::ValueObjectSP
|
|
|
|
SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create)
|
|
|
|
{
|
|
|
|
if (m_wrapper == NULL || m_interpreter == NULL)
|
|
|
|
return lldb::ValueObjectSP();
|
|
|
|
|
|
|
|
PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx);
|
|
|
|
if (py_return == NULL || py_return == Py_None)
|
|
|
|
{
|
|
|
|
Py_XDECREF(py_return);
|
|
|
|
return lldb::ValueObjectSP();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return);
|
|
|
|
|
|
|
|
if (py_return == NULL || sb_ptr == NULL)
|
|
|
|
return lldb::ValueObjectSP();
|
|
|
|
|
|
|
|
return sb_ptr->m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2011-07-24 08:14:56 +08:00
|
|
|
std::string
|
|
|
|
SyntheticScriptProvider::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
2011-07-26 00:59:05 +08:00
|
|
|
sstr.Printf("%s%s%s Python class %s",
|
2011-07-24 08:14:56 +08:00
|
|
|
m_cascades ? "" : " (not cascading)",
|
|
|
|
m_skip_pointers ? " (skip pointers)" : "",
|
|
|
|
m_skip_references ? " (skip references)" : "",
|
|
|
|
m_python_class.c_str());
|
|
|
|
|
|
|
|
return sstr.GetString();
|
2011-08-10 10:10:13 +08:00
|
|
|
}
|
2011-08-23 08:32:52 +08:00
|
|
|
|
|
|
|
const int
|
|
|
|
SyntheticArrayView::GetRealIndexForIndex(int i)
|
|
|
|
{
|
|
|
|
if (i >= GetCount())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
SyntheticArrayRange* ptr = &m_head;
|
|
|
|
|
|
|
|
int residual = i;
|
|
|
|
|
|
|
|
while(ptr && ptr != m_tail)
|
|
|
|
{
|
|
|
|
if (residual >= ptr->GetSelfCount())
|
|
|
|
{
|
|
|
|
residual -= ptr->GetSelfCount();
|
|
|
|
ptr = ptr->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr->GetLow() + residual;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs)
|
|
|
|
{
|
|
|
|
const char* name_cstr = name_cs.GetCString();
|
|
|
|
if (*name_cstr != '[')
|
|
|
|
return UINT32_MAX;
|
|
|
|
std::string name(name_cstr+1);
|
|
|
|
if (name[name.size()-1] != ']')
|
|
|
|
return UINT32_MAX;
|
|
|
|
name = name.erase(name.size()-1,1);
|
|
|
|
int index = Args::StringToSInt32 (name.c_str(), -1);
|
|
|
|
if (index < 0)
|
|
|
|
return UINT32_MAX;
|
|
|
|
return index;
|
|
|
|
}
|