[Lldb-commits] [lldb] r130038 - in /lldb/trunk/test: lldbutil.py python_api/target/TestTargetAPI.py
Johnny Chen
johnny.chen at apple.com
Fri Apr 22 17:13:34 PDT 2011
Author: johnny
Date: Fri Apr 22 19:13:34 2011
New Revision: 130038
URL: http://llvm.org/viewvc/llvm-project?rev=130038&view=rev
Log:
Add a simple utility function get_description(lldb_obj, option=None) to lldbutil.py
and use it from TestTargetAPI.py.
Modified:
lldb/trunk/test/lldbutil.py
lldb/trunk/test/python_api/target/TestTargetAPI.py
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130038&r1=130037&r2=130038&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Fri Apr 22 19:13:34 2011
@@ -168,6 +168,24 @@
return None
return threads[0]
+# ==============================================================
+# Get the description of an lldb object or None if not available
+# ==============================================================
+def get_description(lldb_obj, option=None):
+ """Calls lldb_obj.GetDescription() and returns a string, or None."""
+ method = getattr(lldb_obj, 'GetDescription')
+ if not method:
+ return None
+ stream = lldb.SBStream()
+ if option is None:
+ success = method(stream)
+ else:
+ success = method(stream, option)
+ if not success:
+ return None
+ return stream.GetData()
+
+
# =================================================
# Convert some enum value to its string counterpart
# =================================================
Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=130038&r1=130037&r2=130038&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Fri Apr 22 19:13:34 2011
@@ -66,18 +66,19 @@
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
- stream = lldb.SBStream()
- if not target.GetDescription(stream, lldb.eDescriptionLevelBrief):
+ from lldbutil import get_description
+ desc = get_description(target, option=lldb.eDescriptionLevelBrief)
+ if not desc:
self.fail("SBTarget.GetDescription() failed")
- self.expect(stream.GetData(), exe=False,
+ self.expect(desc, exe=False,
substrs = ['a.out'])
- self.expect(stream.GetData(), exe=False, matching=False,
+ self.expect(desc, exe=False, matching=False,
substrs = ['Target', 'Module', 'Breakpoint'])
- stream.Clear()
- if not target.GetDescription(stream, lldb.eDescriptionLevelFull):
+ desc = get_description(target, option=lldb.eDescriptionLevelFull)
+ if not desc:
self.fail("SBTarget.GetDescription() failed")
- self.expect(stream.GetData(), exe=False,
+ self.expect(desc, exe=False,
substrs = ['a.out', 'Target', 'Module', 'Breakpoint'])
More information about the lldb-commits
mailing list