Commit Graph

752 Commits

Author SHA1 Message Date
Enrico Granata c53114e30a new flag -P to type synth add lets you type a Python class interactively
added a final newline to fooSynthProvider.py
new option to automatically save user input in InputReaderEZ
checking for NULL pointers in several new places

llvm-svn: 135916
2011-07-25 16:59:05 +00:00
Enrico Granata a37a065c33 Python synthetic children:
- you can now define a Python class as a synthetic children producer for a type
   the class must adhere to this "interface":
        def __init__(self, valobj, dict):
     	def get_child_at_index(self, index):
     	def get_child_index(self, name):
   then using type synth add -l className typeName
   (e.g. type synth add -l fooSynthProvider foo)
   (This is still WIP with lots to be added)
   A small test case is available also as reference

llvm-svn: 135865
2011-07-24 00:14:56 +00:00
Peter Collingbourne 9a8d848caf Add support for platforms without sa_len to SocketAddress, and modify
some code to use it

llvm-svn: 135790
2011-07-22 19:12:42 +00:00
Enrico Granata e992a0899e some editing of data visualization error messages to make them more meaningful
debugging printfs() for data visualization turned into a meaningful log:
 - introduced a new log category `types' in channel `lldb'

llvm-svn: 135773
2011-07-22 17:03:19 +00:00
Greg Clayton 00e6fbfee9 Make the SBAddress class easier to use when using the public
API. 

SBTarget changes include changing:

bool
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr, 
                              lldb::SBAddress& addr);

to be:

lldb::SBAddress
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr);

SBAddress can how contruct itself using a load address and a target 
which can be used to resolve the address:

SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);

This will actually just call the new SetLoadAddress accessor:

void
SetLoadAddress (lldb::addr_t load_addr, 
                lldb::SBTarget &target);

