示例#1
0
	bool _GetBreakpointValueAt(UserBreakpoint* breakpoint, int32 rowIndex,
		int32 columnIndex, BVariant &value)
	{
		const UserBreakpointLocation& location = breakpoint->Location();

		switch (columnIndex) {
			case 0:
				value.SetTo((int32)breakpoint->IsEnabled());
				return true;
			case 1:
				value.SetTo(location.GetFunctionID()->FunctionName(),
					B_VARIANT_DONT_COPY_DATA);
				return true;
			case 2:
			{
				LocatableFile* sourceFile = location.SourceFile();
				BString data;
				if (sourceFile != NULL) {
					data.SetToFormat("%s:%" B_PRId32, sourceFile->Name(),
						location.GetSourceLocation().Line() + 1);
				} else {
					AutoLocker<Team> teamLocker(fTeam);
					if (UserBreakpointInstance* instance
							= breakpoint->InstanceAt(0)) {
						data.SetToFormat("%#" B_PRIx64, instance->Address());
					}
				}
				value.SetTo(data);
				return true;
			}
			default:
				return false;
		}
	}
	virtual bool GetValueAt(void* object, int32 columnIndex, BVariant& value)
	{
		if (columnIndex != 0)
			return false;

		if (object == this)
			return false;

		if (object >= fSourceFileIndices
			&& object < fSourceFileIndices + fSourceFileCount) {
			int32 index = *(int32*)object;
			if (LocatableFile* file = fFunctions[index]->SourceFile()) {
				BString path;
				file->GetPath(path);
				value.SetTo(path);
			} else
				value.SetTo("<no source file>", B_VARIANT_DONT_COPY_DATA);

			return true;
		}

		FunctionInstance* function = (FunctionInstance*)object;
		value.SetTo(function->PrettyName(), B_VARIANT_DONT_COPY_DATA);
		return true;
	}
示例#3
0
    virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
    {
        StackFrame* frame
            = fStackTrace != NULL ? fStackTrace->FrameAt(rowIndex) : NULL;
        if (frame == NULL)
            return false;

        switch (columnIndex) {
        case 0:
            value.SetTo(frame->FrameAddress());
            return true;
        case 1:
            value.SetTo(frame->InstructionPointer());
            return true;
        case 2:
        {
            char buffer[512];
            value.SetTo(UiUtils::FunctionNameForFrame(frame, buffer,
                        sizeof(buffer)));
            return true;
        }
        default:
            return false;
        }
    }
