summaryrefslogtreecommitdiff
path: root/packaging/0011-Enable-sosplugin-on-ARM-14.patch
blob: 4a4c4f84178f2465911e51bdff5f0a5aa00d0f4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From 9f0bbb5adf7444d187a01b84ec3ba6d99e46b86f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=9D=B4=EC=B6=98=EC=84=9D/Developer=20Experience=20Lab?=
 =?UTF-8?q?=28S/W=EC=84=BC=ED=84=B0=29/Senior=20Engineer/=EC=82=BC?=
 =?UTF-8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= <chunseok.lee@samsung.com>
Date: Thu, 24 Aug 2017 07:27:41 +0900
Subject: [PATCH 11/23] Enable sosplugin on ARM (#14)

* Fix CreateDump-related undefined reference on non-AMD64/Linux platforms (#11635)

* Enable DacStackWalk

For ARM/Linux, DacUnwindStackFrame failed to unwind stack frame due to
the mismatch between RUNTIME_FUNCTION and IMAGE_ARM_RUNTIME_FUNCTION_ENTRY.

ClrStack SOS command currently does not work due to this bug.

This commit fixes this mismatch and re-enables ClrStack SOS command.
---
 src/ToolBox/SOS/Strike/CMakeLists.txt |  1 +
 src/ToolBox/SOS/Strike/strike.cpp     | 10 +++++-----
 src/unwinder/arm/unwinder_arm.cpp     | 14 +++++---------
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt
index ff5f864..65c3f95 100644
--- a/src/ToolBox/SOS/Strike/CMakeLists.txt
+++ b/src/ToolBox/SOS/Strike/CMakeLists.txt
@@ -150,6 +150,7 @@ if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
       SOS_LIBRARY 
       createdump_lib
     )
+    add_definitions(-DCREATE_DUMP_SUPPORTED)
   endif(CLR_CMAKE_PLATFORM_LINUX)
   set(SOS_SOURCES_ARCH
     disasmX86.cpp
diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp
index 1fff17f..7e01635 100644
--- a/src/ToolBox/SOS/Strike/strike.cpp
+++ b/src/ToolBox/SOS/Strike/strike.cpp
@@ -14370,17 +14370,17 @@ _EFN_GetManagedObjectFieldInfo(
 
 #ifdef FEATURE_PAL
 
-#ifdef __linux__
+#ifdef CREATE_DUMP_SUPPORTED
 #include <dumpcommon.h>
 #include "datatarget.h"
 extern bool CreateDumpForSOS(const char* programPath, const char* dumpPathTemplate, pid_t pid, MINIDUMP_TYPE minidumpType, ICLRDataTarget* dataTarget);
 extern bool g_diagnostics;
-#endif // __linux__
+#endif // CREATE_DUMP_SUPPORTED
 
 DECLARE_API(CreateDump)
 {
     INIT_API();
-#ifdef __linux__
+#ifdef CREATE_DUMP_SUPPORTED
     StringHolder sFileName;
     BOOL normal = FALSE;
     BOOL withHeap = FALSE;
@@ -14440,9 +14440,9 @@ DECLARE_API(CreateDump)
     {
         Status = E_FAIL;
     } 
-#else // __linux__
+#else // CREATE_DUMP_SUPPORTED
     ExtErr("CreateDump not supported on this platform\n");
-#endif // __linux__
+#endif // CREATE_DUMP_SUPPORTED
     return Status;
 }
 
diff --git a/src/unwinder/arm/unwinder_arm.cpp b/src/unwinder/arm/unwinder_arm.cpp
index 6b1f686..6228b01 100644
--- a/src/unwinder/arm/unwinder_arm.cpp
+++ b/src/unwinder/arm/unwinder_arm.cpp
@@ -647,7 +647,7 @@ Return Value:
 HRESULT
 RtlpUnwindFunctionCompact(
     __in ULONG ControlPcRva,
-    __in PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY FunctionEntry,
+    __in PT_RUNTIME_FUNCTION FunctionEntry,
     __inout PT_CONTEXT ContextRecord,
     __out PULONG EstablisherFrame,
     __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine,
@@ -917,7 +917,7 @@ HRESULT
 RtlpUnwindFunctionFull(
     __in ULONG ControlPcRva,
     __in ULONG ImageBase,
-    __in PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY FunctionEntry,
+    __in PT_RUNTIME_FUNCTION FunctionEntry,
     __inout PT_CONTEXT ContextRecord,
     __out PULONG EstablisherFrame,
     __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine,
@@ -1444,7 +1444,7 @@ BOOL OOPStackUnwinderArm::Unwind(T_CONTEXT * pContext)
     DWORD startingPc = pContext->Pc;
     DWORD startingSp = pContext->Sp;
     
-    IMAGE_ARM_RUNTIME_FUNCTION_ENTRY Rfe;
+    T_RUNTIME_FUNCTION Rfe;
     if (FAILED(GetFunctionEntry(DBS_EXTEND64(pContext->Pc), &Rfe, sizeof(Rfe))))
         return FALSE;
 
@@ -1511,17 +1511,13 @@ PEXCEPTION_ROUTINE RtlVirtualUnwind(
     PEXCEPTION_ROUTINE handlerRoutine;
     HRESULT res;
     
-    IMAGE_ARM_RUNTIME_FUNCTION_ENTRY rfe;
-    rfe.BeginAddress = FunctionEntry->BeginAddress;
-    rfe.UnwindData = FunctionEntry->UnwindData;
-    
     ARM_UNWIND_PARAMS unwindParams;
     unwindParams.ContextPointers = ContextPointers;
     
     if ((FunctionEntry->UnwindData & 3) != 0) 
     {
         res = RtlpUnwindFunctionCompact(ControlPc - ImageBase,
-                                        &rfe,
+                                        FunctionEntry,
                                         ContextRecord,
                                         EstablisherFrame,
                                         &handlerRoutine,
@@ -1533,7 +1529,7 @@ PEXCEPTION_ROUTINE RtlVirtualUnwind(
     {
         res = RtlpUnwindFunctionFull(ControlPc - ImageBase,
                                     ImageBase,
-                                    &rfe,
+                                    FunctionEntry,
                                     ContextRecord,
                                     EstablisherFrame,
                                     &handlerRoutine,
-- 
1.9.1