#pragma once
#include "../../GDBServerFoundation/IGDBTarget.h"
#include "VBoxClient.h"

namespace VBoxGDB
{
	using namespace GDBServerFoundation;

	//! Implements a 32-bit VirtualBox target for GDBServerFoundation platform
	/*! This class implements a target debugging a 32-bit guest OS.
		It only supports querying/returning the 32-bit x86 registers and thus won't work with a 64-bit target.
	*/
	class VBoxTarget32 : public GDBServerFoundation::MinimalTargetBase
	{
	private:
		VBoxClient *m_pClient;
		bool m_bOwn;

	public:
		VBoxTarget32(VBoxClient *pClient, bool own);
		~VBoxTarget32();

	public:
		virtual const PlatformRegisterList *GetRegisterList();
		virtual GDBStatus ReadTargetRegisters(int threadID, RegisterSetContainer &registers);
		virtual GDBStatus WriteTargetRegisters(int threadID, const RegisterSetContainer &registers);
		virtual GDBStatus ReadTargetMemory(ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes);
		virtual GDBStatus WriteTargetMemory(ULONGLONG Address, const void *pBuffer, size_t sizeInBytes);

		virtual GDBStatus GetLastStopRecord(TargetStopRecord *pRec);
		virtual GDBStatus ResumeAndWait(int threadID);
		virtual GDBStatus Step(int threadID);
		virtual GDBStatus SendBreakInRequestAsync();

		virtual GDBStatus ExecuteRemoteCommand(const std::string &command, std::string &output);

		virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie);
		virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie);
		virtual void CloseSessionSafely();
	};

}