Commit Graph

129 Commits

Author SHA1 Message Date
Greg Clayton 6a23d21289 Added a "sources.py" which adds a command that can print out the source files contained in one or more modules.
Added "mach_o.py" which is a mach-o parser that can dump mach-o file contents and also extract sections. It uses the "file_extract" module and the "dict_utils" module.

llvm-svn: 189959
2013-09-04 17:31:40 +00:00
Jason Molenda 3f99ade67a Fix typeo in diagnose-unwind.py.
llvm-svn: 186358
2013-07-15 22:40:17 +00:00
Greg Clayton e110ad8fff Enabled the "--debug" option functionality that will SIGSTOP the current process allowing a debugger to attach.
llvm-svn: 186194
2013-07-12 20:08:00 +00:00
Greg Clayton 04bd684074 Added a memory.py module that contains a 'memfind' command which allows you to search memory for a byte pattern.
llvm-svn: 186127
2013-07-11 22:38:00 +00:00
Enrico Granata da504ff00a Tweaks to the Python reference and example command to use the preferred print style and the (finally available :-) SetError API
llvm-svn: 186122
2013-07-11 21:49:38 +00:00
Jason Molenda c95407b0d5 Add the frame content dumper function call to one more place.
llvm-svn: 185906
2013-07-09 05:36:41 +00:00
Jason Molenda 5bd4a4613c Add new information gathering to the lldb & simple backtrace methods:
print five words of memory at the beginning of the stack frame so it's
easier to track where an incorrect saved-fp or saved-pc may have come from.

llvm-svn: 185903
2013-07-09 05:08:14 +00:00
Greg Clayton 96eb9ab047 A bit more cleanup on the process_events.py to use best practices for event handling.
llvm-svn: 185089
2013-06-27 18:08:32 +00:00
Greg Clayton abc18417b6 Update the platform options help strings.
llvm-svn: 185028
2013-06-26 22:24:05 +00:00
Greg Clayton 111db4f94c Fixed the process_events.py example to be able to specify the platform and also use the debugger's listener.
llvm-svn: 185027
2013-06-26 22:23:45 +00:00
Greg Clayton 57d1c4865e Added a regex that can be specified to avoid showing contents on types that match. Also split things up a bit so this can be run as a stand alone script or in lldb.
llvm-svn: 184628
2013-06-22 01:42:49 +00:00
Jason Molenda e445f8fb4d Also report any OS python plugin in use.
llvm-svn: 184487
2013-06-20 22:05:35 +00:00
Jason Molenda 1332988f5a Print the general purpose registers for frame 0.
llvm-svn: 184483
2013-06-20 21:57:34 +00:00
Greg Clayton 694b49f0f8 Cleanup the output a bit by removing old print statements and also printing the number of types found.
llvm-svn: 184389
2013-06-20 01:23:56 +00:00
Greg Clayton d8c3d4b1e9 Implemented a types.py module that allows types to be inspected for padding.
The script was able to point out and save 40 bytes in each lldb_private::Section by being very careful where we need to have virtual destructors and also by re-ordering members.

llvm-svn: 184364
2013-06-19 21:50:28 +00:00
Jason Molenda 8359214427 A few small enhancements to the diagnose-unwind command.
Change the simple-minded stack walk to not depend on lldb to unwind
the first frame.

Collect a list of Modules and Addresses seen while backtracing (with
both methods), display the image list output for all of those modules,
plus disassemble and image show-unwind any additional frames that
the simple backtrace was able to unwind through instead of just the 
lldb unwind algorithm frames.

Remove checks for older lldb's that didn't support -a for disassemble
or specifying the assembler syntax on x86 targets.

llvm-svn: 184280
2013-06-19 04:52:55 +00:00
Jason Molenda 811d259bb1 Small changes to diagnose_unwind. Correctly provide help text.
Print the lldb version at the top of the output.

llvm-svn: 183289
2013-06-05 02:56:58 +00:00
Enrico Granata a5c0308bde Adding a diagnose-nsstring command
This should help us figure out issues with the NSString data formatter

llvm-svn: 182972
2013-05-30 23:36:47 +00:00
Enrico Granata 083fcdb414 Providing a more interesting command template for LLDB
This one actually exploits the SB API to obtain information about your inferior process

llvm-svn: 181500
2013-05-09 01:32:24 +00:00
Enrico Granata 78f05f13ad Adding some LLDB-specific logic to the tracer (in a separate tracer module) to improve the quality of the output when debugging data formatters
(more improvements are necessary before this is really legible)

llvm-svn: 181367
2013-05-07 21:42:18 +00:00
Enrico Granata c8b36f160c First iteration of a Python tracer module
This module uses Python's sys.settrace() mechanism so setup a hook that can log every significant operation
This is a first step in providing a good debugging experience of Python embedded in LLDB
This module comprises an OO infrastructure that wraps Python's tracing and inspecting mechanisms, plus a very simple logging tracer
Output from this tracer looks like:

