Skip to content

Commit

Permalink
Add Monitor_TargetInfo command (nanoframework#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Nov 23, 2020
1 parent 8372a2a commit c76782b
Show file tree
Hide file tree
Showing 20 changed files with 458 additions and 394 deletions.
11 changes: 11 additions & 0 deletions src/CLR/Debugger/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ bool CLR_DBG_Debugger::Monitor_FlashSectorMap(WP_Message *msg)
return true;
}

bool CLR_DBG_Debugger::Monitor_TargetInfo(WP_Message *msg)
{
Monitor_TargetInfo_Reply cmdReply;

bool fOK = nanoBooter_GetTargetInfo(&cmdReply.m_TargetInfo) == true;

WP_ReplyToCommand(msg, fOK, false, &cmdReply, sizeof(cmdReply));

return true;
}

//--//

bool CLR_DBG_Debugger::CheckPermission(ByteAddress address, int mode)
Expand Down
122 changes: 61 additions & 61 deletions src/CLR/Debugger/Debugger_full.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,96 +6,97 @@
#include <nanoCLR_Runtime.h>
#include <nanoCLR_Debugging.h>

#define DEFINE_CMD(cmd) { CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd }
#define DEFINE_CMD2(cmd) { CLR_DBG_Debugger::Monitor_##cmd , CLR_DBG_Commands_c_Monitor_##cmd }
#define DEFINE_CMD3(cmd) { &CLR_DBG_Debugger::Profiling_##cmd, CLR_DBG_Commands::c_Profiling_##cmd }
#define DEFINE_CMD(cmd) \
{ \
CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd \
}
#define DEFINE_CMD2(cmd) \
{ \
CLR_DBG_Debugger::Monitor_##cmd, CLR_DBG_Commands_c_Monitor_##cmd \
}
#define DEFINE_CMD3(cmd) \
{ \
&CLR_DBG_Debugger::Profiling_##cmd, CLR_DBG_Commands::c_Profiling_##cmd \
}

