Commit 93b30d40 authored by David Schulz's avatar David Schulz Committed by Christian Stenger

Cdbext: Let the dumper set the value encoding.

Change-Id: I5e4f6f0a1139208ec38c524adc9684cf9c98b6de
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent de8422ac
......@@ -366,20 +366,6 @@ enum PointerFormats
FormatUcs4String = 105
};
enum DumpEncoding // WatchData encoding of GDBMI values
{
DumpEncodingAscii = 0,
DumpEncodingBase64_Utf16_WithQuotes = 2,
DumpEncodingHex_Ucs4_LittleEndian_WithQuotes = 3,
DumpEncodingBase64_Utf16 = 4,
DumpEncodingHex_Latin1_WithQuotes = 6,
DumpEncodingHex_Utf8_LittleEndian_WithQuotes = 9,
DumpEncodingJulianDate = 14,
DumpEncodingMillisecondsSinceMidnight = 15,
DumpEncodingJulianDateAndMillisecondsSinceMidnight = 16,
DumpEncodingMillisecondsSinceEpoch = 29
};
/* Recode arrays/pointers of char*, wchar_t according to users
* specification. Handles char formats for 'char *', '0x834478 "hallo.."'
* and 'wchar_t *', '0x834478 "hallo.."', 'wchar_t[56] "hallo"', etc.
......@@ -622,6 +608,7 @@ SymbolGroupNode::SymbolGroupNode(SymbolGroup *symbolGroup,
, m_symbolGroup(symbolGroup)
, m_module(module)
, m_index(index)
, m_dumperValueEncoding(0)
, m_dumperType(-1)
, m_dumperContainerSize(-1)
, m_dumperSpecialInfo(0)
......@@ -1059,7 +1046,7 @@ bool SymbolGroupNode::runSimpleDumpers(const SymbolGroupValueContext &ctx)
return true;
if (testFlags(SimpleDumperMask))
return false;
addFlags(dumpSimpleType(this , ctx, &m_dumperValue,
addFlags(dumpSimpleType(this , ctx, &m_dumperValue, &m_dumperValueEncoding,
&m_dumperType, &m_dumperContainerSize,
&m_dumperSpecialInfo, &m_memory));
if (symbolGroupDebug)
......@@ -1069,12 +1056,14 @@ bool SymbolGroupNode::runSimpleDumpers(const SymbolGroupValueContext &ctx)
return testFlags(SimpleDumperOk);
}
std::wstring SymbolGroupNode::simpleDumpValue(const SymbolGroupValueContext &ctx)
std::wstring SymbolGroupNode::simpleDumpValue(const SymbolGroupValueContext &ctx, int *encoding)
{
if (testFlags(Uninitialized))
return L"<not in scope>";
if (runSimpleDumpers(ctx))
if (runSimpleDumpers(ctx)) {
*encoding = m_dumperValueEncoding;
return m_dumperValue;
}
return symbolGroupFixedValue();
}
......@@ -1122,7 +1111,8 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
const std::string watchExp = t.empty() ? aName : watchExpression(addr, t, m_dumperType, m_module);
SymbolGroupNode::dumpBasicData(str, aName, aFullIName, t, watchExp);
std::wstring value = simpleDumpValue(ctx);
int encoding = 0;
std::wstring value = simpleDumpValue(ctx, &encoding);
if (addr) {
str << std::hex << std::showbase << ",addr=\"" << addr << '"';
......@@ -1145,28 +1135,6 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
bool valueEditable = !uninitialized;
bool valueEnabled = !uninitialized;
// Shall it be recoded?
int encoding = 0;
switch (knownType(t, 0)) {
case KT_QDate:
encoding = DumpEncodingJulianDate;
break;
case KT_QTime:
encoding = DumpEncodingMillisecondsSinceMidnight;
break;
case KT_QDateTime:
if (!value.compare(L"(invalid)"))
break;
encoding = QtInfo::get(ctx).version < 5
? DumpEncodingJulianDateAndMillisecondsSinceMidnight
: DumpEncodingMillisecondsSinceEpoch;
break;
case KT_QTimeZone: // Based on a QByteArray dumper
case KT_QByteArray:
if (QtInfo::get(ctx).version > 4)
encoding = DumpEncodingHex_Latin1_WithQuotes;
break;
}
if (encoding) {
str << ",valueencoded=\"" << encoding << "\",value=\"" << gdbmiWStringFormat(value) <<'"';
} else if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
......
......@@ -48,6 +48,21 @@ struct SymbolGroupValueContext;
class SymbolGroupNode;
class MemoryHandle;
enum DumpEncoding // WatchData encoding of GDBMI values
{
DumpEncodingAscii = 0,
DumpEncodingBase64_Utf16_WithQuotes = 2,
DumpEncodingHex_Ucs4_LittleEndian_WithQuotes = 3,
DumpEncodingBase64_Utf16 = 4,
DumpEncodingHex_Latin1_WithQuotes = 6,
DumpEncodingHex_Utf8_LittleEndian_WithQuotes = 9,
DumpEncodingJulianDate = 14,
DumpEncodingMillisecondsSinceMidnight = 15,
DumpEncodingJulianDateAndMillisecondsSinceMidnight = 16,
DumpEncodingIPv6AddressAndHexScopeId = 27,
DumpEncodingMillisecondsSinceEpoch = 29
};
// Helper struct used for check results when recoding CDB char pointer output.
struct DumpParameterRecodeResult
{
......@@ -291,7 +306,7 @@ private:
// Notify about expansion/collapsing of a node, shift indexes
bool notifyIndexesMoved(ULONG index, bool inserted, ULONG offset);
bool runSimpleDumpers(const SymbolGroupValueContext &ctx);
std::wstring simpleDumpValue(const SymbolGroupValueContext &ctx);
std::wstring simpleDumpValue(const SymbolGroupValueContext &ctx, int *encoding);
ULONG nextSymbolIndex() const;
SymbolGroup *const m_symbolGroup;
......@@ -299,6 +314,7 @@ private:
ULONG m_index;
DEBUG_SYMBOL_PARAMETERS m_parameters; // Careful when using ParentSymbol. It might not be correct.
std::wstring m_dumperValue;
int m_dumperValueEncoding;
int m_dumperType;
int m_dumperContainerSize;
void *m_dumperSpecialInfo; // Opaque information passed from simple to complex dumpers
......
......@@ -255,6 +255,7 @@ void formatKnownTypeFlags(std::ostream &os, KnownType kt);
// complex dumpers
unsigned dumpSimpleType(SymbolGroupNode *n, const SymbolGroupValueContext &ctx,
std::wstring *s,
int *encoding = 0,
int *knownType = 0,
int *containerSizeIn = 0,
void **specialInfoIn = 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment