This commit adds a new top level command named "type". Currently this command
implements three commands:
type format add <format> <typename1> [<typename2> ...]
type format delete <typename1> [<typename2> ...]
type format list [<typename1> [<typename2>] ...]
This allows you to specify the default format that will be used to display
types when you use "frame variable" or "expression", or the SBValue classes.
Examples:
// Format uint*_t as hex
type format add x uint16_t uint32_t uint64_t
// Format intptr_t as a pointer
type format add p intptr_t
The format characters are the same as "printf" for the most part with many
additions. These format character specifiers are also used in many other
commands ("frame variable" for one). The current list of format characters
include:
a - char buffer
b - binary
B - boolean
c - char
C - printable char
d - signed decimal
e - float
f - float
g - float
i - signed decimal
I - complex integer
o - octal
O - OSType
p - pointer
s - c-string
u - unsigned decimal
x - hex
X - complex float
y - bytes
Y - bytes with ASCII
llvm-svn: 133728
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
//===-- FormatManager.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/FormatManager.h"
|
|
|
|
// C Includes
|
|
// C++ Includes
|
|
// Other libraries and framework includes
|
|
// Project includes
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
bool FormatManager::GetFormatForType (const ConstString &type, lldb::Format& format, bool& cascade)
|
|
{
|
|
Mutex::Locker locker (m_format_map_mutex);
|
|
FormatMap& fmtmap = m_format_map;
|
|
FormatMap::iterator iter = fmtmap.find(type.GetCString());
|
|
if(iter == fmtmap.end())
|
|
return false;
|
|
else {
|
|
format = iter->second.FormatStyle;
|
|
cascade = iter->second.Cascades;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void FormatManager::AddFormatForType (const ConstString &type, lldb::Format format, bool cascade)
|
|
{
|
|
format_entry_t entry(format, cascade);
|
|
Mutex::Locker locker (m_format_map_mutex);
|
|
FormatMap& fmtmap = m_format_map;
|
|
fmtmap[type.GetCString()] = entry;
|
|
}
|
|
|
|
bool FormatManager::DeleteFormatForType (const ConstString &type)
|
|
{
|
|
Mutex::Locker locker (m_format_map_mutex);
|
|
FormatMap& fmtmap = m_format_map;
|
|
const char* typeCS = type.GetCString();
|
|
FormatMap::iterator iter = fmtmap.find(typeCS);
|
|
if (iter == fmtmap.end())
|
|
return false;
|
|
else {
|
|
fmtmap.erase(typeCS);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void FormatManager::LoopThroughFormatList (FormatCallback cback, void* param)
|
|
{
|
|
Mutex::Locker locker (m_format_map_mutex);
|
|
FormatMap& fmtmap = m_format_map;
|
|
FormatIterator iter = fmtmap.begin();
|
|
while(iter != fmtmap.end()) {
|
|
const char* type = iter->first;
|
|
lldb::Format format = iter->second.FormatStyle;
|
|
bool cascade = iter->second.Cascades;
|
|
if(!cback(param, type,format, cascade)) break;
|
|
iter++;
|
|
}
|
|
}
|
|
|