const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] =
{
const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] = {
DEFINE_CMD(Execution_QueryCLRCapabilities),
DEFINE_CMD2(Ping ),
DEFINE_CMD2(ReadMemory ),
DEFINE_CMD2(Ping),
DEFINE_CMD2(ReadMemory),
DEFINE_CMD2(WriteMemory),
DEFINE_CMD2(CheckMemory),
DEFINE_CMD2(EraseMemory),
DEFINE_CMD2(QueryConfiguration),
DEFINE_CMD2(UpdateConfiguration),
//
DEFINE_CMD2(Execute ),
DEFINE_CMD2(Reboot ),
DEFINE_CMD2(MemoryMap ),
DEFINE_CMD2(Execute),
DEFINE_CMD2(Reboot),
DEFINE_CMD2(MemoryMap),
DEFINE_CMD2(FlashSectorMap),
DEFINE_CMD2(TargetInfo),
DEFINE_CMD2(DeploymentMap),
//
DEFINE_CMD(Execution_BasePtr ),
DEFINE_CMD(Execution_BasePtr),
DEFINE_CMD(Execution_ChangeConditions),
//
DEFINE_CMD(Execution_Allocate ),
DEFINE_CMD(Execution_Allocate),

DEFINE_CMD(UpgradeToSsl),








#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
DEFINE_CMD(Execution_SetCurrentAppDomain),
DEFINE_CMD(Execution_Breakpoints ),
DEFINE_CMD(Execution_BreakpointStatus ),
DEFINE_CMD(Execution_Breakpoints),
DEFINE_CMD(Execution_BreakpointStatus),
//
DEFINE_CMD(Thread_CreateEx ),
DEFINE_CMD(Thread_List ),
DEFINE_CMD(Thread_Stack ),
DEFINE_CMD(Thread_Kill ),
DEFINE_CMD(Thread_Suspend ),
DEFINE_CMD(Thread_Resume ),
DEFINE_CMD(Thread_GetException ),
DEFINE_CMD(Thread_Unwind ),
DEFINE_CMD(Thread_Get ),
DEFINE_CMD(Thread_CreateEx),
DEFINE_CMD(Thread_List),
DEFINE_CMD(Thread_Stack),
DEFINE_CMD(Thread_Kill),
DEFINE_CMD(Thread_Suspend),
DEFINE_CMD(Thread_Resume),
DEFINE_CMD(Thread_GetException),
DEFINE_CMD(Thread_Unwind),
DEFINE_CMD(Thread_Get),
//
DEFINE_CMD(Stack_Info ),
DEFINE_CMD(Stack_SetIP ),
DEFINE_CMD(Stack_Info),
DEFINE_CMD(Stack_SetIP),
//
DEFINE_CMD(Value_ResizeScratchPad ),
DEFINE_CMD(Value_GetStack ),
DEFINE_CMD(Value_GetField ),
DEFINE_CMD(Value_GetArray ),
DEFINE_CMD(Value_GetBlock ),
DEFINE_CMD(Value_GetScratchPad ),
DEFINE_CMD(Value_SetBlock ),
DEFINE_CMD(Value_SetArray ),
DEFINE_CMD(Value_AllocateObject ),
DEFINE_CMD(Value_AllocateString ),
DEFINE_CMD(Value_AllocateArray ),
DEFINE_CMD(Value_Assign ),
DEFINE_CMD(Value_ResizeScratchPad),
DEFINE_CMD(Value_GetStack),
DEFINE_CMD(Value_GetField),
DEFINE_CMD(Value_GetArray),
DEFINE_CMD(Value_GetBlock),
DEFINE_CMD(Value_GetScratchPad),
DEFINE_CMD(Value_SetBlock),
DEFINE_CMD(Value_SetArray),
DEFINE_CMD(Value_AllocateObject),
DEFINE_CMD(Value_AllocateString),
DEFINE_CMD(Value_AllocateArray),
DEFINE_CMD(Value_Assign),
//
DEFINE_CMD(TypeSys_Assemblies ),
DEFINE_CMD(TypeSys_AppDomains ),
DEFINE_CMD(TypeSys_Assemblies),
DEFINE_CMD(TypeSys_AppDomains),
//
DEFINE_CMD(Resolve_AppDomain ),
DEFINE_CMD(Resolve_Assembly ),
DEFINE_CMD(Resolve_Type ),
DEFINE_CMD(Resolve_Field ),
DEFINE_CMD(Resolve_Method ),
DEFINE_CMD(Resolve_VirtualMethod ),
DEFINE_CMD(Resolve_AppDomain),
DEFINE_CMD(Resolve_Assembly),
DEFINE_CMD(Resolve_Type),
DEFINE_CMD(Resolve_Field),
DEFINE_CMD(Resolve_Method),
DEFINE_CMD(Resolve_VirtualMethod),
#endif
//
//
#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING)
DEFINE_CMD(Deployment_Status ),
DEFINE_CMD(Info_SetJMC ),
#endif
//
DEFINE_CMD(Deployment_Status),
DEFINE_CMD(Info_SetJMC),
#endif
//
#if defined(NANOCLR_PROFILE_NEW)
DEFINE_CMD3(Command),
#endif
//
};

