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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.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
|
|
|
// C Includes
|
2011-11-04 11:34:56 +08:00
|
|
|
|
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
|
|
|
// C++ Includes
|
|
|
|
|
|
|
|
// 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"
|
2012-02-29 11:28:49 +08:00
|
|
|
#include "lldb/Core/Timer.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;
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeFormatImpl::TypeFormatImpl (lldb::Format f,
|
|
|
|
const Flags& flags) :
|
|
|
|
m_flags(flags),
|
2011-08-23 08:32:52 +08:00
|
|
|
m_format (f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
std::string
|
|
|
|
TypeFormatImpl::GetDescription()
|
2011-08-23 08:32:52 +08:00
|
|
|
{
|
2012-02-15 10:34:21 +08:00
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf ("%s%s%s%s\n",
|
|
|
|
FormatManager::GetFormatAsCString (GetFormat()),
|
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "");
|
|
|
|
return sstr.GetString();
|
2011-08-23 08:32:52 +08:00
|
|
|
}
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeSummaryImpl::TypeSummaryImpl(const TypeSummaryImpl::Flags& flags) :
|
|
|
|
m_flags(flags)
|
2011-08-23 08:32:52 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
|
|
|
|
const char *format_cstr) :
|
|
|
|
TypeSummaryImpl(flags),
|
|
|
|
m_format()
|
|
|
|
{
|
|
|
|
if (format_cstr)
|
|
|
|
m_format.assign(format_cstr);
|
|
|
|
}
|
|
|
|
|
2012-02-29 11:28:49 +08:00
|
|
|
bool
|
2012-03-20 06:58:49 +08:00
|
|
|
StringSummaryFormat::FormatObject(ValueObject *valobj,
|
2012-02-29 11:28:49 +08:00
|
|
|
std::string& retval)
|
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
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
if (!valobj)
|
2012-02-29 11:28:49 +08:00
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
retval.assign("NULL ValueObject");
|
2012-02-29 11:28:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
StreamString s;
|
2012-03-20 06:58:49 +08:00
|
|
|
ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
|
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
|
|
|
SymbolContext sc;
|
2011-09-22 12:58:26 +08:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame)
|
|
|
|
sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
|
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
|
|
|
|
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
2012-02-03 07:34:52 +08:00
|
|
|
if (IsOneliner())
|
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
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
ValueObject* object;
|
|
|
|
|
|
|
|
ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
|
|
|
|
if (synth_valobj)
|
|
|
|
object = synth_valobj.get();
|
|
|
|
else
|
|
|
|
object = valobj;
|
|
|
|
|
|
|
|
const uint32_t num_children = object->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)
|
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
lldb::ValueObjectSP child_sp(object->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(", ");
|
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
2012-02-03 07:34:52 +08:00
|
|
|
if (!HideNames())
|
|
|
|
{
|
|
|
|
s.PutCString(child_sp.get()->GetName().AsCString());
|
2012-03-20 06:58:49 +08:00
|
|
|
s.PutCString(" = ");
|
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
2012-02-03 07:34:52 +08:00
|
|
|
}
|
2012-03-20 06:58:49 +08:00
|
|
|
child_sp.get()->DumpPrintableRepresentation(s,
|
|
|
|
ValueObject::eValueObjectRepresentationStyleSummary,
|
|
|
|
lldb::eFormatInvalid,
|
|
|
|
ValueObject::ePrintableRepresentationSpecialCasesDisable);
|
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(')');
|
|
|
|
|
2012-02-29 11:28:49 +08:00
|
|
|
retval.assign(s.GetString());
|
|
|
|
return 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
|
|
|
}
|
|
|
|
else
|
2012-02-29 11:28:49 +08:00
|
|
|
{
|
|
|
|
retval.assign("error: oneliner for no children");
|
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-20 06:58:49 +08:00
|
|
|
if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
|
2012-02-29 11:28:49 +08:00
|
|
|
{
|
|
|
|
retval.assign(s.GetString());
|
|
|
|
return 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
|
|
|
else
|
2012-02-29 11:28:49 +08:00
|
|
|
{
|
|
|
|
retval.assign("error: summary string parsing error");
|
|
|
|
return false;
|
|
|
|
}
|
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::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
2012-02-03 07:34:52 +08:00
|
|
|
|
|
|
|
sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
|
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
!DoesPrintChildren() ? "" : " (show children)",
|
|
|
|
!DoesPrintValue() ? " (hide value)" : "",
|
|
|
|
IsOneliner() ? " (one-line printout)" : "",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "",
|
|
|
|
HideNames() ? " (hide member names)" : "");
|
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 sstr.GetString();
|
|
|
|
}
|
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
|
|
|
|
Callback impl,
|
|
|
|
const char* description) :
|
|
|
|
TypeSummaryImpl(flags),
|
|
|
|
m_impl(impl),
|
|
|
|
m_description(description ? description : "")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
|
|
|
|
std::string& dest)
|
|
|
|
{
|
|
|
|
dest.clear();
|
|
|
|
StreamString stream;
|
|
|
|
if (!m_impl || m_impl(*valobj,stream) == false)
|
|
|
|
return false;
|
|
|
|
dest.assign(stream.GetData());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
CXXFunctionSummaryFormat::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),m_impl,
|
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
!DoesPrintChildren() ? "" : " (show children)",
|
|
|
|
!DoesPrintValue() ? " (hide value)" : "",
|
|
|
|
IsOneliner() ? " (one-line printout)" : "",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "",
|
|
|
|
HideNames() ? " (hide member names)" : "");
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
|
|
|
|
2011-11-04 11:34:56 +08:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
|
|
|
|
ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
|
|
|
|
const char * function_name,
|
|
|
|
const char * python_script) :
|
|
|
|
TypeSummaryImpl(flags),
|
|
|
|
m_function_name(),
|
2012-02-29 11:28:49 +08:00
|
|
|
m_python_script(),
|
|
|
|
m_script_function_sp()
|
2011-08-23 08:32:52 +08:00
|
|
|
{
|
2012-02-15 10:34:21 +08:00
|
|
|
if (function_name)
|
|
|
|
m_function_name.assign(function_name);
|
|
|
|
if (python_script)
|
|
|
|
m_python_script.assign(python_script);
|
2011-08-23 08:32:52 +08:00
|
|
|
}
|
|
|
|
|
2012-02-29 11:28:49 +08:00
|
|
|
bool
|
2012-03-20 06:58:49 +08:00
|
|
|
ScriptSummaryFormat::FormatObject(ValueObject *valobj,
|
2012-02-29 11:28:49 +08:00
|
|
|
std::string& retval)
|
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
|
|
|
{
|
2012-02-29 11:28:49 +08:00
|
|
|
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
|
|
|
|
|
2012-03-20 06:58:49 +08:00
|
|
|
TargetSP target_sp(valobj->GetTargetSP());
|
|
|
|
|
|
|
|
if (!target_sp)
|
|
|
|
{
|
|
|
|
retval.assign("error: no target");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
|
|
|
|
|
2012-02-29 11:28:49 +08:00
|
|
|
if (!script_interpreter)
|
|
|
|
{
|
|
|
|
retval.assign("error: no ScriptInterpreter");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
|
2012-03-20 06:58:49 +08:00
|
|
|
valobj->GetSP(),
|
2012-02-29 11:28:49 +08:00
|
|
|
m_script_function_sp,
|
|
|
|
retval);
|
|
|
|
|
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;
|
Added a new --omit-names (-O, uppercase letter o) option to "type summary add".
When used in conjunction with --inline-children, this option will cause the names of the values to be omitted from the output. This can be beneficial in cases such as vFloat, where it will compact the representation from
([0]=1,[1]=2,[2]=3,[3]=4) to (1, 2, 3, 4).
Added a test case to check that the new option works correctly.
Also took some time to revisit SummaryFormat and related classes and tweak them for added readability and maintainability.
Finally, added a new class name to which the std::string summary should be applied.
llvm-svn: 149644
2012-02-03 07:34:52 +08:00
|
|
|
sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
|
|
|
|
!DoesPrintChildren() ? "" : " (show children)",
|
|
|
|
!DoesPrintValue() ? " (hide value)" : "",
|
|
|
|
IsOneliner() ? " (one-line printout)" : "",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "",
|
|
|
|
HideNames() ? " (hide member names)" : "",
|
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
|
|
|
m_python_script.c_str());
|
|
|
|
return sstr.GetString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-11-04 11:34:56 +08:00
|
|
|
#endif // #ifndef LLDB_DISABLE_PYTHON
|
|
|
|
|
2011-07-22 08:16:08 +08:00
|
|
|
std::string
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeFilterImpl::GetDescription()
|
2011-07-22 08:16:08 +08:00
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf("%s%s%s {\n",
|
2012-02-15 10:34:21 +08:00
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "");
|
2011-07-22 08:16:08 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < GetCount(); i++)
|
|
|
|
{
|
|
|
|
sstr.Printf(" %s\n",
|
2012-02-15 10:34:21 +08:00
|
|
|
GetExpressionPathAtIndex(i));
|
2011-07-22 08:16:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sstr.Printf("}");
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
2011-07-24 08:14:56 +08:00
|
|
|
|
2012-09-14 02:27:09 +08:00
|
|
|
std::string
|
|
|
|
CXXSyntheticChildren::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf("%s%s%s Generator at %p - %s\n",
|
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "",
|
|
|
|
m_create_callback,
|
|
|
|
m_description.c_str());
|
|
|
|
|
|
|
|
return sstr.GetString();
|
|
|
|
}
|
|
|
|
|
2011-08-20 05:13:46 +08:00
|
|
|
std::string
|
|
|
|
SyntheticArrayView::GetDescription()
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
|
|
|
sstr.Printf("%s%s%s {\n",
|
2012-02-15 10:34:21 +08:00
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "");
|
|
|
|
|
2011-08-20 05:13:46 +08:00
|
|
|
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-11-04 11:34:56 +08:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
|
|
|
|
2012-03-20 06:58:49 +08:00
|
|
|
TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
|
|
|
|
SyntheticChildrenFrontEnd(backend),
|
2012-03-07 07:42:15 +08:00
|
|
|
m_python_class(pclass),
|
|
|
|
m_wrapper_sp(),
|
|
|
|
m_interpreter(NULL)
|
2011-07-24 08:14:56 +08:00
|
|
|
{
|
2012-09-13 22:46:00 +08:00
|
|
|
if (backend == LLDB_INVALID_UID)
|
2012-03-20 06:58:49 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
TargetSP target_sp = backend.GetTargetSP();
|
|
|
|
|
|
|
|
if (!target_sp)
|
2011-07-26 00:59:05 +08:00
|
|
|
return;
|
|
|
|
|
2012-03-20 06:58:49 +08:00
|
|
|
m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
|
2011-07-26 00:59:05 +08:00
|
|
|
|
2012-03-07 07:42:15 +08:00
|
|
|
if (m_interpreter != NULL)
|
2012-03-20 06:58:49 +08:00
|
|
|
m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, backend.GetSP());
|
2011-10-24 00:49:03 +08:00
|
|
|
}
|
|
|
|
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeSyntheticImpl::FrontEnd::~FrontEnd()
|
2011-10-24 00:49:03 +08:00
|
|
|
{
|
2011-07-24 08:14:56 +08:00
|
|
|
}
|
|
|
|
|
2011-08-23 08:32:52 +08:00
|
|
|
lldb::ValueObjectSP
|
2012-09-14 02:27:09 +08:00
|
|
|
TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx)
|
2011-08-23 08:32:52 +08:00
|
|
|
{
|
2012-03-07 07:42:15 +08:00
|
|
|
if (!m_wrapper_sp || !m_interpreter)
|
2011-08-23 08:32:52 +08:00
|
|
|
return lldb::ValueObjectSP();
|
|
|
|
|
2012-03-07 07:42:15 +08:00
|
|
|
return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
|
2011-08-23 08:32:52 +08:00
|
|
|
}
|
|
|
|
|
2011-07-24 08:14:56 +08:00
|
|
|
std::string
|
2012-02-15 10:34:21 +08:00
|
|
|
TypeSyntheticImpl::GetDescription()
|
2011-07-24 08:14:56 +08:00
|
|
|
{
|
|
|
|
StreamString sstr;
|
2011-07-26 00:59:05 +08:00
|
|
|
sstr.Printf("%s%s%s Python class %s",
|
2012-02-15 10:34:21 +08:00
|
|
|
Cascades() ? "" : " (not cascading)",
|
|
|
|
SkipsPointers() ? " (skip pointers)" : "",
|
|
|
|
SkipsReferences() ? " (skip references)" : "",
|
2011-07-24 08:14:56 +08:00
|
|
|
m_python_class.c_str());
|
|
|
|
|
|
|
|
return sstr.GetString();
|
2011-08-10 10:10:13 +08:00
|
|
|
}
|
2011-08-23 08:32:52 +08:00
|
|
|
|
2011-11-04 11:34:56 +08:00
|
|
|
#endif // #ifndef LLDB_DISABLE_PYTHON
|
|
|
|
|
2011-11-01 06:50:37 +08:00
|
|
|
int
|
2011-08-23 08:32:52 +08:00
|
|
|
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;
|
2011-10-12 08:53:29 +08:00
|
|
|
}
|