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
|
From 388e7b4e98367cbdf03858817da7d756ea4247a3 Mon Sep 17 00:00:00 2001
From: Konstantin Baladurin <k.baladurin@partner.samsung.com>
Date: Tue, 3 Oct 2017 21:28:06 +0300
Subject: [PATCH] Use addresses without sign extension in lldb plugin (#14009)
lldb doesn't expect sign-extended addresses so we need to convert
them before using with lldb API.
This patch allows to use SOS plugin for core files in lldb on 32-bit
platforms and also fixes output of the 'clrstack -f' command.
---
src/ToolBox/SOS/lldbplugin/services.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/ToolBox/SOS/lldbplugin/services.cpp b/src/ToolBox/SOS/lldbplugin/services.cpp
index 262f814..3186920 100644
--- a/src/ToolBox/SOS/lldbplugin/services.cpp
+++ b/src/ToolBox/SOS/lldbplugin/services.cpp
@@ -8,6 +8,8 @@
#include <string.h>
#include <string>
+#define CONVERT_FROM_SIGN_EXTENDED(offset) ((ULONG_PTR)(offset))
+
ULONG g_currentThreadIndex = -1;
ULONG g_currentThreadSystemId = -1;
char *g_coreclrDirectory;
@@ -545,6 +547,9 @@ LLDBServices::Disassemble(
uint8_t byte;
int cch;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
if (buffer == NULL)
{
hr = E_INVALIDARG;
@@ -750,6 +755,9 @@ LLDBServices::ReadVirtual(
lldb::SBError error;
size_t read = 0;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
lldb::SBProcess process = GetCurrentProcess();
if (!process.IsValid())
{
@@ -776,6 +784,9 @@ LLDBServices::WriteVirtual(
lldb::SBError error;
size_t written = 0;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
lldb::SBProcess process = GetCurrentProcess();
if (!process.IsValid())
{
@@ -822,6 +833,9 @@ LLDBServices::GetNameByOffset(
lldb::SBSymbol symbol;
std::string str;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
target = m_debugger.GetSelectedTarget();
if (!target.IsValid())
{
@@ -1012,6 +1026,9 @@ LLDBServices::GetModuleByOffset(
lldb::SBTarget target;
int numModules;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
target = m_debugger.GetSelectedTarget();
if (!target.IsValid())
{
@@ -1076,6 +1093,9 @@ LLDBServices::GetModuleNames(
lldb::SBFileSpec fileSpec;
HRESULT hr = S_OK;
+ // lldb doesn't expect sign-extended address
+ base = CONVERT_FROM_SIGN_EXTENDED(base);
+
target = m_debugger.GetSelectedTarget();
if (!target.IsValid())
{
@@ -1167,6 +1187,9 @@ LLDBServices::GetLineByOffset(
lldb::SBLineEntry lineEntry;
std::string str;
+ // lldb doesn't expect sign-extended address
+ offset = CONVERT_FROM_SIGN_EXTENDED(offset);
+
target = m_debugger.GetSelectedTarget();
if (!target.IsValid())
{
--
2.7.4
|