const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Reply[] =
{
const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Reply[] = {
DEFINE_CMD2(Ping),
};

Expand All @@ -104,5 +105,4 @@ const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Reply[] =
#undef DEFINE_CMD3

const CLR_UINT32 c_Debugger_Lookup_Request_count = ARRAYSIZE(c_Debugger_Lookup_Request);
const CLR_UINT32 c_Debugger_Lookup_Reply_count = ARRAYSIZE(c_Debugger_Lookup_Reply);

const CLR_UINT32 c_Debugger_Lookup_Reply_count = ARRAYSIZE(c_Debugger_Lookup_Reply);
38 changes: 18 additions & 20 deletions src/CLR/Debugger/Debugger_minimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,40 @@
#include <nanoCLR_Runtime.h>
#include <nanoCLR_Debugging.h>

#define DEFINE_CMD(cmd) { CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd }
#define DEFINE_CMD2(cmd) { CLR_DBG_Debugger::Monitor_##cmd , CLR_DBG_Commands::c_Monitor_##cmd }

const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] =
{
DEFINE_CMD2(Ping ),
DEFINE_CMD2(Reboot ),
#define DEFINE_CMD(cmd) \
{ \
CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd \
}
#define DEFINE_CMD2(cmd) \
{ \
CLR_DBG_Debugger::Monitor_##cmd, CLR_DBG_Commands::c_Monitor_##cmd \
}

const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] = {
DEFINE_CMD2(Ping),
DEFINE_CMD2(Reboot),
DEFINE_CMD(Execution_QueryCLRCapabilities),

DEFINE_CMD2(ReadMemory ),
DEFINE_CMD2(ReadMemory),
DEFINE_CMD2(WriteMemory),
DEFINE_CMD2(EraseMemory),
DEFINE_CMD2(QueryConfiguration),
DEFINE_CMD2(UpdateConfiguration),
//
DEFINE_CMD2(Execute ),
DEFINE_CMD2(MemoryMap ),
DEFINE_CMD2(Execute),
DEFINE_CMD2(MemoryMap),
DEFINE_CMD2(FlashSectorMap),

DEFINE_CMD2(TargetInfo),
DEFINE_CMD(UpgradeToSsl),







};

