Commit Graph

51 Commits

Author SHA1 Message Date
Johnny Chen 13ea11afde Modify the test script to better handle the different inlining behaviors of
clang/gcc/llvm-gcc.  If the first breakpoint is due to stop at an inlined
frame, test that the call site corresponds to where it should be.  Also add
an expecr for a second break stop, if the first break stop corresponds to an
inlined call frame #0.

rdar://problem/9741470

llvm-svn: 135100
2011-07-13 22:34:29 +00:00
Johnny Chen 4cfd07ef07 Add TestInlinedFrame.py to exercise the newly added SBFrame APIs: IsInlined() and GetFunctionName().
llvm-svn: 133404
2011-06-20 00:26:39 +00:00
Johnny Chen 0d4f6dd01e o lldbutil.py:
For the print_stacktrace(thread, string_buffer = False) function, if we have debug info
  for a frame function, let's also emit the args for the current function.

o TestFrameUtils.py:

  Add stronger assertTrue for frame0's args.

o TestPrintStackTraces.py:

  Launch the inferior with ["abc", "xyz"] and expect '(int)argc=3' in the stack traces, since
  by design the inferior is built with debug info.

llvm-svn: 133204
2011-06-16 22:07:48 +00:00
Johnny Chen 5a0bee7c5f The extra burden for the Python API test case to assign its process object to self.process
in order to have its process cleaned up (terminated) upon tearDown is gone for good.
Let's simplify a bunch of Python API test cases.

llvm-svn: 133097
2011-06-15 22:14:12 +00:00
Johnny Chen 75ec159da5 Add comment.
llvm-svn: 132152
2011-05-26 21:53:05 +00:00
Johnny Chen 3cd1e55103 Convert these two modules to use the compact truth value testing as well.
llvm-svn: 132072
2011-05-25 19:06:18 +00:00
Johnny Chen b411b980ac Test commit from a git-svn-cloned lldb/trunk repository.
llvm-svn: 131319
2011-05-13 21:55:30 +00:00
Johnny Chen 52b0ffd9c6 When trying to print out the function name corresponding to the frame, if the function obj
from the frame is not valid, try look for the symbol in the symbol table.

llvm-svn: 131273
2011-05-13 00:44:49 +00:00
Johnny Chen ad7372c538 Add two utility functions:
o get_parent_frame(frame)
    o get_args_as_string(frame)

to lldbutil.py and create TestFrameUtils.py to exercise the utils.
Plus re-arrange the test/python_api/lldbutil to have three directories
for testing iteration, process stack traces, and the just added frame utils.

llvm-svn: 131213
2011-05-12 00:32:41 +00:00
Johnny Chen e9e8689f3b Add more docstrings for get_GPRs(frame), getFPRs(frame), and get_ESRs(frame).
llvm-svn: 131168
2011-05-10 23:01:44 +00:00
Johnny Chen 64ff7e6eee Add a utility function get_registers(frame, kind) to get the registers of a given frame and of a given kind.
Also add three convenience functions get_GPRs(frame), get_FPRs(frame), and get_ESRs(frame) to get the general
purpose registers, the floating point registers, and the exception state registers.

Add TestRegistersIterator.py to test these added functions of lldbutil.py.

llvm-svn: 131144
2011-05-10 19:21:13 +00:00
Johnny Chen 2158b97358 Fix docstring.
llvm-svn: 131072
2011-05-08 18:55:37 +00:00
Johnny Chen b21c52eac8 Add test scenario to verify 'eax' register is available when launching the i386 slice
of a universal binary and 'rax' register is available when launching the x86_64 slice.

rdar://problem/9403437

llvm-svn: 131069
2011-05-08 17:25:27 +00:00
Johnny Chen ae9639aeb3 Change the process iteration pattern to a more concise:
for thread in process:
        print >> output, print_stacktrace(thread, string_buffer=True)

