Commit Graph

111 Commits

Author SHA1 Message Date
Johnny Chen c54de2ca54 Missed this file when doing r142543 to temporarily relax the expected substrings for watchpoint creation output.
llvm-svn: 142549
2011-10-19 22:17:06 +00:00
Johnny Chen d72b178a45 Temporarily relax the expected substrings for watchpoint creation output
due a bug in the decl file info of a global variable emitted by clang.

llvm-svn: 142543
2011-10-19 20:51:28 +00:00
Johnny Chen 9df05592f0 Add test cases for setting condition on a watchpoint for both command and API.
llvm-svn: 142291
2011-10-17 22:17:47 +00:00
Enrico Granata a9dbf4325e this patch introduces a new command script import command which takes as input a filename for a Python script and imports the module contained in that file. the containing directory is added to the Python path such that dependencies are honored. also, the module may contain an __lldb_init_module(debugger,dict) function, which gets called after importing, and which can somehow initialize the module's interaction with lldb
llvm-svn: 142283
2011-10-17 21:45:27 +00:00
Johnny Chen 9c7b04cb26 Rename test file.
llvm-svn: 142242
2011-10-17 20:28:39 +00:00
Johnny Chen 8289e36506 Fix wrong docstring.
llvm-svn: 142241
2011-10-17 20:26:07 +00:00
Johnny Chen 16dcf718d3 Add a commnad to set a condition for a watchpoint. Example:
watchpoint modify -c 'global==5'

modifies the last created watchpoint so that the condition expression
is evaluated at the stop point to decide whether we should proceed with
the stopping.

Also add SBWatchpont::SetCondition(const char *condition) to set condition
programmatically.

Test cases to come later.

llvm-svn: 142227
2011-10-17 18:58:00 +00:00
Johnny Chen fc807f84ed Rename directory command_python to command_script, and the test file, too.
llvm-svn: 141963
2011-10-14 17:37:38 +00:00
Johnny Chen 04a101d475 Add cleanups for 'command script add' to TestCommandPython.py.
llvm-svn: 141790
2011-10-12 17:50:41 +00:00
Johnny Chen ebe51726b8 If we spawn an lldb process for test (via pexpect), do not load the init file unless told otherwise.
Set up self.lldbOption to be "--no-lldbibit" unless env variable NO_LLDBIBIT is defined and equals "NO".
Also add "-nx" to gdb spawned.

llvm-svn: 141384
2011-10-07 19:21:09 +00:00
Johnny Chen 4f09a0f855 Add a test sequence for 'target variable' command when no arguments are given.
llvm-svn: 141264
2011-10-06 01:00:53 +00:00
Johnny Chen 6cc60e8668 Add capability to set ignore count for watchpoint on the command line:
watchpoint ignore -i <count> [<watchpt-id | watchpt-id-list>]

Add tests of watchpoint ignore_count for command line as well as API.

llvm-svn: 141217
2011-10-05 21:35:46 +00:00
Johnny Chen 80fdd7c0b7 Fix a problem where the stop-hook command 'frame variable g_val' produces nothing
when newly created threads were subsequently stopped due to breakpoint hit.
The stop-hook mechanism delegates to CommandInterpreter::HandleCommands() to
execuet the commands.  Make sure the execution context is switched only once
at the beginning of HandleCommands() only and don't update the context while looping
on each individual command to be executed.

rdar://problem/10228156

llvm-svn: 141144
2011-10-05 00:42:59 +00:00
Johnny Chen 86268e4459 o lldbtest.py:
Add a keyword argument 'endstr' to TestBase.expect() method to assert that the output
will end with 'endstr'.

Add TestBase.switch_to_thread_with_stop_reason(stop_reason) to select the thread with
the stop reason = 'stop_reason' as the current thread.

o TestWatchLocation.py:

Modified to switch to the stopped thread with stop reason = watchpoint and to evaluate
an expression with expected output for stronger assertion.

llvm-svn: 140890
2011-09-30 21:48:35 +00:00
Johnny Chen b62a3be1a2 Add an accompanying option to the 'frame variable -w' command to, instead of watching the variable,
watch the location pointed to by the variable.  An example,

(lldb) frame variable -w write -x 1 -g g_char_ptr
(char *) g_char_ptr = 0x0000000100100860 ""...
Watchpoint created: WatchpointLocation 1: addr = 0x100100860 size = 1 state = enabled type = w
    declare @ '/Volumes/data/lldb/svn/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp:21'

...

(lldb) c
Process 3936 resuming

...

rocess 3936 stopped
* thread #2: tid = 0x3403, 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27, stop reason = watchpoint 1
    frame #0: 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27
   24  	do_bad_thing_with_location(char *char_ptr, char new_val)
   25  	{
   26  	    *char_ptr = new_val;
-> 27  	}
   28  	
   29  	uint32_t access_pool (uint32_t flag = 0);
   30  	