This function will always succeed in making a SBAddress object
that can be used in API calls (even if "target" isn't valid).
If "target" is valid and there are sections currently loaded,
then it will resolve the address to a section offset address if
it can. Else an address with a NULL section and an offset that is
the "load_addr" that was passed in. We do this because a load address
might be from the heap or stack.

llvm-svn: 135770
2011-07-22 16:46:35 +00:00
Enrico Granata d55546b27a when typing a summary string you can use the %S symbol to explicitly indicate that you want the summary to be used to print the target object
(e.g. ${var%S}). this might already be the default if your variable is of an aggregate type
new feature: synthetic filters. you can restrict the number of children for your variables to only a meaningful subset
 - the restricted list of children obeys the typical rules (e.g. summaries prevail over children)
 - one-line summaries show only the filtered (synthetic) children, if you type an expanded summary string, or you use Python scripts, all the real children are accessible
 - to provide a synthetic children list use the "type synth add" command, as in:
   type synth add foo_type --child varA --child varB[0] --child varC->packet->flags[1-4]
   (you can use ., ->, single-item array operator [N] and bitfield operator [N-M]; array slice access is not supported, giving simplified names to expression paths is not supported)
 - a new -S option to frame variable and target variable lets you override synthetic children and instead show real ones

llvm-svn: 135731
2011-07-22 00:16:08 +00:00
Enrico Granata 2dee16e883 type category list now supports a regular expression argument that filters categories to only include the ones matching the regex
type summary list now supports a -w flag with a regular expression argument that filters categories to only include the ones matching the regex
in category and summary listings, categories are printed in a meaningful order:
 - enabled ones first, in the order in which they are searched for summaries
 - disabled ones, in an unspecified order
type summary list by default only expands non-empty enabled categories. to obtain a full listing, you must use the -w flag giving a "match-all" regex

llvm-svn: 135529
2011-07-19 22:35:10 +00:00
Enrico Granata 9df29e32c9 Applied Matt Johnson patch to ValueObject and FormatManager
llvm-svn: 135523
2011-07-19 20:57:44 +00:00
Greg Clayton 9189b20875 Added some more functionality to SocketAddress and modified
ConnectionFileDescriptor to use it.

llvm-svn: 135511
2011-07-19 20:03:42 +00:00
Johnny Chen 4480530a0f Patch by Matt Johnson to silence G++ warnings!
Used hand merge to apply the diffs.  I did not apply the diffs for FormatManager.h and
the diffs for memberwise initialization for ValueObject.cpp because they changed since.
I will ask my colleague to apply them later.

llvm-svn: 135508
2011-07-19 19:48:13 +00:00
Enrico Granata 20edcdbe8a The implementation of categories is now synchronization safe
Code cleanup:
 - The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
   actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
   FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
   are contained. The wrapper code always remains in Debugger.{h|cpp}
 - Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
 - for type category enable, saying "enable A B C" is the same as saying
    enable C
    enable B
    enable A
   (the ordering is relevant in enabling categories, and it is expected that a user typing
    enable A B C wants to look into category A, then into B, then into C and not the other
    way round)
 - for the other two commands, the order is not really relevant (however, the same inverted ordering
   is used for consistency)

llvm-svn: 135494
2011-07-19 18:03:25 +00:00
Greg Clayton ad440da346 Abstract "struct sockaddr", "struct sockaddr_in", "struct sockaddr_in6" and
"struct sockaddr_storage" into a new host class called SocketAddress. This
will allow us to control the host specific implementations (such as how to
get the length) into a single Host specific class.

llvm-svn: 135488
2011-07-19 16:44:54 +00:00
Enrico Granata 1490c6fd8f Fixed a bug where deleting a regex summary would not immediately reflect in the variables display
The "systemwide summaries" feature has been removed and replaced with a more general and
powerful mechanism.
Categories:
 - summaries can now be grouped into buckets, called "categories" (it is expected that categories
   correspond to libraries and/or runtime environments)
 - to add a summary to a category, you can use the -w option to type summary add and give
   a category name (e.g. type summary add -f "foo" foo_t -w foo_category)
 - categories are by default disabled, which means LLDB will not look into them for summaries,
   to enable a category use "type category enable". once a category is enabled, LLDB will
   look into that category for summaries. the rules are quite trivial: every enabled category
   is searched for an exact match. if an exact match is nowhere to be found, any match is
   searched for in every enabled category (whether it involves cascading, going to base classes,
   ...). categories are searched into the order in which they were enabled (the most recently
   enabled category first, then the second most and so on..)
 - by default, most commands that deal with summaries, use a category named "default" if no
   explicit -w parameter is given (the observable behavior of LLDB should not change when
   categories are not explicitly used)
 - the systemwide summaries are now part of a "system" category

llvm-svn: 135463
2011-07-19 02:34:21 +00:00
Johnny Chen 349f076330 Add SWIG interface files for SBSymbol, SBSymbolContext, and SBSymbolContextList.
llvm-svn: 135459
2011-07-19 01:07:06 +00:00
Johnny Chen f74cb50cda Add SWIG Python interface files for SBLineEntry, SBListener, and SBModule.
llvm-svn: 135441
2011-07-18 23:11:07 +00:00
Johnny Chen d84a9a1249 Missed the interface file for SBFunction in the previous checkin.
llvm-svn: 135436
2011-07-18 22:15:37 +00:00
Johnny Chen 0eca544b45 Add SWIG Python interface files for SBDebugger, SBCompileUnit, and SBEvent.
llvm-svn: 135432
2011-07-18 22:11:53 +00:00
Johnny Chen 5de6a790f2 Add SWIG Python interface files for SBAddress, SBBlock, SBBreakpoint, and SBBreakpointLocation.
llvm-svn: 135430
2011-07-18 21:30:21 +00:00
Johnny Chen 357033b337 Add SWIG Python interface files for SBProcess, SBThread, and SBFrame.
llvm-svn: 135419
2011-07-18 20:13:38 +00:00
Johnny Chen 67ae7bdb54 Add two new interface files SBValue.i and SBValueList.i, instead of directly swigging the header files.
llvm-svn: 135416
2011-07-18 19:08:30 +00:00
Greg Clayton 3a29bdbe9b Added a boolean to the pure virtual lldb_private::Process::CanDebug(...)
method so process plug-ins that are requested by name can answer yes when
asked if they can debug a target that might not have any file in the target.

Modified the ConnectionFileDescriptor to have both a read and a write file
descriptor. This allows us to support UDP, and eventually will allow us to
support pipes. The ConnectionFileDescriptor class also has a file descriptor
type for each of the read and write file decriptors so we can use the correct
read/recv/recvfrom call when reading, or write/send/sendto for writing.

Finished up an initial implementation of UDP where you can use the "udp://"
URL to specify a host and port to connect to:

(lldb) process connect --plugin kdp-remote udp://host:41139

This will cause a ConnectionFileDescriptor to be created that can send UDP
packets to "host:41139", and it will also bind to a localhost port that can
be given out to receive the connectionless UDP reply. 

Added the ability to get to the IPv4/IPv6 socket port number from a 
ConnectionFileDescriptor instance if either file descriptor is a socket.

The ProcessKDP can now successfully connect to a remote kernel and detach
using the above "processs connect" command!!! So far we have the following
packets working:
    KDP_CONNECT
    KDP_DISCONNECT
    KDP_HOSTINFO
    KDP_VERSION
    KDP_REATTACH

Now that the packets are working, adding new packets will go very quickly.

llvm-svn: 135363
2011-07-17 20:36:25 +00:00
Johnny Chen dc7d3c121b Create an interface file for SBTarget named SBTarget.i which relieves SBTarget.h
of the duty of having SWIG docstring features and multiline string literals
embedded within.

lldb.swig now %include .../SBTarget.i, instead of .../SBTarget.h.  Will create
other interface files and transition them over.

Also update modify-python-lldb.py to better handle the trailing blank line right
before the ending '"""' Python docstring delimiter.

llvm-svn: 135355
2011-07-16 21:15:39 +00:00
Peter Collingbourne bac7150db0 Add missing #include, fixes Linux build
llvm-svn: 135346
2011-07-16 15:58:57 +00:00
Greg Clayton 4df8ddfc97 Completed more work on the KDP darwin kernel debugging Process plug-in.
Implemented connect, disconnect, reattach, version, and hostinfo.

Modified the ConnectionFileDescriptor class to be able to handle UDP. 

Added a new Stream subclass called StreamBuffer that is backed by a
llvm::SmallVector for better efficiency.

Modified the DataExtractor class to have a static function that can
dump hex bytes into a stream. This is currently being used to dump incoming
binary packet data in the KDP plug-in.

llvm-svn: 135338
2011-07-16 03:19:08 +00:00
Enrico Granata 0c5ef693a2 Some descriptive text for the Python script feature:
- help type summary add now gives some hints on how to use it
frame variable and target variable now have a --no-summary-depth (-Y) option:
 - simply using -Y without an argument will skip one level of summaries, i.e.
   your aggregate types will expand their children and display no summary, even
   if they have one. children will behave normally
 - using -Y<int>, as in -Y4, -Y7, ..., will skip as many levels of summaries as
   given by the <int> parameter (obviously, -Y and -Y1 are the same thing). children
   beneath the given depth level will behave normally
 -Y0 is the same as omitting the --no-summary-depth parameter entirely
 This option replaces the defined-but-unimplemented --no-summary

llvm-svn: 135336
2011-07-16 01:22:04 +00:00
Sean Callanan c4ffe37cf1 Added support for dynamic detection of AVX, and
fixed a few bugs that revealed.  Now the "register
read" command should show AVX registers
(ymm0-ymm15) on Mac OS X platforms that support
them.

When testing this on Mac OS X, run debugserver
manually, like this:

debugserver --native-regs localhost:1111 /path/to/executable

Then

lldb /path/to/executable
...
(lldb) process connect connect://localhost:1111

llvm-svn: 135331
2011-07-16 00:49:19 +00:00
Enrico Granata 9dd75c8886 System-wide summaries:
- Summaries for char*, const char* and char[] are loaded at startup as
   system-wide summaries. This means you cannot delete them unless you use
   the -a option to type summary delete/clear
 - You can add your own system-wide summaries by using the -w option to type
   summary add
Several code improvements for the Python summaries feature

llvm-svn: 135326
2011-07-15 23:30:15 +00:00
Peter Collingbourne 6b917bb9b5 Fix gcc build error
llvm-svn: 135325
2011-07-15 23:22:49 +00:00
Johnny Chen 135f63fb30 Add some more docstrings for SBCompileUnit and SBBreakpoint, plus incorporate the doxgen doc block of
SBValue::GetChildAtIndex(uint32_t idx, 
                         lldb::DynamicValueType use_dynamic,
                         bool can_create_synthetic);

into the SBValue docstrings.

llvm-svn: 135295
2011-07-15 20:46:19 +00:00
Greg Clayton f660248238 Added the ability to get synthetic child values from SBValue objects that
represent pointers and arrays by adding an extra parameter to the 

SBValue
SBValue::GetChildAtIndex (uint32_t idx, 
                         DynamicValueType use_dynamic, 
                         bool can_create_synthetic);

The new "can_create_synthetic" will allow you to create child values that
aren't actually a part of the original type. So if you code like:

int *foo_ptr = ...

And you have a SBValue that contains the value for "foo_ptr":

SBValue foo_value = ...

You can now get the "foo_ptr[12]" item by doing this:

v = foo_value.GetChiltAtIndex (12, lldb.eNoDynamicValues, True);

Normall the "foo_value" would only have one child value (an integer), but
we can create "synthetic" child values by treating the pointer as an array.

Likewise if you have code like:

int array[2];

array_value = ....

v = array_value.GetChiltAtIndex (0);     // Success, v will be valid
v = array_value.GetChiltAtIndex (1);     // Success, v will be valid
v = array_value.GetChiltAtIndex (2);     // Fail, v won't be valid, "2" is not a valid zero based index in "array"

But if you use the ability to create synthetic children:

v = array_value.GetChiltAtIndex (0, lldb.eNoDynamicValues, True);     // Success, v will be valid
v = array_value.GetChiltAtIndex (1, lldb.eNoDynamicValues, True);     // Success, v will be valid
v = array_value.GetChiltAtIndex (2, lldb.eNoDynamicValues, True);     // Success, v will be valid

llvm-svn: 135292
2011-07-15 19:31:49 +00:00
Greg Clayton 57508026c2 Added the ability to connect using "tcp://<host>:<port>" which is the
same as the old "connect://<host>:<port>". Also added the ability to
connect using "udp://<host>:<port>" which will open a connected 
datagram socket. I need to find a way to specify a non connected
datagram socket as well. 

We might need to start setting some settings in the URL itself, 
maybe something like:

udp://<host>:<port>?connected=yes
udp://<host>:<port>?connected=no

I am open to suggestions for URL settings.

Also did more work on the KDP darwin kernel plug-in.

 

llvm-svn: 135277
2011-07-15 16:31:38 +00:00
Enrico Granata f2bbf717f7 Python summary strings:
- you can use a Python script to write a summary string for data-types, in one of
   three ways:
    -P option and typing the script a line at a time
    -s option and passing a one-line Python script
    -F option and passing the name of a Python function
   these options all work for the "type summary add" command
   your Python code (if provided through -P or -s) is wrapped in a function
   that accepts two parameters: valobj (a ValueObject) and dict (an LLDB
   internal dictionary object). if you use -F and give a function name,
   you're expected to define the function on your own and with the right
   prototype. your function, however defined, must return a Python string
 - test case for the Python summary feature
 - a few quirks:
  Python summaries cannot have names, and cannot use regex as type names
  both issues will be fixed ASAP
major redesign of type summary code:
 - type summary working with strings and type summary working with Python code
   are two classes, with a common base class SummaryFormat
 - SummaryFormat classes now are able to actively format objects rather than
   just aggregating data
 - cleaner code to print descriptions for summaries
the public API now exports a method to easily navigate a ValueObject hierarchy
New InputReaderEZ and PriorityPointerPair classes
Several minor fixes and improvements

llvm-svn: 135238
2011-07-15 02:26:42 +00:00
Johnny Chen 3d3a7cf563 Add usage docstring to SBValue.h, and minor update of docstrings for SBValueList.h.
llvm-svn: 135230
2011-07-15 00:27:47 +00:00
Johnny Chen e625325d9f Add usage docstrings to SBTarget, SBProcess, and SBThread.
llvm-svn: 135221
2011-07-14 23:56:51 +00:00
Johnny Chen e787813e16 Fix typo in ConnectRemote() docstring.
llvm-svn: 135188
2011-07-14 21:17:28 +00:00
Johnny Chen fa181f4fdb Add some more docstrings (includng example usages) to SBTarget.h.
Add logic to modify-python-lldb to correct swig's transformation of 'char **argv' and 'char **envp'
to 'char argv' and 'char envp' by morphing them into the 'list argv' and 'list envp' (as a list of
Python strings).

llvm-svn: 135114
2011-07-14 00:17:49 +00:00
Johnny Chen 3fe166dfd3 Add some more docstrings for SBTarget.
llvm-svn: 135108
2011-07-13 23:35:33 +00:00
Johnny Chen 97ef3fc5bf Use %feature("docstring") for methods of SBModule class so that the methods signature also gets generated in the Python docstring.
llvm-svn: 135105
2011-07-13 23:17:13 +00:00
Johnny Chen 4c9c3ee08a Update docstrings for SBModeule/SBTarget::FindGlobalVariables().
llvm-svn: 135019
2011-07-13 00:46:49 +00:00
Enrico Granata 79dce0a66e fixing missing RefCounter class
llvm-svn: 135012
2011-07-13 00:00:57 +00:00
Enrico Granata f4efecd958 smarter summary strings:
- formats %s %char[] %c and %a now work to print 0-terminated c-strings if they are applied to a char* or char[] even without the [] operator (e.g. ${var%s})
 - array formats (char[], intN[], ..) now work when applied to an array of a scalar type even without the [] operator (e.g. ${var%int32_t[]})
LLDB will not crash because of endless loop when trying to obtain a summary for an object that has no value and references itself in its summary string
In many cases, a wrong summary string will now display an "<error>" message instead of giving out an empty string

llvm-svn: 135007
2011-07-12 22:56:10 +00:00
Greg Clayton d16e1e596a Added the ability to _not_ skip the prologue when settings breakpoints
by name by adding an extra parameter to the lldb_private::Target breakpoint 
setting functions.

Added a function in the DWARF symbol file plug-in that can dump errors
and prints out which DWARF file the error is happening in so we can track
down what used to be assertions easily.

Fixed the MacOSX kernel plug-in to properly read the kext images and set
the kext breakpoint to watch for kexts as they are loaded.

llvm-svn: 134990
2011-07-12 17:06:17 +00:00
Jim Ingham a5a97ebe3c Added "command history" command to dump the command history.
Also made:
(lldb) !<NUM>
(lldb) !-<NUM>
(lldb) !!

work with the history.  For added benefit:

(lldb) !<NUM><TAB>

will insert the command at position <NUM> in the history into the command line to be edited.

This is only partial, I still need to sync up editline's history list with the one kept by the interpreter.

llvm-svn: 134955
2011-07-12 03:12:18 +00:00
Enrico Granata f9fa6ee5e3 named summaries:
- a new --name option for "type summary add" lets you give a name to a summary
 - a new --summary option for "frame variable" lets you bind a named summary to one or more variables
${var%s} now works for printing the value of 0-terminated CStrings
type format test case now tests for cascading
 - this is disabled on GCC because GCC may end up stripping typedef chains, basically breaking cascading
new design for the FormatNavigator class
new template class CleanUp2 meant to support cleanup routines with 1 additional parameter beyond resource handle

llvm-svn: 134943
2011-07-12 00:18:11 +00:00
Johnny Chen 928f4ee26f Add missing docstring for 'bool stop_at_endtry'.
llvm-svn: 134924
2011-07-11 21:41:05 +00:00
Greg Clayton c749eb89ad Added the ability to see block variables when looking up addresses
with the "target modules lookup --address <addr>" command. The variable
ID's, names, types, location for the address, and declaration is
displayed.

This can really help with crash logs since we get, on MacOSX at least,
the registers for the thread that crashed so it is often possible to
figure out some of the variable contents. 

llvm-svn: 134886
2011-07-11 05:12:02 +00:00
Greg Clayton 45ba854399 Allow the built in ValueObject summary providers for C strings
use lldb_private::Target::ReadMemory(...) to allow constant strings
to be displayed in global variables prior on in between process
execution.

Centralized the variable declaration dumping into:

	bool
	Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module);

