From d61816b5b8c5e0f5d5c9e6c5e6811bee59c98140 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Thu, 3 Mar 2011 01:41:57 +0000 Subject: Add TestTargetAPI.py: // When stopped on breakppint 1, and then 2, we can get the line entries using // SBFrame API SBFrame.GetLineEntry(). We'll get the start addresses for the // two line entries; with the start address (of SBAddress type), we can then // resolve the symbol context using the SBTarget API // SBTarget.ResolveSymbolContextForAddress(). // // The two symbol context should point to the same symbol, i.e., 'a' function. Add two utility functions to lldbutil.py: o get_stopped_threads(process, reason): return the list of threads with the specified stop reason or an empty list if not found o get_stopped_thread(process, reason): return the first thread with the given stop reason or None if not found llvm-svn: 126916 --- lldb/test/python_api/process/TestProcessAPI.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lldb/test/python_api/process/TestProcessAPI.py') diff --git a/lldb/test/python_api/process/TestProcessAPI.py b/lldb/test/python_api/process/TestProcessAPI.py index fd8b229553e..474ae062059 100644 --- a/lldb/test/python_api/process/TestProcessAPI.py +++ b/lldb/test/python_api/process/TestProcessAPI.py @@ -5,6 +5,7 @@ Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others. import os, time import unittest2 import lldb +from lldbutil import get_stopped_thread from lldbtest import * class ProcessAPITestCase(TestBase): @@ -71,8 +72,9 @@ class ProcessAPITestCase(TestBase): error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = self.process.GetThreadAtIndex(0); - frame = thread.GetFrameAtIndex(0); + thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") + frame = thread.GetFrameAtIndex(0) # Get the SBValue for the global variable 'my_char'. val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal) @@ -111,8 +113,9 @@ class ProcessAPITestCase(TestBase): error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = self.process.GetThreadAtIndex(0); - frame = thread.GetFrameAtIndex(0); + thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") + frame = thread.GetFrameAtIndex(0) # Get the SBValue for the global variable 'my_char'. val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal) @@ -160,8 +163,9 @@ class ProcessAPITestCase(TestBase): error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = self.process.GetThreadAtIndex(0); - frame = thread.GetFrameAtIndex(0); + thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") + frame = thread.GetFrameAtIndex(0) # Get the SBValue for the global variable 'my_int'. val = frame.FindValue("my_int", lldb.eValueTypeVariableGlobal) -- cgit v1.2.3