llvm-svn: 130940
2011-05-05 18:50:56 +00:00
Johnny Chen e69c748328 Modify the test suite and lldbutil.py to utilize the Python iteration pattern now that
the lldb iteration protocol has been added to lldb.py module.

llvm-svn: 130452
2011-04-28 22:57:01 +00:00
Johnny Chen b2e1a5c998 Add a utility function smart_iter() which has knowledge of the getsize and the getelem
method names of all the lldb container objects and returns an iterator object when
passed an eligible lldb container object.

Example:

    from lldb_util import smart_iter
    for thread in smart_iter(process):
        ID = thread.GetThreadID()
        if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
            stopped_due_to_breakpoint = True
        for frame in smart_iter(thread):
            self.assertTrue(frame.GetThread().GetThreadID() == ID)
        ...

Add a test case for lldb.smart_iter().

llvm-svn: 130332
2011-04-27 21:44:09 +00:00
Johnny Chen de90f1dd93 Change the rest of lldbutil.py's function names to all lower case formats to be consistent.
And modify the test cases accordingly.

llvm-svn: 130314
2011-04-27 17:43:07 +00:00
Johnny Chen 35ec67464f Docstring.
llvm-svn: 130253
2011-04-26 23:10:15 +00:00
Johnny Chen 6424b7d272 Update comment.
llvm-svn: 130252
2011-04-26 23:07:40 +00:00
Johnny Chen 4fdcebda1d Docstring changees.
llvm-svn: 130251
2011-04-26 22:53:38 +00:00
Johnny Chen d0fef81e38 For lldbutil.py, Change a bunch of function names to all lower case formats to be consistent.
And modify the test cases accordingly.

llvm-svn: 130174
2011-04-25 23:38:13 +00:00
Johnny Chen d369908dac Move two functions around.
llvm-svn: 130158
2011-04-25 22:04:05 +00:00
Johnny Chen fc87e2dd5c Make SBBreakpointLocation::GetDescription() API to be consistent with SBTarget,
i.e., with 'SBStream &description' first, followed by 'DescriptionLevel level'.

Modify lldbutil.py so that get_description() for a target or breakpoint location
can just take the lldb object itself without specifying an option to mean option
lldb.eDescriptionLevelBrief.  Modify TestTargetAPI.py to exercise this logic path.

llvm-svn: 130147
2011-04-25 20:23:05 +00:00
Johnny Chen 90256cdaba Add a simple utility function get_description(lldb_obj, option=None) to lldbutil.py
and use it from TestTargetAPI.py.

llvm-svn: 130038
2011-04-23 00:13:34 +00:00
Johnny Chen 238de9a804 Add docstring.
llvm-svn: 129707
2011-04-18 18:34:09 +00:00
Johnny Chen 72f51aafe7 Modify some docstrings.
llvm-svn: 129706
2011-04-18 18:32:09 +00:00
Jim Ingham 78a685aa2d Add support for "dynamic values" for C++ classes. This currently only works for "frame var" and for the
expressions that are simple enough to get passed to the "frame var" underpinnings.  The parser code will
have to be changed to also query for the dynamic types & offsets as it is looking up variables.

The behavior of "frame var" is controlled in two ways.  You can pass "-d {true/false} to the frame var
command to get the dynamic or static value of the variables you are printing.

There's also a general setting:

target.prefer-dynamic-value (boolean) = 'true'

which is consulted if you call "frame var" without supplying a value for the -d option.

llvm-svn: 129623
2011-04-16 00:01:13 +00:00
Johnny Chen 90bb905137 Minor import statement change.
llvm-svn: 128558
2011-03-30 17:54:35 +00:00
Johnny Chen ac77f3b2ac Turns out that the test failure wrt:
rdar://problem/9173060 lldb hangs while running unique-types

disappears if running with clang version >= 3.  Modify the TestUniqueTypes.py
to detect if we are running with clang version < 3 and, if true, skip the test.