call print_keyword_args from <module> @ 243 args are kwargs are {'first_name': 'John', 'last_name': 'Doe'}
running print_keyword_args @ 228 locals are {'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}
running print_keyword_args @ 229 locals are {'key': 'first_name', 'value': 'John', 'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}
first_name = John
running print_keyword_args @ 228 locals are {'key': 'first_name', 'value': 'John', 'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}
running print_keyword_args @ 229 locals are {'key': 'last_name', 'value': 'Doe', 'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}
last_name = Doe
running print_keyword_args @ 228 locals are {'key': 'last_name', 'value': 'Doe', 'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}
return from print_keyword_args value is None locals are {'key': 'last_name', 'value': 'Doe', 'kwargs': {'first_name': 'John', 'last_name': 'Doe'}}

llvm-svn: 181343
2013-05-07 19:49:59 +00:00
Jason Molenda 64dd73e5e1 Print a backtrace line for a pc value even if we can't make an SBAddress
out of it.

llvm-svn: 180835
2013-05-01 01:26:52 +00:00
Jason Molenda 14c84cdb9c Put a try/catch block around the SBAddress setting; don't want to
terminate the command early if we happen to have an invalid load
address.

llvm-svn: 180826
2013-04-30 23:03:56 +00:00
Jason Molenda f7305a6103 Rename unwind_diagnose.py to diagnose_unwind.py. Change
finish-swig-Python-LLDB.sh to create a new lldb.diagnose subdirectory
in the LLDB framework; the first diagnostic command in this directory
is diagnose-unwind.  There may be others added in the future.

Users can load these diagnostic tools into their session with 
"script import lldb.diagnose".

llvm-svn: 180768
2013-04-30 03:03:06 +00:00
Greg Clayton 8d1d25222e Remove a print statement that was left in accidentally.
llvm-svn: 180223
2013-04-24 22:21:02 +00:00
Jason Molenda e005d78241 One line I forgot to remove.
llvm-svn: 180086
2013-04-23 09:49:03 +00:00
Jason Molenda 0f224d2cd4 Update the unwind_diagnose script to work correctly with both
lldb-179 version numberings and the new lldb-300 version numberings.
Remove the pretense that someone might run this from the command
line; this is only used from within a live lldb debug session.  Fix
the loading so it can be loaded via "script import lldb.macosx" or
the script can be loaded individually like "command script import
unwind_diagnose.py"

llvm-svn: 180085
2013-04-23 09:38:10 +00:00
Jason Molenda 535ab8601f Add a new -a / --address argument to image show-unwind to get the
unwind instructions for a function/symbol which contains that
address.

Update the unwind_diagnose.py script to use this instead of doing
image show-unwind by name to avoid cases where there are multiple
name definitions.

llvm-svn: 180079
2013-04-23 04:30:57 +00:00
Jason Molenda caae381b35 Add a new python file to help diagnose backtrace failures in the field.
It will be installed in the LLDB.framework and can be loaded with

  (lldb) script import lldb.macosx

after which a "unwind-diagnose" command will be registered.  Select
the thread which has a bad backtrace and run this command -- a lot
of information about the stack frames, and an alternate backtrace
algorithm, will be used.  The information will often be sufficient
for a remote person to figure out why the backtrace failed.
<rdar://problem/13679300> 

llvm-svn: 180077
2013-04-23 03:40:32 +00:00
Greg Clayton a16cb16a58 <rdar://problem/13477795>
crashlog.py was always subtracting 1 to point to the previous instruction when symbolicating ARM backtraces. Many times the backtraces will include bit zero set to 1 to indicate thumb, so we need to make sure we mask the address and then backup one for non frame zero frames.

llvm-svn: 178812
2013-04-04 23:36:51 +00:00
Greg Clayton 7b619fc159 Playing around with making performance test cases run from within python.
llvm-svn: 178708
2013-04-03 22:59:27 +00:00
Greg Clayton 2d95f35748 A few more tweaks to the python perf tests. Now there is a MemoryMeasurement.
llvm-svn: 178069
2013-03-26 21:00:29 +00:00
Greg Clayton 52e6378f0f Added a python version of the performance tests. It will be good to see if the overhead of python interferes at all with our performance readings. We can try things out with this script and see how things go.
llvm-svn: 177811
2013-03-23 01:44:48 +00:00
Sean Callanan 60e390cbd5 Created a sample "jump" command that handles
GDB-style linespecs.  This command allows changing
the PC without manually looking up the new address.

llvm-svn: 176841
2013-03-12 00:08:40 +00:00
Enrico Granata f58cececaa Initial checkin of a new project: LLDB Performance Testing Infrastructure
This is a very basic implementation of a library that easily allows to drive LLDB.framework to write test cases for performance

This is separate from the LLDB testsuite in test/ in that:
a) this uses C++ instead of Python to avoid measures being affected by SWIG
b) this is in very early development and needs lots of tweaking before it can be considered functionally complete
c) this is not meant to test correctness but to help catch performance regressions

There is a sample application built against the library (in darwin/sketch) that uses the famous sample app Sketch as an inferior to measure certain basic parameters of LLDB's behavior.
The resulting output is a PLIST much like the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>fetch-frames</key>
		<real>0.13161715522222225</real>
	</dict>
	<dict>
		<key>file-line-bkpt</key>
		<real>0.029111678750000002</real>
	</dict>
	<dict>
		<key>fetch-modules</key>
		<real>0.00026376766666666668</real>
	</dict>
	<dict>
		<key>fetch-vars</key>
		<real>0.17820429311111111</real>
	</dict>
	<dict>
		<key>run-expr</key>
		<real>0.029676525769230768</real>
	</dict>
</array>
</plist>

Areas for improvement:
- code cleanups (I will be out of the office for a couple days this coming week, but please keep ideas coming!)
- more metrics and test cases
- better error checking

This toolkit also comprises a simple event-loop-driven controller for LLDB, similar yet much simpler to what the Driver does to implement the lldb command-line tool.

llvm-svn: 176715
2013-03-08 20:29:13 +00:00
Greg Clayton 923bedf52f Added a new module that can dump all line tables for all compile units in any modules that are specified as arguments to the "dump_module_line_tables" command.
I used this to verify that the debug map line tables were the same as previous LLDB releases prior to my change in the DWARF in .o file linking.

llvm-svn: 176610
2013-03-07 02:57:54 +00:00
Enrico Granata 6308f58254 Being explicit about how ignoring optparse's exceptions is not a best principle
llvm-svn: 176059
2013-02-25 23:01:08 +00:00
Greg Clayton fdc2515ce9 Added missing lldb module namespace.
llvm-svn: 176049
2013-02-25 21:20:59 +00:00
Greg Clayton 59c40ff3f9 <rdar://problem/13286937>
Make sure to not look in self.images when we have a symbolicator with a live process.

llvm-svn: 176040
2013-02-25 19:34:57 +00:00
Jim Ingham 6c00a01526 Mark the command as failed if parsing fails.
llvm-svn: 175776
2013-02-21 18:38:46 +00:00
Greg Clayton c7bece56fa <rdar://problem/13069948>
Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.

So I defined a new "lldb::offset_t" which should be used for all file offsets.

After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.

Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.

llvm-svn: 173463
2013-01-25 18:06:21 +00:00
Greg Clayton a4d8747d0f <rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:

class OperatingSystemPlugin:
  def create_thread(self, tid, context):
    # Return a dictionary for a new thread to create it on demand

This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.

Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*. 
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
	- PyObject *
	- const PythonObject &
	- const lldb::ScriptInterpreterObjectSP &

Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.

llvm-svn: 172873
2013-01-18 23:41:08 +00:00
Sean Callanan c51cd47549 Made crashlog.py handle cases where a parent
process's name contains spaces.  Thanks to
Justin Seyster for the patch.

<rdar://problem/13002540>

llvm-svn: 172294
2013-01-12 02:11:49 +00:00
Greg Clayton 89f255e426 Updated documentation on the "register_data_addr" key that can be supplied in the "thread" dictionary return value for the python OS plug-ins.
llvm-svn: 171934
2013-01-09 02:05:38 +00:00
Greg Clayton ead45e0174 Allow operating system plug-ins to specify the address for registers so we don't have to create data up front.
llvm-svn: 166701
2012-10-25 17:56:31 +00:00
Greg Clayton c9d645d306 <rdar://problem/12491420>
Added a new setting that allows a python OS plug-in to detect threads and provide registers for memory threads. To enable this you set the setting:

settings set target.process.python-os-plugin-path lldb/examples/python/operating_system.py

Then run your program and see the extra threads. 

llvm-svn: 166244
2012-10-18 22:40:37 +00:00
Greg Clayton 984fee5b8f Added process attach options and also use the SBLaunchInfo and SBAttachInfo.
llvm-svn: 164619
2012-09-25 18:27:12 +00:00
Greg Clayton aa4d45314c Added auto LLDB import to the crashlog script.
llvm-svn: 164192
2012-09-19 01:59:34 +00:00
Greg Clayton f453907a6d Modified the command template to include best practices.
llvm-svn: 163773
2012-09-13 05:35:34 +00:00
Greg Clayton b28179bb80 Added some documentation and an accessor for the target with an explanation of why to not use "lldb.target".
llvm-svn: 163671
2012-09-12 00:47:53 +00:00