Commit Graph

1380 Commits

Author SHA1 Message Date
Jim Ingham 513c6bb88c Initial check-in of "fancy" inlined stepping. Doesn't do anything useful unless you switch LLDB_FANCY_INLINED_STEPPING to true. With that
on, basic inlined stepping works, including step-over of inlined functions.  But for some as yet mysterious reason i386 debugging gets an
assert and dies immediately.  So for now its off.

llvm-svn: 163044
2012-09-01 01:02:41 +00:00
Greg Clayton 4c05410f8f Made it so changes to the prompt via "settings set prompt" get noticed by the command line.
Added the ability for OptionValueString objects to take flags. The only flag is currently for parsing escape sequences. Not the prompt string can have escape characters translate which will allow colors in the prompt.

Added functions to Args that will parse the escape sequences in a string, and also re-encode the escape sequences for display. This was looted from other parts of LLDB (the Debugger::FormatString() function).

llvm-svn: 163043
2012-09-01 00:38:36 +00:00
Jim Ingham fcb59bcfc6 Add a convenience function to get the range containing a given PC specified as load address + Target.
llvm-svn: 163038
2012-08-31 23:49:32 +00:00
Greg Clayton 7036425c59 <rdar://problem/12202862>
Added a fix for incorrect dynamic typing. Before when asking if a C++ class could be dynamic, we would answer yes for incomplete C++ classes. This turned out to have issues where if a class was not virtual, yet had its first ivar be an instance of a virtual class, we would incorrectly say that a class was virtual and we would downcast it to be a pointer to the first ivar. We now ask the class to complete itself prior to answering the question. We need to test the effects on memory of this change prior to submission. It is the safest and best fix, but it does have a potential downside of higher memory consumption.

llvm-svn: 163014
2012-08-31 18:56:24 +00:00
Greg Clayton facebca6ba Fix indentation.
llvm-svn: 163011
2012-08-31 18:11:06 +00:00
Greg Clayton 0b0b512fd6 OptionValueFileSpec had an accessor to read the contents of the file and return the data. This can end up being used to get the string contents of a text file and could end up not being NULL terminated. I added accessors to get the file contents raw, or with a null terminator. Added the needed calls to make this happen in the FileSpec and File classes.
llvm-svn: 162921
2012-08-30 18:15:10 +00:00
Greg Clayton 1f7460716b <rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". 
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()

Cleaned up header includes a bit as well.

llvm-svn: 162860
2012-08-29 21:13:06 +00:00
Filipe Cabecinhas c5041918dd Added SBDebugger's log callbacks to Python-land
- Tweaked a parameter name in SBDebugger.h so my typemap will catch it;
- Added a SBDebugger.Create(bool, callback, baton) to the swig interface;
- Added SBDebugger.SetLoggingCallback to the swig interface;
- Added a callback utility function for log callbacks;
- Guard against Py_None on both callback utility functions;

- Added a FIXME to the SBDebugger API test;
- Added a __del__() stub for SBDebugger.

We need to be able to get both the log callback and baton from an
SBDebugger if we want to protect against memory leaks (or make the user
responsible for holding another reference to the callback).
Additionally, it's impossible to revert from a callback-backed log
mechanism to a file-backed log mechanism.

llvm-svn: 162633
2012-08-25 00:29:07 +00:00
Sean Callanan 6efc2ba7f8 Changed register ValueObjects to report their
expression path in a way that can actually be
resolved by "expr".

llvm-svn: 162574
2012-08-24 18:21:05 +00:00
Greg Clayton 435ce13937 The OS plug-in can now get data from a python script that implements the protocol.
llvm-svn: 162540
2012-08-24 05:45:15 +00:00
Greg Clayton 2443cbd7f5 Added Args::StringForEncoding(), Args::StringToGenericRegister() and centralized the parsing of the string to encoding and string to generic register.
Added code the initialize the register context in the OperatingSystemPython plug-in with the new PythonData classes, and added a test OperatingSystemPython module in lldb/examples/python/operating_system.py that we can use for testing.