(lldb) 

Also add TestWatchLocation.py test to exercise this functionality.

llvm-svn: 140836
2011-09-30 01:08:48 +00:00
Johnny Chen a9b68f4dd6 Modify the delegation chain from MachThreadList -> MachThread -> DNBArchProtocol so that when
the watchpoint state is changed, not only does the change propagate to all the thread instances,
it also updates a global debug state, if chosen by the DNBArchProtocol derivative.

Once implemented, the DNBArchProtocol derivative, also makes sure that when new thread comes along,
it tries to inherit from the global debug state, if it is valid.

Modify TestWatchpointMultipleThreads.py to test this functionality.

llvm-svn: 140811
2011-09-29 21:48:52 +00:00
Johnny Chen 825ea37835 Fix a bug in the current MacOSX MachThreadList::EnableHardwareWatchpoint() impl so that
it enables the hardware watchpoint for all existing threads.  Add a test file for that.
Also fix MachThreadList::DisableHardwareWatchpoint().

llvm-svn: 140757
2011-09-29 01:20:42 +00:00
Johnny Chen 12e27887cb Add a simple regression test for 'target stop-hook list' with no target specified.
It should not crash lldb.

llvm-svn: 140421
2011-09-23 21:34:40 +00:00
Jim Ingham 76bb759605 Added a test for problems caused when Clang errantly makes the line range for one line
too long, so that the jump from the line above the bad line to the line after
ends up in the middle of the bad line instead.  Added a workaround to lldb to just
continue to the end if we find ourselves stopped in the middle of some other line.

llvm-svn: 140419
2011-09-23 21:24:57 +00:00
Johnny Chen 947961c151 Add test cases for watchpoint list, enable, disable, and delete commands.
llvm-svn: 140398
2011-09-23 18:42:28 +00:00
Johnny Chen 3aa2889cc7 A second try to make the TestStopHookMechanism.py more robust after recent changes.
llvm-svn: 140396
2011-09-23 18:25:02 +00:00
Johnny Chen 825815fbaf The "Stop Hooks" anchors have been removed from the stop-hook output.
Update the test case to fix test suite failure.

llvm-svn: 140392
2011-09-23 17:53:13 +00:00
Jim Ingham 87df91b866 Added the ability to restrict breakpoints by function name, function regexp, selector
etc to specific source files.
Added SB API's to specify these source files & also more than one module.
Added an "exact" option to CompileUnit's FindLineEntry API.

llvm-svn: 140362
2011-09-23 00:54:11 +00:00
Johnny Chen f04ee930a0 Add initial implementation of watchpoint commands for list, enable, disable, and delete.
Test cases to be added later.

llvm-svn: 140322
2011-09-22 18:04:58 +00:00
Sean Callanan 0886e5657b Fixed a problem with the IR interpreter that caused
it to generate result variables that were not bound
to their underlying data.  This allowed the SBValue
class to use the interpreter (if possible).

Also made sure that any result variables that point
to stack allocations in the stack frame of the
interpreted expressions do not get live data.

llvm-svn: 140285
2011-09-22 00:41:11 +00:00
Johnny Chen d0b0f4920c Add four new expectedFailre decorators to new failures most likely due to r139772 check-in.
llvm-svn: 140150
2011-09-20 17:31:05 +00:00
Johnny Chen de6bd2432c Add a declaraion info member field to the WatchpointLocation class.
Modify CommandObjectFrame.cpp to populate this field when creating a watchpoint location.
Update the test case to verify that the declaration info matches the file and line number.

llvm-svn: 139946
2011-09-16 21:41:42 +00:00
Johnny Chen f68cc12453 Add a simple watchpoint test to exercise watchpoint creation followed by watchpoint hit events.
llvm-svn: 139847
2011-09-15 21:09:59 +00:00
Enrico Granata 08633eea20 Adding two new options to the 'help' command:
--show-aliases (-a) shows aliases for commands, as well as built-in commands
 --hide-user-defined (-u) hides user defined commands
by default 'help' without arguments does not show aliases anymore. to see them, add --show-aliases
to have only built-in commands appear, use 'help --hide-user-defined' ; there is currently no way to hide
built-in commands from the help output
'help command' is not changed by this commit, and help is shown even if command is an alias and -a is not specified

llvm-svn: 139377
2011-09-09 17:49:36 +00:00
Jim Ingham b7f6b2fa3c Move the SourceManager from the Debugger to the Target. That way it can store the per-Target default Source File & Line.
Set the default Source File & line to main (if it can be found.) at startup.  Selecting the current thread & or frame resets 
the current source file & line, and "source list" as well as the breakpoint command "break set -l <NUM>" will use the 
current source file.

