forked from qt-creator/qt-creator
Debugger[CDB]: Fix setting individual formats by iname.
Do not hex-decode names. Change-Id: I0b9b6df2524cdf66bc34958bbab5bbc28f8a73db Reviewed-on: http://codereview.qt.nokia.com/3172 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
@@ -386,13 +386,15 @@ DumpCommandParameters::ParseOptionResult DumpCommandParameters::parseOption(Stri
|
|||||||
options->pop_front();
|
options->pop_front();
|
||||||
if (options->front().empty())
|
if (options->front().empty())
|
||||||
return Error;
|
return Error;
|
||||||
dumpParameters.typeFormats = DumpParameters::decodeFormatArgument(options->front());
|
dumpParameters.typeFormats =
|
||||||
|
DumpParameters::decodeFormatArgument(options->front(), true);
|
||||||
break;
|
break;
|
||||||
case 'I': // individual formats: 'hex'ed name = formatnumber,...'
|
case 'I': // individual formats: iname= formatnumber,...'
|
||||||
if (options->size() < 2)
|
if (options->size() < 2)
|
||||||
return Error;
|
return Error;
|
||||||
options->pop_front();
|
options->pop_front();
|
||||||
dumpParameters.individualFormats = DumpParameters::decodeFormatArgument(options->front());
|
dumpParameters.individualFormats =
|
||||||
|
DumpParameters::decodeFormatArgument(options->front(), false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
knownOption = false;
|
knownOption = false;
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
static const char whiteSpace[] = " \t\r\n";
|
static const char whiteSpace[] = " \t\r\n";
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ std::string stringFromHex(const char *p, const char *end)
|
|||||||
|
|
||||||
std::string rc;
|
std::string rc;
|
||||||
rc.reserve((end - p) / 2);
|
rc.reserve((end - p) / 2);
|
||||||
for ( ; p < end; p++) {
|
for ( ; p < end; ++p) {
|
||||||
unsigned c = 16 * hexDigit(*p);
|
unsigned c = 16 * hexDigit(*p);
|
||||||
c += hexDigit(*++p);
|
c += hexDigit(*++p);
|
||||||
rc.push_back(char(c));
|
rc.push_back(char(c));
|
||||||
@@ -247,9 +248,40 @@ std::string stringFromHex(const char *p, const char *end)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper for dumping memory
|
||||||
|
std::string dumpMemory(const unsigned char *p, size_t size,
|
||||||
|
bool wantQuotes)
|
||||||
|
{
|
||||||
|
std::ostringstream str;
|
||||||
|
str << std::oct << std::setfill('0');
|
||||||
|
if (wantQuotes)
|
||||||
|
str << '"';
|
||||||
|
const unsigned char *end = p + size;
|
||||||
|
for ( ; p < end; ++p) {
|
||||||
|
const unsigned char u = *p;
|
||||||
|
switch (u) {
|
||||||
|
case '\t':
|
||||||
|
str << "\\t";
|
||||||
|
case '\r':
|
||||||
|
str << "\\r";
|
||||||
|
case '\n':
|
||||||
|
str << "\\n";
|
||||||
|
default:
|
||||||
|
if (u >= 32 && u < 128) {
|
||||||
|
str << (char(u));
|
||||||
|
} else {
|
||||||
|
str << '\\' << std::setw(3) << unsigned(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wantQuotes)
|
||||||
|
str << '"';
|
||||||
|
return str.str();
|
||||||
|
}
|
||||||
|
|
||||||
void decodeHex(const char *p, const char *end, unsigned char *target)
|
void decodeHex(const char *p, const char *end, unsigned char *target)
|
||||||
{
|
{
|
||||||
for ( ; p < end; p++) {
|
for ( ; p < end; ++p) {
|
||||||
unsigned c = 16 * hexDigit(*p);
|
unsigned c = 16 * hexDigit(*p);
|
||||||
c += hexDigit(*++p);
|
c += hexDigit(*++p);
|
||||||
*target++ = c;
|
*target++ = c;
|
||||||
@@ -263,7 +295,7 @@ std::wstring dataToHexW(const unsigned char *p, const unsigned char *end)
|
|||||||
|
|
||||||
std::wstring rc;
|
std::wstring rc;
|
||||||
rc.reserve(2 * (end - p));
|
rc.reserve(2 * (end - p));
|
||||||
for ( ; p < end ; p++) {
|
for ( ; p < end ; ++p) {
|
||||||
const unsigned c = *p;
|
const unsigned c = *p;
|
||||||
rc.push_back(toHexDigit(c / 16));
|
rc.push_back(toHexDigit(c / 16));
|
||||||
rc.push_back(toHexDigit(c &0xF));
|
rc.push_back(toHexDigit(c &0xF));
|
||||||
@@ -279,7 +311,7 @@ std::wstring dataToReadableHexW(const unsigned char *begin, const unsigned char
|
|||||||
|
|
||||||
std::wstring rc;
|
std::wstring rc;
|
||||||
rc.reserve(5 * (end - begin));
|
rc.reserve(5 * (end - begin));
|
||||||
for (const unsigned char *p = begin; p < end ; p++) {
|
for (const unsigned char *p = begin; p < end ; ++p) {
|
||||||
rc.append(p == begin ? L"0x" : L" 0x");
|
rc.append(p == begin ? L"0x" : L" 0x");
|
||||||
const unsigned c = *p;
|
const unsigned c = *p;
|
||||||
rc.push_back(toHexDigit(c / 16));
|
rc.push_back(toHexDigit(c / 16));
|
||||||
|
@@ -182,6 +182,9 @@ std::wstring stringToWString(const std::string &w);
|
|||||||
std::wstring quotedWStringFromCharData(const unsigned char *data, size_t size);
|
std::wstring quotedWStringFromCharData(const unsigned char *data, size_t size);
|
||||||
std::wstring quotedWStringFromWCharData(const unsigned char *data, size_t size);
|
std::wstring quotedWStringFromWCharData(const unsigned char *data, size_t size);
|
||||||
|
|
||||||
|
// Helper for dumping memory
|
||||||
|
std::string dumpMemory(const unsigned char *data, size_t size, bool wantQuotes = true);
|
||||||
|
|
||||||
// String from hex "414A" -> "AJ".
|
// String from hex "414A" -> "AJ".
|
||||||
std::string stringFromHex(const char *begin, const char *end);
|
std::string stringFromHex(const char *begin, const char *end);
|
||||||
// Decode hex to a memory area.
|
// Decode hex to a memory area.
|
||||||
|
@@ -294,7 +294,8 @@ DumpParameters::DumpParameters() : dumpFlags(0)
|
|||||||
|
|
||||||
// typeformats: decode hex-encoded name, value pairs:
|
// typeformats: decode hex-encoded name, value pairs:
|
||||||
// '414A=2,...' -> map of "AB:2".
|
// '414A=2,...' -> map of "AB:2".
|
||||||
DumpParameters::FormatMap DumpParameters::decodeFormatArgument(const std::string &f)
|
DumpParameters::FormatMap DumpParameters::decodeFormatArgument(const std::string &f,
|
||||||
|
bool isHex)
|
||||||
{
|
{
|
||||||
FormatMap rc;
|
FormatMap rc;
|
||||||
const std::string::size_type size = f.size();
|
const std::string::size_type size = f.size();
|
||||||
@@ -304,7 +305,9 @@ DumpParameters::FormatMap DumpParameters::decodeFormatArgument(const std::string
|
|||||||
const std::string::size_type equalsPos = f.find('=', pos);
|
const std::string::size_type equalsPos = f.find('=', pos);
|
||||||
if (equalsPos == std::string::npos)
|
if (equalsPos == std::string::npos)
|
||||||
return rc;
|
return rc;
|
||||||
const std::string name = stringFromHex(f.c_str() + pos, f.c_str() + equalsPos);
|
const std::string name = isHex ?
|
||||||
|
stringFromHex(f.c_str() + pos, f.c_str() + equalsPos) :
|
||||||
|
f.substr(pos, equalsPos - pos);
|
||||||
// Search for number
|
// Search for number
|
||||||
const std::string::size_type numberPos = equalsPos + 1;
|
const std::string::size_type numberPos = equalsPos + 1;
|
||||||
std::string::size_type nextPos = f.find(',', numberPos);
|
std::string::size_type nextPos = f.find(',', numberPos);
|
||||||
@@ -383,6 +386,12 @@ DumpParameters::checkRecode(const std::string &type,
|
|||||||
enum ReformatType { ReformatNone, ReformatPointer, ReformatArray };
|
enum ReformatType { ReformatNone, ReformatPointer, ReformatArray };
|
||||||
|
|
||||||
DumpParameterRecodeResult result;
|
DumpParameterRecodeResult result;
|
||||||
|
if (SymbolGroupValue::verbose > 2) {
|
||||||
|
DebugPrint debugPrint;
|
||||||
|
debugPrint << '>' << __FUNCTION__ << ' ' << iname << '/' << iname;
|
||||||
|
if (dp)
|
||||||
|
debugPrint << " option format: " << dp->format(type, iname);
|
||||||
|
}
|
||||||
// We basically handle char formats for 'char *', '0x834478 "hallo.."'
|
// We basically handle char formats for 'char *', '0x834478 "hallo.."'
|
||||||
// and 'wchar_t *', '0x834478 "hallo.."'
|
// and 'wchar_t *', '0x834478 "hallo.."'
|
||||||
// Determine address and length from the pointer value output,
|
// Determine address and length from the pointer value output,
|
||||||
@@ -467,6 +476,11 @@ DumpParameters::checkRecode(const std::string &type,
|
|||||||
delete [] result.buffer;
|
delete [] result.buffer;
|
||||||
result = DumpParameterRecodeResult();
|
result = DumpParameterRecodeResult();
|
||||||
}
|
}
|
||||||
|
if (SymbolGroupValue::verbose > 2)
|
||||||
|
DebugPrint()
|
||||||
|
<< '<' << __FUNCTION__ << ' ' << iname << " format="
|
||||||
|
<< result.recommendedFormat << " size="
|
||||||
|
<< result.size << " data=" << dumpMemory(result.buffer, result.size);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,8 +72,7 @@ struct DumpParameters
|
|||||||
DumpParameters();
|
DumpParameters();
|
||||||
bool humanReadable() const { return dumpFlags & DumpHumanReadable; }
|
bool humanReadable() const { return dumpFlags & DumpHumanReadable; }
|
||||||
// Helper to decode format option arguments.
|
// Helper to decode format option arguments.
|
||||||
static FormatMap decodeFormatArgument(const std::string &f);
|
static FormatMap decodeFormatArgument(const std::string &f, bool isHex);
|
||||||
|
|
||||||
|
|
||||||
static DumpParameterRecodeResult
|
static DumpParameterRecodeResult
|
||||||
checkRecode(const std::string &type, const std::string &iname,
|
checkRecode(const std::string &type, const std::string &iname,
|
||||||
|
Reference in New Issue
Block a user