forked from qt-creator/qt-creator
Debugger: Extract create value functionality
Change-Id: Ia02fa053ec2a70fcd47e8f4efdd5ea8dae735200 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -293,41 +293,7 @@ static PyObject *cdbext_createValue(PyObject *, PyObject *args)
|
|||||||
if (!type->impl)
|
if (!type->impl)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
if (debugPyCdbextModule) {
|
return createPythonObject(PyValue::createValue(address, *(type->impl)));
|
||||||
DebugPrint() << "Create Value address: 0x" << std::hex << address
|
|
||||||
<< " type name: " << type->impl->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
IDebugSymbolGroup2 *symbolGroup = CurrentSymbolGroup::get();
|
|
||||||
if (symbolGroup == nullptr)
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
|
|
||||||
ULONG numberOfSymbols = 0;
|
|
||||||
symbolGroup->GetNumberSymbols(&numberOfSymbols);
|
|
||||||
ULONG index = 0;
|
|
||||||
for (;index < numberOfSymbols; ++index) {
|
|
||||||
ULONG64 offset;
|
|
||||||
symbolGroup->GetSymbolOffset(index, &offset);
|
|
||||||
if (offset == address) {
|
|
||||||
DEBUG_SYMBOL_PARAMETERS params;
|
|
||||||
if (SUCCEEDED(symbolGroup->GetSymbolParameters(index, 1, ¶ms))) {
|
|
||||||
if (params.TypeId == type->impl->getTypeId() && params.Module == type->impl->moduleId())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index >= numberOfSymbols) {
|
|
||||||
ULONG index = DEBUG_ANY_ID;
|
|
||||||
const std::string name = SymbolGroupValue::pointedToSymbolName(address, type->impl->name(true));
|
|
||||||
if (debugPyCdbextModule)
|
|
||||||
DebugPrint() << "Create Value expression: " << name;
|
|
||||||
|
|
||||||
if (FAILED(symbolGroup->AddSymbol(name.c_str(), &index)))
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return createPythonObject(PyValue(index, symbolGroup));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *cdbext_call(PyObject *, PyObject *args)
|
static PyObject *cdbext_call(PyObject *, PyObject *args)
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "pyvalue.h"
|
#include "pyvalue.h"
|
||||||
|
|
||||||
#include "extensioncontext.h"
|
#include "extensioncontext.h"
|
||||||
|
#include "symbolgroupvalue.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@@ -263,6 +264,43 @@ PyValue PyValue::childFromIndex(int index)
|
|||||||
return PyValue(m_index + offset, m_symbolGroup);
|
return PyValue(m_index + offset, m_symbolGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyValue PyValue::createValue(ULONG64 address, const PyType &type)
|
||||||
|
{
|
||||||
|
if (debuggingValueEnabled()) {
|
||||||
|
DebugPrint() << "Create Value address: 0x" << std::hex << address
|
||||||
|
<< " type name: " << type.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
IDebugSymbolGroup2 *symbolGroup = CurrentSymbolGroup::get();
|
||||||
|
if (symbolGroup == nullptr)
|
||||||
|
return PyValue();
|
||||||
|
|
||||||
|
ULONG numberOfSymbols = 0;
|
||||||
|
symbolGroup->GetNumberSymbols(&numberOfSymbols);
|
||||||
|
ULONG index = 0;
|
||||||
|
for (;index < numberOfSymbols; ++index) {
|
||||||
|
ULONG64 offset;
|
||||||
|
symbolGroup->GetSymbolOffset(index, &offset);
|
||||||
|
if (offset == address) {
|
||||||
|
DEBUG_SYMBOL_PARAMETERS params;
|
||||||
|
if (SUCCEEDED(symbolGroup->GetSymbolParameters(index, 1, ¶ms))) {
|
||||||
|
if (params.TypeId == type.getTypeId() && params.Module == type.moduleId())
|
||||||
|
return PyValue(index, symbolGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string name = SymbolGroupValue::pointedToSymbolName(address, type.name(true));
|
||||||
|
if (debuggingValueEnabled())
|
||||||
|
DebugPrint() << "Create Value expression: " << name;
|
||||||
|
|
||||||
|
index = DEBUG_ANY_ID;
|
||||||
|
if (FAILED(symbolGroup->AddSymbol(name.c_str(), &index)))
|
||||||
|
return PyValue();
|
||||||
|
|
||||||
|
return PyValue(index, symbolGroup);
|
||||||
|
}
|
||||||
|
|
||||||
// Python interface implementation
|
// Python interface implementation
|
||||||
|
|
||||||
namespace PyValueInterface {
|
namespace PyValueInterface {
|
||||||
|
@@ -54,6 +54,7 @@ public:
|
|||||||
PyValue childFromField(const PyField &field);
|
PyValue childFromField(const PyField &field);
|
||||||
PyValue childFromIndex(int index);
|
PyValue childFromIndex(int index);
|
||||||
|
|
||||||
|
static PyValue createValue(ULONG64 address, const PyType &type);
|
||||||
private:
|
private:
|
||||||
static void indicesMoved(CIDebugSymbolGroup *symbolGroup, ULONG start, ULONG delta);
|
static void indicesMoved(CIDebugSymbolGroup *symbolGroup, ULONG start, ULONG delta);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user