Skip to content

Commit 6058bfc

Browse files
Merge pull request swiftlang#9277 from adrian-prantl/135576217
Properly convert file addresses to load addresses when resolving glob
2 parents b09cd64 + 316f6d2 commit 6058bfc

File tree

3 files changed

+50
-39
lines changed

3 files changed

+50
-39
lines changed

lldb/source/Core/ValueObjectVariable.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,26 @@ bool ValueObjectVariable::UpdateValue() {
231231
if (type->GetForwardCompilerType()
232232
.GetTypeSystem()
233233
.dyn_cast_or_null<TypeSystemSwift>() &&
234-
TypePayloadSwift(type->GetPayload()).IsFixedValueBuffer())
234+
TypePayloadSwift(type->GetPayload()).IsFixedValueBuffer() &&
235+
m_value.GetValueType() == Value::ValueType::FileAddress)
235236
if (auto process_sp = GetProcessSP())
236237
if (auto runtime = process_sp->GetLanguageRuntime(
237238
compiler_type.GetMinimumLanguage())) {
238239
if (!runtime->IsStoredInlineInBuffer(compiler_type)) {
239-
lldb::addr_t addr =
240-
m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
241-
if (addr != LLDB_INVALID_ADDRESS) {
242-
Target &target = process_sp->GetTarget();
243-
size_t ptr_size = process_sp->GetAddressByteSize();
244-
lldb::addr_t deref_addr;
245-
target.ReadMemory(addr, &deref_addr, ptr_size, m_error, true);
246-
m_value.GetScalar() = deref_addr;
240+
if (auto *scs = variable->GetSymbolContextScope()) {
241+
if (auto module_sp = scs->CalculateSymbolContextModule()) {
242+
lldb::addr_t file_addr =
243+
m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
244+
Address address(file_addr, module_sp->GetSectionList());
245+
Target &target = process_sp->GetTarget();
246+
size_t ptr_size = process_sp->GetAddressByteSize();
247+
lldb::addr_t deref_addr;
248+
lldb::addr_t load_addr = address.GetLoadAddress(&target);
249+
// FIXME: Add error handling!
250+
if (target.ReadMemory(load_addr, &deref_addr, ptr_size,
251+
m_error, process_is_alive))
252+
m_value.GetScalar() = deref_addr;
253+
}
247254
}
248255
}
249256
}
Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
# TestSwiftFoundationValueTypes.py
2-
#
3-
# This source file is part of the Swift.org open source project
4-
#
5-
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6-
# Licensed under Apache License v2.0 with Runtime Library Exception
7-
#
8-
# See https://swift.org/LICENSE.txt for license information
9-
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10-
#
11-
# ------------------------------------------------------------------------------
12-
import lldbsuite.test.lldbinline as lldbinline
1+
import lldb
132
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
145

15-
lldbinline.MakeInlineTest(
16-
__file__, globals(), decorators=
17-
[skipUnlessDarwin,swiftTest])
6+
7+
class TestSwiftFoundationTypeNotification(lldbtest.TestBase):
8+
9+
mydir = lldbtest.TestBase.compute_mydir(__file__)
10+
11+
@swiftTest
12+
def test(self):
13+
self.build()
14+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
15+
self, 'break here', lldb.SBFileSpec('main.swift'))
16+
self.expect("log enable lldb types -v")
17+
# global
18+
self.expect("target variable -d run g_notification",
19+
substrs=['name = ', '"MyNotification"',
20+
'object = nil',
21+
'userInfo = 0 key/value pairs'])
22+
self.expect("expression -d run -- g_notification",
23+
substrs=['name = ', '"MyNotification"',
24+
'object = nil',
25+
'userInfo = 0 key/value pairs'])
26+
# local
27+
self.expect("frame variable -d run -- notification",
28+
substrs=['name = ', '"MyNotification"',
29+
'object = nil',
30+
'userInfo = 0 key/value pairs'])
31+
self.expect("expression -d run -- notification",
32+
substrs=['name = ', '"MyNotification"',
33+
'object = nil',
34+
'userInfo = 0 key/value pairs'])
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
// main.swift
2-
//
3-
// This source file is part of the Swift.org open source project
4-
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6-
// Licensed under Apache License v2.0 with Runtime Library Exception
7-
//
8-
// See https://swift.org/LICENSE.txt for license information
9-
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10-
//
11-
// -----------------------------------------------------------------------------
121
import Foundation
132

143
func main() {
154
var notification = Notification(name: Notification.Name(rawValue: "MyNotification"), object: nil, userInfo: [:])
16-
print("done!") //% self.expect("frame variable -d run -- notification", substrs=['name = ', '"MyNotification"', 'object = nil', 'userInfo = 0 key/value pairs'])
17-
//% self.expect("expression -d run -- notification", substrs=['name = ', '"MyNotification"', 'object = nil', 'userInfo = 0 key/value pairs'])
5+
print("break here!")
186
}
197

208
var g_notification = Notification(name: Notification.Name(rawValue: "MyNotification"), object: nil, userInfo: [:])
219

22-
main() //% self.expect("target variable -d run g_notification", substrs=['name = ', '"MyNotification"', 'object = nil', 'userInfo = 0 key/value pairs'])
23-
//% self.expect("expression -d run -- g_notification", substrs=['name = ', '"MyNotification"', 'object = nil', 'userInfo = 0 key/value pairs'])
10+
main()

0 commit comments

Comments
 (0)