Update the lldbtest.system() function to return a tuple of (stdoutdata, stderrdata)
since we need the stderr data from "clang -v" command.  Modify existing clients of
lldbtest.system() to now use, for example:

         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of (variable, value) pairs extracted
         # from the golden output.
         gl = []

And add two utility functions to lldbutil.py.

llvm-svn: 128162
2011-03-23 20:28:59 +00:00
Johnny Chen a460316d81 Add test cases for Python SBThread.StepOut() API by stepping out of a malloc call where the call site is at function b().
Verifies that after the thread.StepOut(), we are at the correct line within function b.

llvm-svn: 127374
2011-03-09 23:45:56 +00:00
Johnny Chen 930e3ad51e Add a test case ProcessAPITestCase.test_remote_launch() which tests SBProcess.RemoteLaunch()
API with a process not in eStateConnected, and checks that the remote launch failed.

Modify SBProcess::RemoteLaunch()/RemoteAttachToProcessWithID()'s log statements to fix a
crasher when logging is turned on.

llvm-svn: 127055
2011-03-05 01:20:11 +00:00
Johnny Chen ed4019802d Add TestDisasmAPI.py which exercises the newly added SBFunction/SBSymbol.GetStartAddress(),
among other things:

// When stopped on breakppint 1, we can get the line entry using SBFrame API
// SBFrame.GetLineEntry().  We'll get the start address for the the line entry
// with the SBAddress type, resolve the symbol context using the SBTarget API
// SBTarget.ResolveSymbolContextForAddress() in order to get the SBSymbol.
//
// We then stop at breakpoint 2, get the SBFrame, and the the SBFunction object.
//
// The address from calling GetStartAddress() on the symbol and the function
// should point to the same address, and we also verify that.

And add one utility function disassemble(target, function_or_symbol) to lldbutil.py:

    """Disassemble the function or symbol given a target.

    It returns the disassembly content in a string object.
    """

TestDisasm.py uses the disassemble() function to do disassembly on the SBSymbol, and
then the SBFunction object.

llvm-svn: 126955
2011-03-03 19:14:00 +00:00
Johnny Chen d61816b5b8 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
2011-03-03 01:41:57 +00:00
Johnny Chen 43e587c1f6 Clarified the docstrings for int_to_bytearray() and bytearray_to_int().
llvm-svn: 126877
2011-03-02 20:54:22 +00:00
Johnny Chen 43766d6f12 Add two utility functions to lldbutil.py:
o int_to_bytearray()
o bytearray_to_int()

They return/interpret the bytearray in the little endian format.
For big endian, simply perform ba.reverse() on the bytearray object.

And modify TestProcessAPI.py to take advantage of the functions.

llvm-svn: 126813
2011-03-02 01:36:45 +00:00
Johnny Chen b340e6bb15 Add more docstring for the lldb_iter() utility function which provides a compact
way of iterating through an aggregate data structure.  The added example usage
is from an actual use in test/foundation/TestSymbolTable.py:

    2. Pass a container of aggregate which provides APIs to get to the size and
       the element of the aggregate:

    # Module is a container of symbol table 
    module = target.FindModule(filespec)
    for symbol in lldb_iter(module, 'GetNumSymbols', 'GetSymbolAtIndex'):
        name = symbol.GetName()
        ...

llvm-svn: 121271
2010-12-08 19:19:08 +00:00
Johnny Chen 87bb589c4d Add a test for Python API SBValue.GetValueType() inside TestArrayTypes.py for a
local variable and an argument variable.

Add ValueTypeString() utility function into lldbutil.py which converts the enum
into a human readable string.

Modify TestBase.DebugSBValue() to also dump the value type of an SBValue object.

