Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4502 from seanshpark/arm_sos_with_lldb38
Browse files Browse the repository at this point in the history
ARM, SOS: Fix libsos.so load fail and changes for SOS to work with ARM-Linux
  • Loading branch information
mikem8361 committed Apr 26, 2016
2 parents 3fbfb5e + 8c80873 commit 18268be
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/ToolBox/PdbTypeMatch/PdbTypeMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ bool LoadDataFromPdb(
case IMAGE_FILE_MACHINE_I386 : g_dwMachineType = CV_CFL_80386; break;
case IMAGE_FILE_MACHINE_IA64 : g_dwMachineType = CV_CFL_IA64; break;
case IMAGE_FILE_MACHINE_AMD64 : g_dwMachineType = CV_CFL_AMD64; break;
case IMAGE_FILE_MACHINE_ARMNT : g_dwMachineType = CV_CFL_ARM7; break;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/ToolBox/SOS/Strike/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
add_definitions(-DSOS_TARGET_ARM=1)
add_definitions(-D_TARGET_WIN32_=1)
add_definitions(-D_TARGET_ARM_=1)
add_definitions(-DDBG_TARGET_32BIT)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
add_definitions(-DSOS_TARGET_ARM64=1)
Expand Down
7 changes: 7 additions & 0 deletions src/ToolBox/SOS/Strike/datatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ HRESULT STDMETHODCALLTYPE
DataTarget::GetPointerSize(
/* [out] */ ULONG32 *size)
{
#if defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64)
*size = 8;
#elif defined(SOS_TARGET_ARM)
*size = 4;
#elif
#error Unsupported architecture
#endif

return S_OK;
}

Expand Down
7 changes: 4 additions & 3 deletions src/ToolBox/SOS/Strike/disasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ eTargetType GetFinalTarget(DWORD_PTR callee, DWORD_PTR* finalMDorIP);
//-----------------------------------------------------------------------------------------

#ifndef THUMB_CODE
#define THUMB_CODE 1;
#define THUMB_CODE 1
#endif
#define STACKWALK_CONTROLPC_ADJUST_OFFSET 2;
#define STACKWALK_CONTROLPC_ADJUST_OFFSET 2

#ifdef SOS_TARGET_X86

Expand Down Expand Up @@ -186,7 +186,7 @@ class ARMMachine : public IMachine
typedef ARM_CONTEXT TGT_CTXT;

static IMachine* GetInstance()
{ static ARMMachine s_ARMMachineInstance; return &s_ARMMachineInstance; }
{ return &s_ARMMachineInstance; }

ULONG GetPlatform() const { return IMAGE_FILE_MACHINE_ARMNT; }
ULONG GetContextSize() const { return sizeof(ARM_CONTEXT); }
Expand Down Expand Up @@ -238,6 +238,7 @@ class ARMMachine : public IMachine
static LPCSTR s_DSOHeading;
static LPCSTR s_GCRegs[14];
static LPCSTR s_SPName;
static ARMMachine s_ARMMachineInstance;
}; // class ARMMachine

#endif // SOS_TARGET_ARM
Expand Down
16 changes: 11 additions & 5 deletions src/ToolBox/SOS/Strike/disasmARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace ARMGCDump
#error This file should be used to support SOS targeting ARM debuggees
#endif

#ifdef SOS_TARGET_ARM
ARMMachine ARMMachine::s_ARMMachineInstance;

// Decodes the target label of the immediate form of bl and blx instructions. The PC given is that of the
// start of the instruction.
Expand Down Expand Up @@ -334,6 +336,8 @@ static void HandleValue(TADDR value)
}
}

#endif // !FEATURE_PAL