示例#4
0
status_t
IntegerValueFormatter::_ValidateUnsigned(const BString& input, type_code type,
        ::Value*& _output, integer_format format, bool wantsValue) const
{
    const char* text = input.String();
    int32 base = format == INTEGER_FORMAT_UNSIGNED ? 10 : 16;

    char *parseEnd = NULL;
    uintmax_t parsedValue = strtoumax(text, &parseEnd, base);
    if (parseEnd - text < input.Length() && !isspace(*parseEnd))
        return B_BAD_VALUE;

    BVariant newValue;
    switch (type) {
    case B_UINT8_TYPE:
    {
        if (parsedValue > UINT8_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((uint8)parsedValue);
        break;
    }
    case B_UINT16_TYPE:
    {
        if (parsedValue > UINT16_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((uint16)parsedValue);
        break;
    }
    case B_UINT32_TYPE:
    {
        if (parsedValue > UINT32_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((uint32)parsedValue);
        break;
    }
    case B_UINT64_TYPE:
    {
        newValue.SetTo((uint64)parsedValue);
        break;
    }
    default:
        return B_BAD_VALUE;
    }

    if (wantsValue) {
        _output = new(std::nothrow) IntegerValue(newValue);
        if (_output == NULL)
            return B_NO_MEMORY;
    }

    return B_OK;
}
示例#5
0
status_t
ArchitectureX8664::ReadValueFromMemory(target_addr_t address, uint32 valueType,
	BVariant& _value) const
{
	uint8 buffer[64];
	size_t size = BVariant::SizeOfType(valueType);
	if (size == 0 || size > sizeof(buffer))
		return B_BAD_VALUE;

	ssize_t bytesRead = fTeamMemory->ReadMemory(address, buffer, size);
	if (bytesRead < 0)
		return bytesRead;
	if ((size_t)bytesRead != size)
		return B_ERROR;

	// TODO: We need to swap endianess, if the host is big endian!

	switch (valueType) {
		case B_INT8_TYPE:
			_value.SetTo(*(int8*)buffer);
			return B_OK;
		case B_UINT8_TYPE:
			_value.SetTo(*(uint8*)buffer);
			return B_OK;
		case B_INT16_TYPE:
			_value.SetTo(*(int16*)buffer);
			return B_OK;
		case B_UINT16_TYPE:
			_value.SetTo(*(uint16*)buffer);
			return B_OK;
		case B_INT32_TYPE:
			_value.SetTo(*(int32*)buffer);
			return B_OK;
		case B_UINT32_TYPE:
			_value.SetTo(*(uint32*)buffer);
			return B_OK;
		case B_INT64_TYPE:
			_value.SetTo(*(int64*)buffer);
			return B_OK;
		case B_UINT64_TYPE:
			_value.SetTo(*(uint64*)buffer);
			return B_OK;
		case B_FLOAT_TYPE:
			_value.SetTo(*(float*)buffer);
				// TODO: float on the host might work differently!
			return B_OK;
		case B_DOUBLE_TYPE:
			_value.SetTo(*(double*)buffer);
				// TODO: double on the host might work differently!
			return B_OK;
		default:
			return B_BAD_VALUE;
	}
}
示例#6
0
status_t
IntegerValueFormatter::_ValidateSigned(const BString& input, type_code type,
                                       ::Value*& _output, bool wantsValue) const
{
    const char* text = input.String();
    char *parseEnd = NULL;
    intmax_t parsedValue = strtoimax(text, &parseEnd, 10);
    if (parseEnd - text < input.Length() && !isspace(*parseEnd))
        return B_NO_MEMORY;

    BVariant newValue;
    switch (type) {
    case B_INT8_TYPE:
    {
        if (parsedValue < INT8_MIN || parsedValue > INT8_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((int8)parsedValue);
        break;
    }
    case B_INT16_TYPE:
    {
        if (parsedValue < INT16_MIN || parsedValue > INT16_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((int16)parsedValue);
        break;
    }
    case B_INT32_TYPE:
    {
        if (parsedValue < INT32_MIN || parsedValue > INT32_MAX)
            return B_BAD_VALUE;

        newValue.SetTo((int32)parsedValue);
        break;
    }
    case B_INT64_TYPE:
    {
        newValue.SetTo((int64)parsedValue);
        break;
    }
    default:
        return B_BAD_VALUE;
    }

    if (wantsValue) {
        _output = new(std::nothrow) IntegerValue(newValue);
        if (_output == NULL)
            return B_NO_MEMORY;
    }

    return B_OK;
}
示例#7
0
bool
CpuStateX86::GetRegisterValue(const Register* reg, BVariant& _value) const
{
	int32 index = reg->Index();
	if (!IsRegisterSet(index))
		return false;

	if (index >= X86_INT_REGISTER_END)
		return false;

	if (reg->BitSize() == 16)
		_value.SetTo((uint16)fIntRegisters[index]);
	else
		_value.SetTo(fIntRegisters[index]);

	return true;
}
	virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
	{
		Image* image = fImages.ItemAt(rowIndex);
		if (image == NULL)
			return false;

		switch (columnIndex) {
			case 0:
				value.SetTo(image->ID());
				return true;
			case 1:
				value.SetTo(image->Name(), B_VARIANT_DONT_COPY_DATA);
				return true;
			default:
				return false;
		}
	}
示例#9
0
bool
VariablesView::VariableTableModel::GetValueAt(void* object, int32 columnIndex,
	BVariant& _value)
{
	ModelNode* node = (ModelNode*)object;

	switch (columnIndex) {
		case 0:
			_value.SetTo(node->Name(), B_VARIANT_DONT_COPY_DATA);
			return true;
		case 1:
			if (node->GetValue() == NULL)
				return false;

			_value.SetTo(node, VALUE_NODE_TYPE);
			return true;
		default:
			return false;
	}
}
示例#10
0
	virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
	{
		UserBreakpoint* breakpoint = fBreakpoints.ItemAt(rowIndex);
		if (breakpoint == NULL)
			return false;
		const UserBreakpointLocation& location = breakpoint->Location();

		switch (columnIndex) {
			case 0:
				value.SetTo((int32)breakpoint->IsEnabled());
				return true;
			case 1:
				value.SetTo(location.GetFunctionID()->FunctionName(),
					B_VARIANT_DONT_COPY_DATA);
				return true;
			case 2:
				if (LocatableFile* sourceFile = location.SourceFile()) {
					value.SetTo(sourceFile->Name(), B_VARIANT_DONT_COPY_DATA);
					return true;
				}
				return false;
			case 3:
				if (location.SourceFile() != NULL) {
					value.SetTo(location.GetSourceLocation().Line() + 1);
					return true;
				}
				return false;
			case 4:
				if (location.SourceFile() == NULL) {
					AutoLocker<Team> teamLocker(fTeam);
					if (UserBreakpointInstance* instance
							= breakpoint->InstanceAt(0)) {
						value.SetTo(instance->Address());
						return true;
					}
				}
				return false;
			default:
				return false;
		}
	}
示例#11
0
bool
CpuStateX8664::GetRegisterValue(const Register* reg, BVariant& _value) const
{
	int32 index = reg->Index();
	if (!IsRegisterSet(index))
		return false;

	if (index >= X86_64_XMM_REGISTER_END)
		return false;

	if (BVariant::TypeIsInteger(reg->ValueType())) {
		if (reg->BitSize() == 16)
			_value.SetTo((uint16)fIntRegisters[index]);
		else
			_value.SetTo(fIntRegisters[index]);
	} else if (BVariant::TypeIsFloat(reg->ValueType())) {
		index -= X86_64_REGISTER_ST0;
		if (reg->ValueType() == B_FLOAT_TYPE)
			_value.SetTo((float)fFloatRegisters[index]);
		else
			_value.SetTo(fFloatRegisters[index]);
	} else {
		if (index >= X86_64_REGISTER_MM0 && index < X86_64_REGISTER_XMM0) {
			index -= X86_64_REGISTER_MM0;
			_value.SetTo(fMMXRegisters[index].value);
		} else {
			index -= X86_64_REGISTER_XMM0;
			_value.SetTo(fXMMRegisters[index].value);
		}
	}

	return true;
}
示例#12
0
	bool _GetWatchpointValueAt(Watchpoint* watchpoint, int32 rowIndex,
		int32 columnIndex, BVariant &value)
	{
		switch (columnIndex) {
			case 0:
				value.SetTo((int32)watchpoint->IsEnabled());
				return true;
			case 1:
			{
				BString data;
				data.SetToFormat("%s at 0x%" B_PRIx64 " (%" B_PRId32 " bytes)",
					_WatchpointTypeToString(watchpoint->Type()),
					watchpoint->Address(), watchpoint->Length());
				value.SetTo(data);
				return true;
			}
			case 2:
			{
				return false;
			}
			default:
				return false;
		}
	}
示例#13
0
	virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
	{
		Thread* thread = fThreads.ItemAt(rowIndex);
		if (thread == NULL)
			return false;

		switch (columnIndex) {
			case 0:
				value.SetTo(thread->ID());
				return true;
			case 1:
			{
				switch (thread->State()) {
					case THREAD_STATE_RUNNING:
						value.SetTo("Running", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STATE_STOPPED:
						break;
					case THREAD_STATE_UNKNOWN:
					default:
						value.SetTo("?", B_VARIANT_DONT_COPY_DATA);
						return true;
				}

				// thread is stopped -- get the reason
				switch (thread->StoppedReason()) {
					case THREAD_STOPPED_DEBUGGER_CALL:
						value.SetTo("Call", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STOPPED_EXCEPTION:
						value.SetTo("Exception", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STOPPED_BREAKPOINT:
					case THREAD_STOPPED_WATCHPOINT:
					case THREAD_STOPPED_SINGLE_STEP:
					case THREAD_STOPPED_DEBUGGED:
					case THREAD_STOPPED_UNKNOWN:
					default:
						value.SetTo("Debugged", B_VARIANT_DONT_COPY_DATA);
						return true;
				}
			}
			case 2:
				value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA);
				return true;
			default:
				return false;
		}
	}