llvm-svn: 162530
2012-08-24 01:42:50 +00:00
Enrico Granata 6167ab2819 Hooking up two more calls for the PythonOSPlugin stuff. The part of code to fetch the data and convert it to C++ objects is still missing, but will come
llvm-svn: 162522
2012-08-24 00:51:29 +00:00
Enrico Granata 5790759a06 Adding bindings to the Script Interpreter for some basic Python OS plugin functionality (still WIP)
llvm-svn: 162513
2012-08-24 00:30:47 +00:00
Greg Clayton 281d7998b8 Switch over to using object instances for all PythonData objects.
llvm-svn: 162504
2012-08-23 23:49:47 +00:00
Johnny Chen 892943f9dd Cope with the case where the user-supplied callbacks want the watchpoint itself to be disabled!
Previously we put a WatchpointSentry object within StopInfo.cpp to disable-and-then-enable the watchpoint itself
while we are performing the actions associated with the triggered watchpoint, which can cause the user-initiated
watchpoint disabling action to be negated.

Add a test case to verify that a watchpoint can be disabled during the callbacks.

llvm-svn: 162483
2012-08-23 22:28:26 +00:00
Enrico Granata 0845a1a077 A first version of a bunch of classes that wrap commonly used Python objects in a ref-counting and type-safe C++ API
llvm-svn: 162481
2012-08-23 22:02:23 +00:00
Greg Clayton 754a9369db <rdar://problem/12022079>
Added a new "interpreter" properties to encapsulate any properties for the command interpreter. Right now this contains only "expand-regex-aliases", so you can now enable (disabled by default) the echoing of the command that a regular expression alias expands to:

(lldb) b main
Breakpoint created: 1: name = 'main', locations = 1

Note that the expanded regular expression command wasn't shown by default. You can enable it if you want to:

(lldb) settings set interpreter.expand-regex-aliases true
(lldb) b main
breakpoint set --name 'main'
Breakpoint created: 1: name = 'main', locations = 1

Also enabled auto completion for enumeration option values (OptionValueEnumeration) and for boolean option values (OptionValueBoolean).

Fixed auto completion for settings names when nothing has been type (it should show all settings).

llvm-svn: 162418
2012-08-23 00:22:02 +00:00
Jim Ingham 4e22598b0f Fix some indenting.
llvm-svn: 162406
2012-08-22 22:52:39 +00:00
Jim Ingham 4fc6cb9c76 Rework how the API mutex is acquired when filling out an ExecutionContext from an ExecutionContextRef,
particularly in the SBThread & SBFrame interfaces.  Instead of filling the whole context & then getting
the API mutex, we now get only the target, acquire the API mutex from it, then fill out the rest of the
context.  This removes a race condition where you get a ThreadSP, then wait on the API mutex while another
command Destroy's the Thread you've just gotten.
Also fixed the ExecutionContextRef::Get*SP calls so they don't return invalid objects.
Also fixed the ExecutionContext::Has*Scope calls so they don't claim to have a scope if the object representing
that scope has been destroyed.
Also fixed a think-o in Thread::IsValid which was causing it to return the opposite of the desired value.

<rdar://problem/11995490>

llvm-svn: 162401
2012-08-22 21:34:33 +00:00
Greg Clayton 6920b52be6 Remove further outdated "settings" code and also implement a few missing things.
llvm-svn: 162376
2012-08-22 18:39:03 +00:00
Greg Clayton 67cc06366c Reimplemented the code that backed the "settings" in lldb. There were many issues with the previous implementation:
- no setting auto completion
- very manual and error prone way of getting/setting variables
- tons of code duplication
- useless instance names for processes, threads

Now settings can easily be defined like option values. The new settings makes use of the "OptionValue" classes so we can re-use the option value code that we use to set settings in command options. No more instances, just "does the right thing".

llvm-svn: 162366
2012-08-22 17:17:09 +00:00
Johnny Chen 4fe2302ae2 Fix test failures in TestWatchpointIter.py due to http://llvm.org/viewvc/llvm-project?rev=162322&view=rev.
llvm-svn: 162328
2012-08-21 23:17:04 +00:00
Filipe Cabecinhas c30199917a A baton isn't needed to dispatch input.
I also added a typemap to make DispatchInput usable in Python.

llvm-svn: 162204
2012-08-20 16:21:04 +00:00
Jason Molenda 8eba46c68a Some eh_frame unwind instructions will define a return address register;
when you want to find the caller's saved pc, you look up the return address
register and use that.  On arm, for instance, this would be the contents of
the link register (lr).

If the eh_frame CIE defines an RA, record that fact in the UnwindPlan.