const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Reply[] =
{
const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Reply[] = {
DEFINE_CMD2(Ping),
};

#undef DEFINE_CMD
#undef DEFINE_CMD2

const CLR_UINT32 c_Debugger_Lookup_Request_count = ARRAYSIZE(c_Debugger_Lookup_Request);
const CLR_UINT32 c_Debugger_Lookup_Reply_count = ARRAYSIZE(c_Debugger_Lookup_Reply);
const CLR_UINT32 c_Debugger_Lookup_Reply_count = ARRAYSIZE(c_Debugger_Lookup_Reply);
37 changes: 20 additions & 17 deletions src/CLR/Debugger/Debugger_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//
#include <nanoCLR_Runtime.h>


////////////////////////////////////////////////////////////////////////////////////////////////////
__nfweak void CLR_DBG_Debugger::Debugger_Discovery()
{
Expand Down Expand Up @@ -37,7 +36,11 @@ __nfweak HRESULT CLR_DBG_Debugger::DeleteInstance()
NANOCLR_SYSTEM_STUB_RETURN();
}

__nfweak void CLR_DBG_Debugger::BroadcastEvent( unsigned int cmd, unsigned int payloadSize, unsigned char* payload, unsigned int flags )
__nfweak void CLR_DBG_Debugger::BroadcastEvent(
unsigned int cmd,
unsigned int payloadSize,
unsigned char *payload,
unsigned int flags)
{
(void)cmd;
(void)payloadSize;
Expand All @@ -48,26 +51,26 @@ __nfweak void CLR_DBG_Debugger::BroadcastEvent( unsigned int cmd, unsigned int p
}

__nfweak void NFReleaseInfo::Init(
NFReleaseInfo& NFReleaseInfo,
unsigned short int major,
unsigned short int minor,
unsigned short int build,
unsigned short int revision,
const char *info,
NFReleaseInfo &NFReleaseInfo,
unsigned short int major,
unsigned short int minor,
unsigned short int build,
unsigned short int revision,
const char *info,
size_t infoLen,
const char *target,
const char *target,
size_t targetLen,
const char *platform,
const char *platform,
size_t platformLen)
{
size_t len;

NFVersion::Init( NFReleaseInfo.Version, major, minor, build, revision );
NFVersion::Init(NFReleaseInfo.Version, major, minor, build, revision);

// better set these to empty strings, in case there is nothing to fill in
NFReleaseInfo.InfoString[ 0 ] = 0;
NFReleaseInfo.TargetName[ 0 ] = 0;
NFReleaseInfo.PlatformName[ 0 ] = 0;
NFReleaseInfo.InfoString[0] = 0;
NFReleaseInfo.TargetName[0] = 0;
NFReleaseInfo.PlatformName[0] = 0;

// fill each one, if it was provided
if (NULL != info)
Expand All @@ -92,15 +95,15 @@ __nfweak void NFReleaseInfo::Init(
}
}

__nfweak bool SOCKETS_DbgInitialize( int ComPortNum )
__nfweak bool SOCKETS_DbgInitialize(int ComPortNum)
{
NATIVE_PROFILE_CLR_DEBUGGER();

(void)ComPortNum;
return true;
}

__nfweak bool SOCKETS_DbgUninitialize( int ComPortNum )
__nfweak bool SOCKETS_DbgUninitialize(int ComPortNum)
{
NATIVE_PROFILE_CLR_DEBUGGER();

Expand Down
14 changes: 14 additions & 0 deletions src/CLR/Include/WireProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef enum CLR_DBG_Commands_Monitor
CLR_DBG_Commands_c_Monitor_OemInfo = 0x0000000E,
CLR_DBG_Commands_c_Monitor_QueryConfiguration = 0x0000000F,
CLR_DBG_Commands_c_Monitor_UpdateConfiguration = 0x00000010,
CLR_DBG_Commands_c_Monitor_TargetInfo = 0x00000020,
}CLR_DBG_Commands_Monitor;

// structure for Wire Protocol packet
Expand Down Expand Up @@ -200,6 +201,19 @@ typedef struct ReleaseInfo

}ReleaseInfo;

// structure to hold nanoFramework Target information
typedef struct TargetInfo
{

VersionInfo BooterVersion;
VersionInfo ClrVersion;
uint8_t InfoString[128];
uint8_t TargetName[32];
uint8_t PlatformName[32];
uint8_t PlatformInfoString[128];

}TargetInfo;

// structure for Wire Protocol command handler lookup
typedef struct CommandHandlerLookup
{
Expand Down
14 changes: 13 additions & 1 deletion src/CLR/Include/WireProtocol_MonitorCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#ifndef _WIREPROTOCOL_COMMANDS_H_
#define _WIREPROTOCOL_COMMANDS_H_

#include <nanoHAL_v2.h>
#include "WireProtocol.h"
#include "WireProtocol_Message.h"
#include <nanoPackStruct.h>

// clang-format off

Expand Down Expand Up @@ -82,6 +82,13 @@ typedef struct Monitor_OemInfo_Reply

} Monitor_OemInfo_Reply;

// structure with reply for Target information command
typedef struct Monitor_TargetInfo_Reply
{
TargetInfo m_TargetInfo;

} Monitor_TargetInfo_Reply;

typedef struct CLR_DBG_Commands_Monitor_ReadMemory
{
uint32_t address;
Expand Down Expand Up @@ -183,6 +190,11 @@ extern "C"
int Monitor_CheckMemory(WP_Message *message);
int Monitor_MemoryMap(WP_Message *message);
int Monitor_FlashSectorMap(WP_Message *message);
int Monitor_TargetInfo(WP_Message *message);

// helper functions
int nanoBooter_GetTargetInfo(TargetInfo *targetInfo);
int NanoBooter_GetReleaseInfo(ReleaseInfo *releaseInfo);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions src/CLR/Include/nanoCLR_Debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ struct CLR_DBG_Debugger

static bool Monitor_Ping ( WP_Message *msg );
static bool Monitor_Reboot ( WP_Message *msg );
static bool Monitor_TargetInfo ( WP_Message *msg );
static bool Debugging_Execution_QueryCLRCapabilities( WP_Message *msg );

static bool Monitor_ReadMemory ( WP_Message *msg );
Expand Down
Loading

0 comments on commit c76782b

Please sign in to comment.