/**********************************************************************\
* Routine Description: *
* *
Expand All @@ -351,6 +355,7 @@ void ARMMachine::Unassembly (
BOOL bSuppressLines,
BOOL bDisplayOffsets) const
{
#ifndef FEATURE_PAL
ULONG_PTR PC = PCBegin;
char line[1024];
char *ptr;
Expand Down Expand Up @@ -524,11 +529,12 @@ void ARMMachine::Unassembly (

ExtOut ("\n");
}
#endif // !FEATURE_PAL
}

#if 0 // @ARMTODO: Figure out how to extract this information under CoreARM
static void ExpFuncStateInit (TADDR *PCRetAddr)
{
#if 0 // @ARMTODO: Figure out how to extract this information under CoreARM
ULONG64 offset;
if (FAILED(g_ExtSymbols->GetOffsetByName("ntdll!KiUserExceptionDispatcher", &offset))) {
return;
Expand All @@ -541,10 +547,9 @@ static void ExpFuncStateInit (TADDR *PCRetAddr)
PCRetAddr[i++] = (TADDR)offset;
}
}
#endif // 0
}
#endif // 0

#endif // !FEATURE_PAL

// @ARMTODO: Figure out how to extract this information under CoreARM
BOOL ARMMachine::GetExceptionContext (TADDR stack, TADDR PC, TADDR *cxrAddr, CROSS_PLATFORM_CONTEXT * cxr,
Expand Down Expand Up @@ -598,13 +603,13 @@ BOOL ARMMachine::GetExceptionContext (TADDR stack, TADDR PC, TADDR *cxrAddr, CRO
#endif // 0
}

#ifndef FEATURE_PAL

///
/// Dump ARM GCInfo table
///
void ARMMachine::DumpGCInfo(BYTE* pTable, unsigned methodSize, printfFtn gcPrintf, bool encBytes, bool bPrintHeader) const
{
#ifndef FEATURE_PAL
if (bPrintHeader)
{
ExtOut("Pointer table:\n");
Expand All @@ -614,6 +619,7 @@ void ARMMachine::DumpGCInfo(BYTE* pTable, unsigned methodSize, printfFtn gcPrint
gcDump.gcPrintf = gcPrintf;

gcDump.DumpGCTable(pTable, methodSize, 0);
#endif // !FEATURE_PAL
}

#endif // !FEATURE_PAL
#endif // SOS_TARGET_ARM
2 changes: 2 additions & 0 deletions src/ToolBox/SOS/Strike/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4548,6 +4548,8 @@ class SOSDataTarget : public ICorDebugMutableDataTarget
*pPlatform = CORDB_PLATFORM_POSIX_X86;
else if(platformKind == IMAGE_FILE_MACHINE_AMD64)
*pPlatform = CORDB_PLATFORM_POSIX_AMD64;
else if(platformKind == IMAGE_FILE_MACHINE_ARMNT)
*pPlatform = CORDB_PLATFORM_POSIX_ARM;
else
return E_FAIL;
#else
Expand Down
1 change: 1 addition & 0 deletions src/ToolBox/SOS/lldbplugin/inc/lldbservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern "C" {
#define DEBUG_CLASS_IMAGE_FILE 3

#define IMAGE_FILE_MACHINE_I386 0x014c // Intel 386.
#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian
#define IMAGE_FILE_MACHINE_AMD64 0x8664 // AMD64 (K8)

// Execution status codes used for waiting,
Expand Down
4 changes: 4 additions & 0 deletions src/ToolBox/SOS/lldbplugin/services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ HRESULT
LLDBServices::GetExecutingProcessorType(
PULONG type)
{
#ifdef DBG_TARGET_AMD64
*type = IMAGE_FILE_MACHINE_AMD64;
#elif DBG_TARGET_ARM
*type = IMAGE_FILE_MACHINE_ARMNT;
#endif
return S_OK;
}

Expand Down
6 changes: 5 additions & 1 deletion src/debug/daccess/datatargetadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ DataTargetAdapter::GetPlatform(
platform = CORDB_PLATFORM_POSIX_AMD64;
break;

case IMAGE_FILE_MACHINE_IA64:
case IMAGE_FILE_MACHINE_ARMNT:
ulExpectedPointerSize = 4;
platform = CORDB_PLATFORM_POSIX_ARM;
break;

case IMAGE_FILE_MACHINE_IA64:
case IMAGE_FILE_MACHINE_ARM64:
_ASSERTE_MSG(false, "Not supported platform.");
return E_NOTIMPL;
Expand Down

0 comments on commit 18268be

Please sign in to comment.