本文整理汇总了C++中Stream::IndentMore方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::IndentMore方法的具体用法?C++ Stream::IndentMore怎么用?C++ Stream::IndentMore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::IndentMore方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void StructuredData::Array::Dump(Stream &s, bool pretty_print) const {
bool first = true;
s << "[";
if (pretty_print) {
s << "\n";
s.IndentMore();
}
for (const auto &item_sp : m_items) {
if (first) {
first = false;
} else {
s << ",";
if (pretty_print)
s << "\n";
}
if (pretty_print)
s.Indent();
item_sp->Dump(s, pretty_print);
}
if (pretty_print) {
s.IndentLess();
s.EOL();
s.Indent();
}
s << "]";
}
示例2: exe_ctx
size_t
Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source)
{
ExecutionContext exe_ctx (shared_from_this());
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
size_t num_frames_shown = 0;
strm.Indent();
bool is_selected = false;
if (process)
{
if (process->GetThreadList().GetSelectedThread().get() == this)
is_selected = true;
}
strm.Printf("%c ", is_selected ? '*' : ' ');
if (target && target->GetDebugger().GetUseExternalEditor())
{
StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
if (frame_sp)
{
SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry));
if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file)
{
Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
}
}
}
DumpUsingSettingsFormat (strm, start_frame);
if (num_frames > 0)
{
strm.IndentMore();
const bool show_frame_info = true;
strm.IndentMore ();
num_frames_shown = GetStackFrameList ()->GetStatus (strm,
start_frame,
num_frames,
show_frame_info,
num_frames_with_source);
strm.IndentLess();
strm.IndentLess();
}
return num_frames_shown;
}
示例3: ConvertTypeMaskToType
void
OptionValueDictionary::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
{
const Type dict_type = ConvertTypeMaskToType (m_type_mask);
if (dump_mask & eDumpOptionType)
{
if (m_type_mask != eTypeInvalid)
strm.Printf ("(%s of %ss)", GetTypeAsCString(), GetBuiltinTypeAsCString(dict_type));
else
strm.Printf ("(%s)", GetTypeAsCString());
}
if (dump_mask & eDumpOptionValue)
{
if (dump_mask & eDumpOptionType)
strm.PutCString (" =");
collection::iterator pos, end = m_values.end();
strm.IndentMore();
for (pos = m_values.begin(); pos != end; ++pos)
{
OptionValue *option_value = pos->second.get();
strm.EOL();
strm.Indent(pos->first.GetCString());
const uint32_t extra_dump_options = m_raw_value_dump ? eDumpOptionRaw : 0;
switch (dict_type)
{
default:
case eTypeArray:
case eTypeDictionary:
case eTypeProperties:
case eTypeFileSpecList:
case eTypePathMap:
strm.PutChar (' ');
option_value->DumpValue(exe_ctx, strm, dump_mask | extra_dump_options);
break;
case eTypeBoolean:
case eTypeChar:
case eTypeEnum:
case eTypeFileSpec:
case eTypeFormat:
case eTypeSInt64:
case eTypeString:
case eTypeUInt64:
case eTypeUUID:
// No need to show the type for dictionaries of simple items
strm.PutCString("=");
option_value->DumpValue(exe_ctx, strm, (dump_mask & (~eDumpOptionType)) | extra_dump_options);
break;
}
}
strm.IndentLess();
}
}
示例4: ConvertTypeMaskToType
void
OptionValueArray::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
{
const Type array_element_type = ConvertTypeMaskToType (m_type_mask);
if (dump_mask & eDumpOptionType)
{
if ((GetType() == eTypeArray) && (m_type_mask != eTypeInvalid))
strm.Printf ("(%s of %ss)", GetTypeAsCString(), GetBuiltinTypeAsCString(array_element_type));
else
strm.Printf ("(%s)", GetTypeAsCString());
}
if (dump_mask & eDumpOptionValue)
{
if (dump_mask & eDumpOptionType)
strm.Printf (" =%s", (m_values.size() > 0) ? "\n" : "");
strm.IndentMore();
const uint32_t size = m_values.size();
for (uint32_t i = 0; i<size; ++i)
{
strm.Indent();
strm.Printf("[%u]: ", i);
const uint32_t extra_dump_options = m_raw_value_dump ? eDumpOptionRaw : 0;
switch (array_element_type)
{
default:
case eTypeArray:
case eTypeDictionary:
case eTypeProperties:
case eTypeFileSpecList:
case eTypePathMap:
m_values[i]->DumpValue(exe_ctx, strm, dump_mask | extra_dump_options);
break;
case eTypeBoolean:
case eTypeChar:
case eTypeEnum:
case eTypeFileSpec:
case eTypeFormat:
case eTypeSInt64:
case eTypeString:
case eTypeUInt64:
case eTypeUUID:
// No need to show the type for dictionaries of simple items
m_values[i]->DumpValue(exe_ctx, strm, (dump_mask & (~eDumpOptionType)) | extra_dump_options);
break;
}
if (i < (size - 1))
strm.EOL();
}
strm.IndentLess();
}
}
示例5: DumpValue
void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
if (dump_mask & eDumpOptionType)
strm.Printf("(%s)", GetTypeAsCString());
if (dump_mask & eDumpOptionValue) {
if (dump_mask & eDumpOptionType)
strm.Printf(" =%s", m_current_value.GetSize() > 0 ? "\n" : "");
strm.IndentMore();
const uint32_t size = m_current_value.GetSize();
for (uint32_t i = 0; i < size; ++i) {
strm.Indent();
strm.Printf("[%u]: ", i);
m_current_value.GetFileSpecAtIndex(i).Dump(&strm);
}
strm.IndentLess();
}
}
示例6: DumpRegisterSet
bool
DumpRegisterSet (const ExecutionContext &exe_ctx,
Stream &strm,
RegisterContext *reg_ctx,
size_t set_idx,
bool primitive_only=false)
{
uint32_t unavailable_count = 0;
uint32_t available_count = 0;
if (!reg_ctx)
return false; // thread has no registers (i.e. core files are corrupt, incomplete crash logs...)
const RegisterSet * const reg_set = reg_ctx->GetRegisterSet(set_idx);
if (reg_set)
{
strm.Printf ("%s:\n", reg_set->name);
strm.IndentMore ();
const size_t num_registers = reg_set->num_registers;
for (size_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
{
const uint32_t reg = reg_set->registers[reg_idx];
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg);
// Skip the dumping of derived register if primitive_only is true.
if (primitive_only && reg_info && reg_info->value_regs)
continue;
if (DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
++available_count;
else
++unavailable_count;
}
strm.IndentLess ();
if (unavailable_count)
{
strm.Indent ();
strm.Printf("%u registers were unavailable.\n", unavailable_count);
}
strm.EOL();
}
return available_count > 0;
}
示例7:
void
StructuredData::Dictionary::Dump (Stream &s) const
{
bool first = true;
s << "{\n";
s.IndentMore();
for (const auto &pair : m_dict)
{
if (first)
first = false;
else
s << ",\n";
s.Indent();
s << "\"" << pair.first.AsCString() << "\" : ";
pair.second->Dump(s);
}
s.IndentLess();
s.EOL();
s.Indent();
s << "}";
}
示例8: DumpCallback
//----------------------------------------------------------------------
// DumpCallback
//
// A callback function for the static DWARFDebugInfo::Parse() function
// that gets called each time a compile unit header or debug information
// entry is successfully parsed.
//
// This function dump DWARF information and obey recurse depth and
// whether a single DIE is to be dumped (or all of the data).
//----------------------------------------------------------------------
static dw_offset_t DumpCallback(SymbolFileDWARF *dwarf2Data,
DWARFCompileUnit *cu, DWARFDebugInfoEntry *die,
const dw_offset_t next_offset,
const uint32_t curr_depth, void *userData) {
DumpInfo *dumpInfo = (DumpInfo *)userData;
Stream *s = dumpInfo->strm;
bool show_parents =
s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
if (die) {
// Are we dumping everything?
if (dumpInfo->die_offset == DW_INVALID_OFFSET) {
// Yes we are dumping everything. Obey our recurse level though
if (curr_depth < dumpInfo->recurse_depth)
die->Dump(dwarf2Data, cu, *s, 0);
} else {
// We are dumping a specific DIE entry by offset
if (dumpInfo->die_offset == die->GetOffset()) {
// We found the DIE we were looking for, dump it!
if (show_parents) {
s->SetIndentLevel(0);
const uint32_t num_ancestors = dumpInfo->ancestors.size();
if (num_ancestors > 0) {
for (uint32_t i = 0; i < num_ancestors - 1; ++i) {
dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0);
s->IndentMore();
}
}
}
dumpInfo->found_depth = curr_depth;
die->Dump(dwarf2Data, cu, *s, 0);
// Note that we found the DIE we were looking for
dumpInfo->found_die = true;
// Since we are dumping a single DIE, if there are no children we are
// done!
if (!die->HasChildren() || dumpInfo->recurse_depth == 0)
return DW_INVALID_OFFSET; // Return an invalid address to end parsing
} else if (dumpInfo->found_die) {
// Are we done with all the children?
if (curr_depth <= dumpInfo->found_depth)
return DW_INVALID_OFFSET;
// We have already found our DIE and are printing it's children. Obey
// our recurse depth and return an invalid offset if we get done
// dumping all of the children
if (dumpInfo->recurse_depth == UINT32_MAX ||
curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth)
die->Dump(dwarf2Data, cu, *s, 0);
} else if (dumpInfo->die_offset > die->GetOffset()) {
if (show_parents)
dumpInfo->ancestors.back() = *die;
}
}
// Keep up with our indent level
if (die->IsNULL()) {
if (show_parents)
dumpInfo->ancestors.pop_back();
if (curr_depth <= 1)
return cu->GetNextCompileUnitOffset();
else
s->IndentLess();
} else if (die->HasChildren()) {
if (show_parents) {
DWARFDebugInfoEntry null_die;
dumpInfo->ancestors.push_back(null_die);
}
s->IndentMore();
}
} else {
if (cu == NULL)
s->PutCString("NULL - cu");
// We have a compile unit, reset our indent level to zero just in case
s->SetIndentLevel(0);
// See if we are dumping everything?
if (dumpInfo->die_offset == DW_INVALID_OFFSET) {
// We are dumping everything
if (cu) {
cu->Dump(s);
return cu->GetFirstDIEOffset(); // Return true to parse all DIEs in this
// Compile Unit
} else {
return DW_INVALID_OFFSET;
}
//.........这里部分代码省略.........
示例9: GetStateVariable
void
CommandInterpreter::OutputFormattedHelpText (Stream &strm,
const char *word_text,
const char *separator,
const char *help_text,
uint32_t max_word_len)
{
StateVariable *var = GetStateVariable ("term-width");
int max_columns = var->GetIntValue();
// Sanity check max_columns, to cope with emacs shell mode with TERM=dumb
// (0 rows; 0 columns;).
if (max_columns <= 0) max_columns = 80;
int indent_size = max_word_len + strlen (separator) + 2;
strm.IndentMore (indent_size);
int len = indent_size + strlen (help_text) + 1;
char *text = (char *) malloc (len);
sprintf (text, "%-*s %s %s", max_word_len, word_text, separator, help_text);
if (text[len - 1] == '\n')
text[--len] = '\0';
if (len < max_columns)
{
// Output it as a single line.
strm.Printf ("%s", text);
}
else
{
// We need to break it up into multiple lines.
bool first_line = true;
int text_width;
int start = 0;
int end = start;
int final_end = strlen (text);
int sub_len;
while (end < final_end)
{
if (first_line)
text_width = max_columns - 1;
else
text_width = max_columns - indent_size - 1;
// Don't start the 'text' on a space, since we're already outputting the indentation.
if (!first_line)
{
while ((start < final_end) && (text[start] == ' '))
start++;
}
end = start + text_width;
if (end > final_end)
end = final_end;
else
{
// If we're not at the end of the text, make sure we break the line on white space.
while (end > start
&& text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
end--;
}
sub_len = end - start;
if (start != 0)
strm.EOL();
if (!first_line)
strm.Indent();
else
first_line = false;
assert (start <= final_end);
assert (start + sub_len <= final_end);
if (sub_len > 0)
strm.Write (text + start, sub_len);
start = end + 1;
}
}
strm.EOL();
strm.IndentLess(indent_size);
free (text);
}
示例10: GenerateOptionUsage
void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd,
uint32_t screen_width) {
const bool only_print_args = cmd->IsDashDashCommand();
auto opt_defs = GetDefinitions();
const uint32_t save_indent_level = strm.GetIndentLevel();
llvm::StringRef name;
StreamString arguments_str;
if (cmd) {
name = cmd->GetCommandName();
cmd->GetFormattedCommandArguments(arguments_str);
} else
name = "";
strm.PutCString("\nCommand Options Usage:\n");
strm.IndentMore(2);
// First, show each usage level set of options, e.g. <cmd>
// [options-for-level-0]
// <cmd>
// [options-for-level-1]
// etc.
const uint32_t num_options = NumCommandOptions();
if (num_options == 0)
return;
uint32_t num_option_sets = GetRequiredOptions().size();
uint32_t i;
if (!only_print_args) {
for (uint32_t opt_set = 0; opt_set < num_option_sets; ++opt_set) {
uint32_t opt_set_mask;
opt_set_mask = 1 << opt_set;
if (opt_set > 0)
strm.Printf("\n");
strm.Indent(name);
// Different option sets may require different args.
StreamString args_str;
if (cmd)
cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
// First go through and print all options that take no arguments as
// a single string. If a command has "-a" "-b" and "-c", this will show
// up as [-abc]
std::set<int> options;
std::set<int>::const_iterator options_pos, options_end;
for (auto &def : opt_defs) {
if (def.usage_mask & opt_set_mask && isprint8(def.short_option)) {
// Add current option to the end of out_stream.
if (def.required && def.option_has_arg == OptionParser::eNoArgument) {
options.insert(def.short_option);
}
}
}
if (options.empty() == false) {
// We have some required options with no arguments
strm.PutCString(" -");
for (i = 0; i < 2; ++i)
for (options_pos = options.begin(), options_end = options.end();
options_pos != options_end; ++options_pos) {
if (i == 0 && ::islower(*options_pos))
continue;
if (i == 1 && ::isupper(*options_pos))
continue;
strm << (char)*options_pos;
}
}
options.clear();
for (auto &def : opt_defs) {
if (def.usage_mask & opt_set_mask && isprint8(def.short_option)) {
// Add current option to the end of out_stream.
if (def.required == false &&
def.option_has_arg == OptionParser::eNoArgument) {
options.insert(def.short_option);
}
}
}
if (options.empty() == false) {
// We have some required options with no arguments
strm.PutCString(" [-");
for (i = 0; i < 2; ++i)
for (options_pos = options.begin(), options_end = options.end();
options_pos != options_end; ++options_pos) {
if (i == 0 && ::islower(*options_pos))
continue;
if (i == 1 && ::isupper(*options_pos))
continue;
//.........这里部分代码省略.........
示例11: range
bool
Disassembler::Disassemble
(
Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
const AddressRange &disasm_range,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm
)
{
if (disasm_range.GetByteSize())
{
Disassembler *disassembler = Disassembler::FindPlugin(arch);
if (disassembler)
{
AddressRange range(disasm_range);
Process *process = exe_ctx.process;
// If we weren't passed in a section offset address range,
// try and resolve it to something
if (range.GetBaseAddress().IsSectionOffset() == false)
{
if (process && process->IsAlive())
{
process->ResolveLoadAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress());
}
else if (exe_ctx.target)
{
exe_ctx.target->GetImages().ResolveFileAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress());
}
}
DataExtractor data;
size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, range, data);
if (bytes_disassembled == 0)
{
return false;
}
else
{
// We got some things disassembled...
size_t num_instructions = disassembler->GetInstructionList().GetSize();
uint32_t offset = 0;
SymbolContext sc;
SymbolContext prev_sc;
AddressRange sc_range;
if (num_mixed_context_lines)
strm.IndentMore ();
Address addr(range.GetBaseAddress());
// We extract the section to make sure we don't transition out
// of the current section when disassembling
const Section *addr_section = addr.GetSection();
Module *range_module = range.GetBaseAddress().GetModule();
for (size_t i=0; i<num_instructions; ++i)
{
Disassembler::Instruction *inst = disassembler->GetInstructionList().GetInstructionAtIndex (i);
if (inst)
{
addr_t file_addr = addr.GetFileAddress();
if (addr_section == NULL || addr_section->ContainsFileAddress (file_addr) == false)
{
if (range_module)
range_module->ResolveFileAddress (file_addr, addr);
else if (exe_ctx.target)
exe_ctx.target->GetImages().ResolveFileAddress (file_addr, addr);
addr_section = addr.GetSection();
}
prev_sc = sc;
if (addr_section)
{
Module *module = addr_section->GetModule();
uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
if (resolved_mask)
{
if (prev_sc.function != sc.function || prev_sc.symbol != sc.symbol)
{
if (prev_sc.function || prev_sc.symbol)
strm.EOL();
strm << sc.module_sp->GetFileSpec().GetFilename();
if (sc.function)
strm << '`' << sc.function->GetMangled().GetName();
else if (sc.symbol)
strm << '`' << sc.symbol->GetMangled().GetName();
strm << ":\n";
}
//.........这里部分代码省略.........