llvm-svn: 139323
2011-09-08 22:13:49 +00:00
Enrico Granata 9128ee2f7a Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
   a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
   in frozen objects ; now such reads transparently move from host to target as required
 - as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
   removed code that enabled to recognize an expression result VO as such
 - introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
   representing a T* or T[], and doing dereferences transparently
   in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
 - as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
   en lieu of doing the raw read itself
 - introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
   this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
   in public layer this returns an SBData, just like GetPointeeData()
 - introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
   the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
   of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
 - added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
 of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
 addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types

llvm-svn: 139160
2011-09-06 19:20:51 +00:00
Johnny Chen d890bfc962 Add a new attribute self.lldbHere, representing the fullpath to the 'lldb' executable
built locally from the source tree.  This is distinguished from self.lldbExec, which
can be used by test/benchmarks to measure the performances against other debuggers.

You can use environment variable LLDB_EXEC to specify self.lldbExec to the dotest.py
test driver, otherwise it is going to be populated with self.lldbHere.

Modify the regular tests under test dir, i.e., not test/benchmarks, to use self.lldbHere.
Also modify the benchmarks tests to use self.lldbHere when it needs an 'lldb' executable
with debug info to do the performance measurements.

llvm-svn: 138608
2011-08-26 00:00:01 +00:00
Johnny Chen 3e15c4d50b Don't display the stdout if not in TraceOn(), i.e, '-t option, mode.
llvm-svn: 138458
2011-08-24 18:19:50 +00:00
Enrico Granata 65a6a6bea4 Moved the test code for Python commands out of the test case for aliases, into its own dedicated test case (one fill was still lurking in the old folder)
llvm-svn: 138446
2011-08-24 17:46:38 +00:00
Enrico Granata cb2921dbd3 Moved the test code for Python commands out of the test case for aliases, into its own dedicated test case
llvm-svn: 138444
2011-08-24 17:45:40 +00:00
Johnny Chen 04adb62569 Uniquefy the various data-formatter test class names so that:
./dotest.py -v -f DataFormatterTestCase.test_with_dsym_and_run_command

will not end up running 14 tests.

llvm-svn: 138399
2011-08-23 22:32:45 +00:00
Enrico Granata 88da35f881 Improved the user-friendliness of errors shown by the summary feature in certain areas
Renamed format "signed decimal" to be "decimal". "unsigned decimal" remains unchanged:
 - the name "signed decimal" was interfering with symbol %S (use summary) in summary strings.
   because of the way summary strings are implemented, this did not really lead to a bug, but
   simply to performing more steps than necessary to display a summary. this is fixed.
Documentation improvements (more on synthetic children, some information on filters). This is still a WIP.

llvm-svn: 138384
2011-08-23 21:26:09 +00:00
Enrico Granata db3485cd06 Short option for --summary-string in 'type summary add' is now -s. This might be a breaking change for those who have summaries defined.
llvm-svn: 138331
2011-08-23 16:13:35 +00:00
Enrico Granata dc9407308e Additional code cleanups ; Short option name for --python-script in type summary add moved from -s to -o (this is a preliminary step in moving the short option for --summary-string from -f to -s) ; Accordingly updated the test suite
llvm-svn: 138315
2011-08-23 00:32:52 +00:00
Enrico Granata def5391ae5 - Support for Python namespaces:
If you have a Python module foo, in order to use its contained objects in LLDB you do not need to use
  'from foo import *'. You can use 'import foo', and then refer to items in foo as 'foo.bar', and LLDB
  will know how to resolve bar as a member of foo.
  Accordingly, GNU libstdc++ formatters have been moved from the global namespace to gnu_libstdcpp and a few
  test cases are also updated to reflect the new convention. Python docs suggest using a plain 'import' en lieu of
  'from-import'.

llvm-svn: 138244
2011-08-22 17:34:47 +00:00
Enrico Granata 58ad33440a Taking care of an issue with using lldb_private types in SBCommandInterpreter.cpp ; Making NSString test case work on Snow Leopard ; Removing an unused variable warning
llvm-svn: 138105
2011-08-19 21:56:10 +00:00
Enrico Granata d64d0bc0ea - Now using ${var} as the summary for an aggregate type will produce "name-of-type @ object-location" instead of giving an error
e.g. you may get "foo_class @ 0x123456" when typing "type summary add -f ${var} foo_class"
- Added a new special formatting token %T for summaries. This shows the type of the object.
  Using it, the new "type @ location" summary could be manually generated by writing ${var%T} @ ${var%L}
- Bits and pieces required to support "frame variable array[n-m]"
  The feature is not enabled yet because some additional design and support code is required, but the basics
  are getting there