When we're finding a saved register, if it's the pc, lok for the location
of the return address register instead.

<rdar://problem/12062310> 

llvm-svn: 162167
2012-08-18 06:53:34 +00:00
Johnny Chen 2c90e999aa Merge python-GIL bracnh (by filcab) back into trunk!
llvm-svn: 162161
2012-08-18 04:14:54 +00:00
Johnny Chen 319e927ae1 Fix a race condition where multiple PythonInputReaderManager instances could, during destruction,
tread on the m_embedded_thread_input_reader_sp singleton maintained by the script interpreter.
Furthermore, use two additional slots under the script interpreter to store the PseudoTerminal and
the InputReaderSP pertaining to the embedded python interpreter -- resulted from the
ScriptInterpreterPython::ExecuteInterpreterLoop() call -- to facilitate separation from what is being
used by the PythonInputReaderManager instances.

llvm-svn: 162147
2012-08-17 23:44:35 +00:00
Johnny Chen 25c0eb4a38 When trying to take snapshots of a watched variable, if the frame is unable to evaluate the variable expression,
do not take the sanpshot and forget about the stop info.  It is possible that the variable expression has gone
out of scope, we'll revise the hit count due to the false alarms.

llvm-svn: 161892
2012-08-14 20:56:37 +00:00
Johnny Chen 88fc73b8f7 Simplify the "Watchpoint ... hit" printout, make it more terse.
Change the test case, too. 

llvm-svn: 161806
2012-08-13 23:27:50 +00:00
Johnny Chen 209bd65ea4 rdar://problem/12007576
Record the snapshot of our watched value when the watchpoint is set or hit.
And report the old/new values when watchpoint is triggered.  Add some test scenarios.

llvm-svn: 161785
2012-08-13 21:09:54 +00:00
Jim Ingham f94e179172 Add explicit casts to bool in "shared pointer is valid" constructs that return bool.
llvm-svn: 161719
2012-08-11 00:35:26 +00:00
Greg Clayton 8179bcac55 <rdar://problem/11791234>
Fixed an issue that could cause references the shared data for an object file to stay around longer than intended and could cause memory bloat when debugging multiple times.

llvm-svn: 161716
2012-08-10 23:33:27 +00:00
Johnny Chen e9a5627e7a rdar://problem/11457143 [ER] need "watchpoint command ..."
Add 'watchpoint command add/delete/list' to lldb, plus two .py test files.

llvm-svn: 161638
2012-08-09 23:09:42 +00:00
Enrico Granata 17b1174911 <rdar://problem/11578397> Adding a new --summary-string option for the frame variable command which allows the user to provide a summary string with which he wants to display the variables without having to make a named summary first
llvm-svn: 161623
2012-08-09 22:02:51 +00:00
Enrico Granata 7ec18e3d10 <rdar://problem/10449092> Adding a new uppercase hex format specifier. This commit also changes the short names for formats so that uppercase hex can be 'X', which was previously assigned to hex float. hex float now has no short name.
llvm-svn: 161606
2012-08-09 19:33:34 +00:00
Sean Callanan bcf897fa89 LLDB no longer prints <no result> by default if
the expression returns nothing.  There is now a
setting, "notify-void."  When the user enables
that setting, lldb prints (void) if an expression's
result is void.  Otherwise, lldb is silent.

<rdar://problem/11225150>

llvm-svn: 161600
2012-08-09 18:18:47 +00:00
Enrico Granata 2b2631c915 <rdar://problem/11505459> Stripping off the object's type from the output of the 'po' command
llvm-svn: 161592
2012-08-09 16:51:25 +00:00
Greg Clayton fcde4fad2b Fixed the delay that was happening when quitting lldb from the command line. We weren't initializing the command pipes when constructing a ConnectionFileDescriptor with a file descriptor.
llvm-svn: 161533
2012-08-08 22:27:52 +00:00
Sean Callanan bf154daee6 Added a 'void' format so that the user can manually
suppress all non-error output from the "expression"
command.

<rdar://problem/11225150>

llvm-svn: 161502
2012-08-08 17:35:10 +00:00
Sean Callanan cd4ae1ab94 Changed the Opcode::GetData() API so that it didn't
require an AddressClass, which is useless at this
point since it already knows the distinction between
32-bit Thumb opcodes and 32-bit ARM opcodes.

