Exemple #1
0
status_t
BreakpointSetting::WriteTo(BMessage& archive) const
{
	if (fFunctionID == NULL)
		return B_BAD_VALUE;

	status_t error;
	if ((error = ArchivingUtils::ArchiveChild(fFunctionID, archive, "function"))
			!= B_OK
		|| (error = archive.AddString("sourceFile", fSourceFile)) != B_OK
		|| (error = archive.AddInt32("line", fSourceLocation.Line())) != B_OK
		|| (error = archive.AddInt32("column", fSourceLocation.Column()))
			!= B_OK
		|| (error = archive.AddUInt64("relativeAddress", fRelativeAddress))
			!= B_OK
		|| (error = archive.AddBool("enabled", fEnabled)) != B_OK) {
		return error;
	}

	return B_OK;
}
Exemple #2
0
void
MemoryView::_HandleContextMenu(BPoint point)
{
	int32 offset = _GetOffsetAt(point);
	if (offset < fSelectionStart || offset > fSelectionEnd)
		return;

	BPopUpMenu* menu = new(std::nothrow) BPopUpMenu("Options");
	if (menu == NULL)
		return;

	ObjectDeleter<BPopUpMenu> menuDeleter(menu);
	ObjectDeleter<BMenuItem> itemDeleter;
	ObjectDeleter<BMessage> messageDeleter;
	BMessage* message = NULL;
	BMenuItem* item = NULL;
	if (fSelectionEnd - fSelectionStart == fTargetAddressSize / 2) {
		BMessage* message = new(std::nothrow) BMessage(MSG_INSPECT_ADDRESS);
		if (message == NULL)
			return;

		target_addr_t address;
		if (fTargetAddressSize == 8)
			address = *((uint32*)(fTargetBlock->Data() + fSelectionStart));
		else
			address = *((uint64*)(fTargetBlock->Data() + fSelectionStart));

		if (fCurrentEndianMode == EndianModeBigEndian)
			address = B_HOST_TO_BENDIAN_INT64(address);
		else
			address = B_HOST_TO_LENDIAN_INT64(address);

		messageDeleter.SetTo(message);
		message->AddUInt64("address", address);
		BMenuItem* item = new(std::nothrow) BMenuItem("Inspect", message);
		if (item == NULL)
			return;

		messageDeleter.Detach();
		itemDeleter.SetTo(item);
		if (!menu->AddItem(item))
			return;

		item->SetTarget(Looper());
		itemDeleter.Detach();
	}

	message = new(std::nothrow) BMessage(B_COPY);
	if (message == NULL)
		return;

	messageDeleter.SetTo(message);
	item = new(std::nothrow) BMenuItem("Copy", message);
	if (item == NULL)
		return;

	messageDeleter.Detach();
	itemDeleter.SetTo(item);
	if (!menu->AddItem(item))
		return;

	item->SetTarget(this);
	itemDeleter.Detach();
	menuDeleter.Detach();

	BPoint screenWhere(point);
	ConvertToScreen(&screenWhere);
	BRect mouseRect(screenWhere, screenWhere);
	mouseRect.InsetBy(-4.0, -4.0);
	menu->Go(screenWhere, true, false, mouseRect, true);
}