- Fixed a potential issue where a ValueObjectSyntheticFilter was not holding on to its SyntheticChildrenSP
  Because of the way VOSF are being built now, this has never been an actual issue, but it is still sensible for
  a VOSF to hold on to the SyntheticChildrenSP as well as to its FrontEnd

llvm-svn: 138080
2011-08-19 21:13:46 +00:00
Enrico Granata da616d06e9 More thorough fix for the spaces-in-typename issue
llvm-svn: 138026
2011-08-19 01:47:11 +00:00
Enrico Granata 02b6676d2b Third round of code cleanups:
- reorganizing the PTS (Partial Template Specializations) in FormatManager.h
 - applied a patch by Filipe Cabecinhas to make LLDB compile with GCC
Functional changes:
 - fixed an issue where command type summary add for type "struct Foo" would not match any types.
   currently, "struct" will be stripped off and type "Foo" will be matched.
   similar behavior occurs for class, enum and union specifiers.

llvm-svn: 138020
2011-08-19 01:14:49 +00:00
Enrico Granata 85933ed40c Second round of code cleanups:
- reorganizing classes layout to have public part first
   Typedefs that we want to keep private, but must be defined for some public code to work correctly are an exception
 - avoiding methods in the form T foo() { code; } all on one-line
 - moving method implementations from .h to .cpp whenever feasible
   Templatized code is an exception and so are very small methods
 - generally, adhering to coding conventions followed project-wide
Functional changes:
 - fixed an issue where using ${var} in a summary for an aggregate, and then displaying a pointer-to-aggregate would lead to no summary being displayed
   The issue was not a major one because all ${var} was meant to do in that context was display an error for invalid use of pointer
   Accordingly fixed test cases and added a new test case

llvm-svn: 137944
2011-08-18 16:38:26 +00:00
Enrico Granata c482a19294 First round of code cleanups:
- all instances of "vobj" have been renamed to "valobj"
 - class Debugger::Formatting has been renamed to DataVisualization (defined in FormatManager.h/cpp)
   The interface to this class has not changed
 - FormatCategory now uses ConstString's as keys to the navigators instead of repeatedly casting
   from ConstString to const char* and back all the time
   Next step is making the same happen for categories themselves
 - category gnu-libstdc++ is defined in the constructor for a FormatManager
   The source code for it is defined in gnu_libstdcpp.py, drawn from examples/synthetic at compile time
   All references to previous 'osxcpp' name have been removed from both code and file names
Functional changes:
 - the name of the option to use a summary string for 'type summary add' has changed from the previous --format-string
   to the new --summary-string. It is expected that the short option will change from -f to -s, and -s for --python-script
   will become -o

llvm-svn: 137886
2011-08-17 22:13:59 +00:00
Enrico Granata 217f91fc57 New category "gnu-libstdc++" provides summary for std::string and synthetic children for types std::map, std::list and std::vector
The category is enabled by default. If you run into issues with it, disable it and the previous behavior of LLDB is restored
 ** This is a temporary solution. The general solution to having formatters pulled in at startup should involve going through the Platform.
Fixed an issue in type synthetic list where a category with synthetic providers in it was not shown if all the providers were regex-based

llvm-svn: 137850
2011-08-17 19:07:52 +00:00
Enrico Granata 99f0b8f935 When defining a scripted command, it is possible to provide a docstring and that will be used as the help text for the command
If no docstring is provided, a default help text is created
LLDB will refuse to create scripted commands if the scripting language is anything but Python
Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code

llvm-svn: 137801
2011-08-17 01:30:04 +00:00
Enrico Granata 223383ed6c Changes to Python commands:
- They now have an SBCommandReturnObject instead of an SBStream as third argument
 - The class CommandObjectPythonFunction has been merged into CommandObjectCommands.cpp
 - The command to manage them is now:
  command script with subcommands add, list, delete, clear
   command alias is returned to its previous functionality
 - Python commands are now part of an user dictionary, instead of being seen as aliases
 

llvm-svn: 137785
2011-08-16 23:24:13 +00:00
Enrico Granata be93a35a8a Python commands:
It is now possible to use 'command alias --python' to define a command name that actually triggers execution of a Python function
 (e.g. command alias --python foo foo_impl makes a command named 'foo' that runs Python function 'foo_impl')
 The Python function foo_impl should have as signature: def foo_impl(debugger, args, stream, dict): where
  debugger is an object wrapping an LLDB SBDebugger
  args is the command line arguments, as an unparsed Python string
  stream is an SBStream that represents the standard output
  dict is an internal utility parameter and should be left untouched
 The function should return None on no error, or an error string to describe any problems

llvm-svn: 137722
2011-08-16 16:49:25 +00:00