Exemple #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;
		}
	}
Exemple #2
0
    virtual void setAsyncResult(const BVariant& result) {
      try {
        if (result.isException()) {
          innerResult->setAsyncResult(result);
        }
        else {
          POBJECT obj;
          result.get(obj);
          PMessage msg = byps_static_ptr_cast<BMessage>(obj);

          BNegotiate nego;
          nego.read(msg->buf);
          {
            byps_unique_lock lock(transport->mtx);
            transport->protocol = transport->createNegotiatedProtocol(nego);
            transport->targetId = nego.targetId;
            transport->connectedServerId = nego.targetId.getServerId();
            transport->sessionId = nego.sessionId;
          }

          transport->internalAuthenticate(innerResult);
        }
      }
      catch (const exception& ex) {
        innerResult->setAsyncResult(BVariant(ex));
      }
      delete this;
    }
	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;
	}
    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;
        }
    }
Exemple #5
0
SettingsOption*
Settings::OptionValue(OptionsSetting* setting) const
{
	BVariant value = Value(setting);
	return value.Type() == B_STRING_TYPE
		? setting->OptionByID(value.ToString())
		: setting->DefaultOption();
}
Exemple #6
0
BVariant
Settings::Value(Setting* setting) const
{
	AutoLocker<BLocker> locker(fLock);

	BVariant value;
	return value.SetFromMessage(fValues, setting->ID()) == B_OK
		? value : setting->DefaultValue();
}
bool
TableCellIntegerEditor::ValidateInput() const
{
	BVariant variantValue;
	if (!InitialValue()->ToVariant(variantValue))
		return false;

	return GetValueFormatter()->ValidateFormattedValue(Text(),
		variantValue.Type());
}
status_t
TableCellIntegerEditor::GetValueForInput(::Value*& _output) const
{
	BVariant variantValue;
	if (!InitialValue()->ToVariant(variantValue))
		return B_NO_MEMORY;

	return GetValueFormatter()->GetValueFromFormattedInput(Text(),
		variantValue.Type(), _output);
}
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;
}
Exemple #10
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;
	}
}
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;
}
Exemple #12
0
BVariant
Settings::Value(const char* settingID) const
{
	AutoLocker<BLocker> locker(fLock);

	BVariant value;
	if (value.SetFromMessage(fValues, settingID) == B_OK)
		return value;

	Setting* setting = fDescription->SettingByID(settingID);
	return setting != NULL ? setting->DefaultValue() : value;
}
Exemple #13
0
	float GetPreferredWidth(const BVariant& value, BView* targetView) const
	{
		// get the preferred width from the node's designated renderer
		if (value.Type() == VALUE_NODE_TYPE) {
			ModelNode* node = dynamic_cast<ModelNode*>(value.ToReferenceable());
			if (node != NULL && node->GetValue() != NULL
				&& node->TableCellRenderer() != NULL) {
				return node->TableCellRenderer()->PreferredValueWidth(
					node->GetValue(), targetView);
			}
		}

		return fColumn.BTitledColumn::GetPreferredWidth(NULL, targetView);
	}
Exemple #14
0
bool
CpuStateX8664::SetRegisterValue(const Register* reg, const BVariant& value)
{
	int32 index = reg->Index();
	if (index >= X86_64_XMM_REGISTER_END)
		return false;

	if (index < X86_64_INT_REGISTER_END)
		fIntRegisters[index] = value.ToUInt64();
	else if (index >= X86_64_REGISTER_ST0 && index < X86_64_FP_REGISTER_END)
		fFloatRegisters[index - X86_64_REGISTER_ST0] = value.ToDouble();
	else if (index >= X86_64_REGISTER_MM0 && index < X86_64_MMX_REGISTER_END) {
		if (value.Size() > sizeof(int64))
			return false;
		memset(&fMMXRegisters[index - X86_64_REGISTER_MM0], 0,
			sizeof(x86_64_fp_register));
		memcpy(fMMXRegisters[index - X86_64_REGISTER_MM0].value,
			value.ToPointer(), value.Size());
	} else if (index >= X86_64_REGISTER_XMM0
			&& index < X86_64_XMM_REGISTER_END) {
		if (value.Size() > sizeof(x86_64_xmm_register))
			return false;

		memset(&fXMMRegisters[index - X86_64_REGISTER_XMM0], 0,
			sizeof(x86_64_xmm_register));
		memcpy(fXMMRegisters[index - X86_64_REGISTER_XMM0].value,
			value.ToPointer(), value.Size());
	} else
		return false;

	fSetRegisters[index] = 1;
	return true;
}
Exemple #15
0
 virtual void setAsyncResult(const BVariant& result) {
   if (result.isException()) {
     asyncResult->setAsyncResult(result);
   }
   else {
     PMethodRequest methodRequest = byps_ptr_cast<BMethodRequest>(requestObject);
     if (methodRequest) {
       PSerializable session;
       result.get(session);
       methodRequest->setSession(session);
     }
     pTransport->send(methodRequest, asyncResult);
   }
   delete this;
 }