llvm-svn: 161382
2012-08-07 01:44:58 +00:00
Sean Callanan 5c97c2f7b0 Improved raw disassembly output for Thumb.
llvm-svn: 161360
2012-08-06 23:42:52 +00:00
Johnny Chen 0efe2743f8 Pull in cxa_demangle.cpp/.h from llvm's libcxxabi project. Change the namespace to lldb_cxxabiv1 for the time being.
Mangled.cpp is not wired in to call it yet.

llvm-svn: 161293
2012-08-04 01:36:57 +00:00
Enrico Granata e2e091bd59 <rdar://problem/12027563> Making sure that some class of stop-hook commands that involve po'ing objects do not cause an endless recursion
llvm-svn: 161271
2012-08-03 22:24:48 +00:00
Sean Callanan 7e6d4e5a11 Instructions generated by a disassembler can now
keep a shared pointer to their disassembler.  This
is important for the LLVM-C disassembler because
it needs to lock its parent in order to disassemble
itself.

This means that every interface that returned a
Disassembler* needs to return a DisassemblerSP, so
that the instructions and any external owners share
the same reference count on the object.  I changed
all clients to use this shared pointer, which also
plugged a few leaks.

<rdar://problem/12002822>

llvm-svn: 161123
2012-08-01 18:50:59 +00:00
Greg Clayton 1811b4faad <rdar://problem/11275622>
Added new API to lldb::SBTypeMember for bitfields:

    bool SBTypeMember::IsBitfield();
    uint32_t SBTypeMember::GetBitfieldSizeInBits();

Also added new properties for easy access. Now SBTypeMember objects in python have a "fields" property for all type fields, "bases" for all direct bases, "vbases" for all virtual base classes and "members" for a combo of all three organized by bit offset. They all return a python list() of SBTypeMember objects. Usage:
(lldb) script
>>> t = lldb.target.FindFirstType("my_type")
>>> for field in t.fields:
...     print field
>>> for vbase in t.vbases:
...     print vbase
>>> for base in t.bases:
...     print base
>>> for member in t.members:
...     print member

Also added new "is_bitfield" property to the SBTypeMember objects that will return the result of SBTypeMember::IsBitfield(), and "bitfield_bit_size" which will return the result of SBTypeMember::GetBitfieldSizeInBits();

I also fixed "SBTypeMember::GetOffsetInBytes()" to return the correct byte offset.

llvm-svn: 161091
2012-07-31 23:39:10 +00:00
Jim Ingham cfc0935ed9 Added an lldb_private & equivalent SB API to send an AsyncInterrupt to the event loop.
Convert from calling Halt in the lldb Driver.cpp's input reader's sigint handler to sending this AsyncInterrupt so it can be handled in the 
event loop.
If you are attaching and get an async interrupt, abort the attach attempt.
Also remember to destroy the process if get interrupted while attaching.
Getting this to work also required handing the eBroadcastBitInterrupt in a few more places in Process WaitForEvent & friends.

<rdar://problem/10792425>

llvm-svn: 160903
2012-07-27 23:57:19 +00:00
Jim Ingham 279ceecf65 Add a call to "sync" a thread state before checkpointing registers in preparation for
calling functions.  This is necessary on Mac OS X, since bad things can happen if you set
the registers of a thread that's sitting in a kernel trap.

<rdar://problem/11145013>

llvm-svn: 160756
2012-07-25 21:12:43 +00:00
Sean Callanan 6e6d4a6223 Added a fix that allows newly-constructed objects
to returned by expressions, by removing the
__cxa_atexit call that would normally cause these
objects to be destroyed.  This also prevents many
errors of the form

Couldn't rewrite one of the arguments of a function call
error: Couldn't materialize struct: Structure hasn't been laid out yet

<rdar://problem/11309402>

llvm-svn: 160596
2012-07-21 02:02:15 +00:00
Jim Ingham cd16df9154 Add "vAttachOrWait" to debugserver, so you can implement "attach to the process if it exists OR wait for it" without race conditions. Use that in lldb.
llvm-svn: 160578
2012-07-20 21:37:13 +00:00
Greg Clayton 8e59d2d940 Fixed the file header to match the filename.
llvm-svn: 160524
2012-07-19 21:24:56 +00:00
Greg Clayton f866543a36 Fixed the comment for the lldb_private::PathType enumerations.
llvm-svn: 160523
2012-07-19 21:23:34 +00:00