[lldb/Test] use GetLoadAddress from scripted thread plan
authorJonas Devlieghere <jonas@devlieghere.com>
Sat, 30 May 2020 06:01:09 +0000 (23:01 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Sat, 30 May 2020 06:04:08 +0000 (23:04 -0700)
Commit 0800529fe605 adds a runtime error which triggers when using
SBAddress properties that use the current process/target from a
non-interactive session. TestThreadPlanCommands.py was doing exactly
this and this patch fixes that by use GetLoadAddress instead.

lldb/test/API/functionalities/thread_plan/wrap_step_over.py

index a7b3976..bce34d6 100644 (file)
@@ -3,14 +3,16 @@ import lldb
 class WrapStepOver():
     def __init__(self, thread_plan, args_data, dict):
         self.plan = thread_plan
-        frame_0 = thread_plan.GetThread().frames[0]
+        thread = thread_plan.GetThread()
+        target = thread.GetProcess().GetTarget()
+        frame_0 = thread.frames[0]
         line_entry = frame_0.line_entry
         start_addr = line_entry.addr
         end_addr = line_entry.end_addr
-        range_size = int(end_addr) - int(start_addr)
+        range_size = end_addr.GetLoadAddress(target) - start_addr.GetLoadAddress(target)
         error = lldb.SBError()
         self.sub_plan = thread_plan.QueueThreadPlanForStepOverRange(start_addr, range_size)
-        
+
     def should_step(self):
         return False