Exemple #16
0
status_t
InspectorWindow::LoadSettings(const GUITeamUISettings* settings)
{
	BVariant value;
	if (settings->Value("inspectorWindowFrame", value) == B_OK) {
		BRect frameRect = value.ToRect();
		ResizeTo(frameRect.Width(), frameRect.Height());
		MoveTo(frameRect.left, frameRect.top);
	}

	_LoadMenuFieldMode(fHexMode, "Hex", settings);
	_LoadMenuFieldMode(fEndianMode, "Endian", settings);
	_LoadMenuFieldMode(fTextMode, "Text", settings);

	return B_OK;
}
Exemple #17
0
bool
Settings::RestoreValues(const BMessage& message)
{
	AutoLocker<BLocker> locker(fLock);

	for (int32 i = 0; i < fDescription->CountSettings(); i++) {
		Setting* setting = fDescription->SettingAt(i);
		BVariant value;
		if (value.SetFromMessage(message, setting->ID()) == B_OK) {
			if (!SetValue(setting, value))
				return false;
		}
	}

	return true;
}
status_t
InitializeBFSEditor::ParameterChanged(const char* name, const BVariant& variant)
{
	if (!strcmp(name, "name"))
		fNameControl->SetText(variant.ToString());
	return B_OK;
}
Exemple #19
0
bool
GUITeamUISettings::SetValue(const char* settingID, const BVariant& value)
{
	fValues.RemoveName(settingID);

	return value.AddToMessage(fValues, settingID) == B_OK;
}
Exemple #20
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;
		}
	}
Exemple #22
0
	void DrawValue(const BVariant& value, BRect rect, BView* targetView)
	{
		// draw the node's value with the designated renderer
		if (value.Type() == VALUE_NODE_TYPE) {
			ModelNode* node = dynamic_cast<ModelNode*>(value.ToReferenceable());
			if (node != NULL && node->GetValue() != NULL
				&& node->TableCellRenderer() != NULL) {
				node->TableCellRenderer()->RenderValue(node->GetValue(), rect,
					targetView);
				return;
			}
		}

		// fall back to drawing an empty string
		fField.SetString("");
		fField.SetWidth(Width());
		fColumn.DrawField(&fField, rect, targetView);
	}
Exemple #23
0
    virtual void setAsyncResult(const BVariant& result) {
      bool relogin = false;

      try {
        if (result.isException()) {
          relogin = internalIsReloginException(result.getException());
          if (!relogin) {
            innerResult->setAsyncResult(BVariant(result.getException()));
          }
        }
        else {
          try {
            POBJECT obj;
            result.get(obj);
            if (obj) {
              PMessage msg = byps_static_ptr_cast<BMessage>(obj);

              PInput inp = transport->getInput(msg->header, msg->buf);
              PSerializable sobj = inp->load();
              innerResult->setAsyncResult(BVariant(sobj));
            }
            else {
              BException ex(BExceptionC::CORRUPT, L"Missing message object in result.");
              innerResult->setAsyncResult(BVariant(ex));
            }
          }
          catch (const BException& e) {
            relogin = internalIsReloginException(e);
            if (!relogin) {
              innerResult->setAsyncResult(BVariant(e));
            }
          }
        }

        if (relogin) {
          transport->loginAndRetrySend(requestObject, innerResult);
        }
      }
      catch (const exception& ex) {
        innerResult->setAsyncResult(BVariant(ex));
      }

      delete this;
    }
Exemple #24
0
void
InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name,
	const GUITeamUISettings* settings)
{
	BVariant value;
	BString fieldName;
	fieldName.SetToFormat("inspectorWindow%sMode", name);
	status_t error = settings->Value(fieldName.String(), value);
	if (error == B_OK) {
		BMenu* menu = field->Menu();
		for (int32 i = 0; i < menu->CountItems(); i++) {
			BInvoker* item = menu->ItemAt(i);
			if (item->Message()->FindInt32("mode") == value.ToInt32()) {
				item->Invoke();
				break;
			}
		}
	}
}
Exemple #25
0
    virtual void setAsyncResult(const BVariant& var) {
      try {
        if (var.isException()) {
          outp->setException(var.getException());
        }
        else {
          PSerializable obj;
          var.get(obj);
          outp->store(obj);
        }
        PMessage msg = outp->toMessage();

        innerResult->setAsyncResult(BVariant(msg));
      }
      catch (const exception& ex) {
        innerResult->setAsyncResult(BVariant(ex));
      }
      delete this;
    }
Exemple #26
0
bool
CpuStateX86::SetRegisterValue(const Register* reg, const BVariant& value)
{
	int32 index = reg->Index();
	if (index >= X86_INT_REGISTER_END)
		return false;

	fIntRegisters[index] = value.ToUInt32();
	fSetRegisters[index] = 1;
	return true;
}
Exemple #27
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;
	}
}
Exemple #28
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;
		}
	}
Exemple #29
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;
}
Exemple #30
0
 virtual void setAsyncResult(const BVariant& result) {
   try {
     if (result.isException()) {
       innerResult->setAsyncResult(result);
     }
     else {
       transport->assignSessionThenSendMethod(requestObject, innerResult);
     }
   }
   catch (const exception& ex) {
     innerResult->setAsyncResult(BVariant(ex));
   }
   delete this;
 }