Fixed an issue if you used "target variable --regex <regex>" where the
variable name would not be displayed, but the regular expression would.

Fixed an issue when viewing global variables through "target variable"
might not display correctly when doing DWARF in object files.

llvm-svn: 134878
2011-07-10 19:21:23 +00:00
Greg Clayton daf515fc8a Fixed the global and static variables to always be in scope.
Made it so that you can create synthetic children of array
value objects. This is for creating array members when the
array index is out of range. This comes in handy when you have
a structure definition like:

struct Collection
{
    uint32_t count;
    Item array[0];
};
"array" has 1 item, but many times in practice there are more
items in "item_array".

This allows you to do:

(lldb) target variable g_collection.array[3]

To implement this, the get child at index has been modified
to have a "ignore_array_bounds" boolean that can be set to true.

llvm-svn: 134846
2011-07-09 20:12:33 +00:00
Greg Clayton ebf121b188 Fixed some const issues with args to some lldb_private::Target functions.
llvm-svn: 134826
2011-07-09 17:16:43 +00:00
Greg Clayton 9e00b6a654 Added the ability to get an abstract file type (executable, object file,
shared library, etc) and strata (user/kernel) from an object file. This will
help with plug-in and platform selection when given a new binary with the
"target create <file>" command.

llvm-svn: 134779
2011-07-09 00:41:34 +00:00