llvm-svn: 118197
2010-11-03 21:37:58 +00:00
Johnny Chen 567a045fe3 Only prints out the stop reason if it is not invalid.
llvm-svn: 117287
2010-10-25 19:13:52 +00:00
Johnny Chen 4badfb8a1f Also prints out the stop reason string for lldbutil.PrintStackTrace(thread).
llvm-svn: 117281
2010-10-25 18:43:29 +00:00
Johnny Chen f4f70bb890 Comment heading changes.
llvm-svn: 117152
2010-10-22 21:31:03 +00:00
Johnny Chen 8b6b189422 Also change the utility functions in lldbutil.py, too, to correspond to the StateType representation change.
llvm-svn: 116706
2010-10-18 15:46:54 +00:00
Johnny Chen d5d6facc64 Don't wrap StringIO inside a with statement. It is not a context manager.
llvm-svn: 116643
2010-10-15 23:33:18 +00:00
Johnny Chen 2f66619004 Make sure to close the string buffer when finished.
llvm-svn: 116621
2010-10-15 21:18:07 +00:00
Johnny Chen 150c3cc825 This is an initial version of test driver enhanceent to be able to dump the
session info after a test case failure, allowing more direct inspection of
debugger session which leads to the test failure.

For a simple usage scenario:

[18:06:26] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log 

...

[18:14:43] johnny:/Volumes/data/lldb/svn/trunk/test $ ls -l .session-*
-rw-r--r--  1 johnny  admin  1359 Oct 14 18:06 .session-TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command
-rw-r--r--  1 johnny  admin  2054 Oct 14 18:07 .session-TestClassTypes.ClassTypesTestCase.test_with_dsym_and_expr_parser
-rw-r--r--  1 johnny  admin  2055 Oct 14 18:07 .session-TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_expr_parser
-rw-r--r--  1 johnny  admin  1351 Oct 14 17:57 .session-TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_run_command
[18:14:51] johnny:/Volumes/data/lldb/svn/trunk/test $ 

The test case which failed will have its recorded session info dumped to a
.session-* file in the current working directory.  For test suite using
relocated directory, expect to find the .session-* files there.

In this checkin, I also add @skip decorator to the two test methods in
test/foundation/TestObjCMethods.py as it looks like the test suite is
deadlocking when running the tests.  More investigations are needed.

llvm-svn: 116552
2010-10-15 01:18:29 +00:00
Johnny Chen 493b526bf7 Simplify the generator adaptor to a Python function instead of a class definition,
with the function name 'lldb_iter'.  Example:

def disassemble_instructions (insts):
    from lldbutil import lldb_iter
    for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'):
        print i

llvm-svn: 116171
2010-10-10 20:25:10 +00:00
Johnny Chen f4de10d290 Add a generator adaptor class named 'Iterator' which turns lldb aggregate data
structures into an iterable Python object.

Example:

    def disassemble_instructions (insts):
        from lldbutil import Iterator
        for i in Iterator(insts, 'GetSize', 'GetInstructionAtIndex'):
            print i

llvm-svn: 116137
2010-10-09 01:31:09 +00:00
Johnny Chen 28ae29420a Move the enum to string utility functions from lldbtest.py to lldbuti.py and
update the affected API clients.

llvm-svn: 115995
2010-10-07 22:15:58 +00:00
Johnny Chen 7ea9aee9be Add a test case which uses the SBProcess and SBThread APIs to iterate through
the threads and print their stack traces when stopped on a breakpoint.

Add a PrintStackTraces(process) utility function into the lldbutil.py module.

llvm-svn: 115983
2010-10-07 21:38:28 +00:00
Johnny Chen 6c70499030 Add a keyword argument string_buffer (with a default value of False) to the
PrintStackTrace(thread) function.  If string_buffer is True, PrintStackTrace()
will return the content of the stack trace as a string, instead.

llvm-svn: 115960
2010-10-07 18:52:48 +00:00
Johnny Chen 43a651c609 Added GetStackFrames(thread) utility function.
llvm-svn: 113460
2010-09-09 00:55:07 +00:00