Commit Graph

1338 Commits

Author SHA1 Message Date
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
Greg Clayton 037520e9cf Cleaned up the lldb_private::Mangled class to get rid of the tokenizing code that has bit rotted and isn't being used. Also cleaned up the API to the "lldb_private::Mangled" to always take "const ConstString &" arguments instead of both "const ConstString &" and "const char *".
llvm-svn: 160466
2012-07-18 23:18:10 +00:00
Greg Clayton 5e0c5e8108 <rdar://problem/10998370>
Improved the error message when we can find a function in the current program by printing the demangled name.

Also added the ability to create lldb_private::Mangled instances with a ConstString when we already have a ConstString for a mangled or demangled name. Also added the ability to call SetValue with a ConstString and also without a boolean to indicate if the string is mangled where we will now auto-detect if the string is mangled.

llvm-svn: 160450
2012-07-18 20:47:40 +00:00
Greg Clayton 358a789744 Cleaned up incorrect STL std::map comparison code and use the operator == on std::map objects instead of manually implementing the comparisons. Also modified the UnwindPlan::AppendRow() function to take a "const RowSP &" object so we don't have to copy shared pointers when calling this function.
llvm-svn: 160448
2012-07-18 20:37:53 +00:00
Jason Molenda 24a8378c4f Change UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly so it records
the state of the unwind instructions once the prologue has finished.  If it hits an
early return epilogue in the middle of the function, re-instate the prologue after that
epilogue has completed so that we can still unwind for cases where the flow of control
goes past that early-return.  <rdar://problem/11775059>

Move the UnwindPlan operator== definition into the .cpp file, expand the definition a bit.

Add some casts to a SBCommandInterpreter::HandleCompletion() log statement so it builds without
warning on 64- and 32-bit systems.

llvm-svn: 160337
2012-07-17 01:57:24 +00:00
Jim Ingham ab728678ee Lock around reading as well as connecting & disconnecting so we don't start reading after
someone has set our file descriptor to -1 and crash in FD_SET...
<rdar://problem/11653966>

llvm-svn: 160336
2012-07-17 01:47:11 +00:00
Enrico Granata 3372f581eb <rdar://problem/11672978> Fixing an issue where an ObjC object might come out without a description because the expression used to obtain it would timeout before running to completion
llvm-svn: 160326
2012-07-16 23:10:35 +00:00
Jason Molenda 1d42c7bc32 Switch nearly all of the use of the UnwindPlan::Row's to go through
a shared pointer to ease some memory management issues with a patch
I'm working on.

The main complication with using SPs for these objects is that most
methods that build up an UnwindPlan will construct a Row to a given
instruction point in a function, then add additional regsaves in
the next instruction point to that row and push it again.  A little
care is needed to not mutate the previous instruction point's Row
once these are switched to being held behing shared pointers.

llvm-svn: 160214
2012-07-14 04:52:53 +00:00
Greg Clayton 685c88c5a8 <rdar://problem/11870357>
Allow "frame variable" to find ivars without the need for "this->" or "self->".  

llvm-svn: 160211
2012-07-14 00:53:55 +00:00
Enrico Granata f04a21917c <rdar://problem/11782789> Changes to the watchpoint implementation on ARM so that we single-step before stopping at the WP. This is necessary because on ARM the WP triggers before the opcode is actually executed, so we would be unable to continue since we would keep hitting the WP. We work around this by disabling the WP, single stepping and then putting the WP back in place.
llvm-svn: 160199
2012-07-13 23:18:48 +00:00
Jim Ingham 18b4689639 Add accessors on process to get & set the selected thread by IndexID (useful since that's the one that "thread list" shows and it won't get reused even if the underlying system thread ID gets reused.
llvm-svn: 160187
2012-07-13 20:18:18 +00:00
Greg Clayton 1d60909e81 <rdar://problem/11740973>
Fixed issues that could happen when the UUID doesn't change in a binary and old stale debug info could end up being used.

llvm-svn: 160145
2012-07-12 22:51:12 +00:00
Greg Clayton 4e0fe8ab95 <rdar://problem/11791234>
Fixed a case where the python interpreter could end up holding onto a previous lldb::SBProcess (probably in lldb.process) when run under Xcode. Prior to this fix, the lldb::SBProcess held onto a shared pointer to a lldb_private::Process. This in turn could cause the process to still have a thread list with stack frames. The stack frames would have module shared pointers in the lldb_private::SymbolContext objects. 

We also had issues with things staying in the shared module list too long when we found things by UUID (we didn't remove the out of date ModuleSP from the global module cache).

Now all of this is fixed and everything goes away between runs.

llvm-svn: 160140
2012-07-12 20:32:19 +00:00
Jim Ingham 17ce5b977b Add a command channel to wait on along with the file descriptor the ConnectionFileDescriptor class is managing, so we can always pop ourselves out of our select call regardless of how well behaved the channel we are talking to is.
<rdar://problem/11448282>

llvm-svn: 160100
2012-07-12 01:17:55 +00:00
Sean Callanan 7d69f12e75 Added a mutex to the call frame info to guard
generation of the FDE index.

<rdar://problem/11813705>

llvm-svn: 160099
2012-07-12 01:11:40 +00:00
Jason Molenda 380241a81f Add a new 'target modules show-unwind' command to show the different
UnwindPlans for a function.  This specifically does not use any
previously-generated UnwindPlans so if any logging is performed
while creating the UnwindPlans, it will be repeated.  This is
useful for when an lldb stack trace is not correct and you want
to gather diagnostic information from the user -- they can do 
log enable -v lldb unwind, image show-unwind of the function, and
you'll get the full logging as the UnwindPlans are recreated.

llvm-svn: 160095
2012-07-12 00:20:07 +00:00
Greg Clayton c3a86bf9f0 Modifying the "address" format, which prints a pointer and a description of what it points to, to detect when the deref of that pointer points to something valid. So if you have:
% cat sp.cpp 
    #include <tr1/memory>

    class A
    {
    public:
        A (): m_i (12) {}
        virtual ~A() {}
    private:
        int m_i;
    };

    int main (int argc, char const *argv[], char const *envp[])
    {
        A *a_pointers[2] = { NULL, NULL };
        A a1;
        A a2;
        a_pointers[0] = &a1;
        a_pointers[1] = &a2;
        return 0;
    }


And you stop at the "return 0", you can now read memory using the "address" format and see:

(lldb) memory read --format address `&a_pointers`
0x7fff5fbff870: 0x00007fff5fbff860 -> 0x00000001000010b0 vtable for A + 16
0x7fff5fbff878: 0x00007fff5fbff850 -> 0x00000001000010b0 vtable for A + 16
0x7fff5fbff880: 0x00007fff5fbff8d0
0x7fff5fbff888: 0x00007fff5fbff8c0
0x7fff5fbff890: 0x0000000000000001
0x7fff5fbff898: 0x36d54c275add2294
0x7fff5fbff8a0: 0x00007fff5fbff8b0
0x7fff5fbff8a8: 0x0000000100000bb4 a.out`start + 52

Note the extra dereference that was applied to 0x00007fff5fbff860 and 0x00007fff5fbff850 so we can see that these are "A" classes.

llvm-svn: 160085
2012-07-11 22:18:24 +00:00
Greg Clayton 53eb7ad2f7 <rdar://problem/11852100>
The "stop-line-count-after" and "stop-line-count-before" settings are broken. This fixes them.

llvm-svn: 160071
2012-07-11 20:33:48 +00:00
Filipe Cabecinhas 5137f317ce Fixed typos found while reading commit logs.
llvm-svn: 159930
2012-07-09 13:42:24 +00:00
Jason Molenda 75b9cfd1f0 Simplify the CreateDefaultUnwindPlan methods for the x86 and arm unwinders
a bit -- we're creating the UnwindPlan here, we can set the register set to
whatever is convenient for us, no need to handle different register sets.

A handful of small comment fixes I noticed while reading through the code.

llvm-svn: 159924
2012-07-09 07:47:47 +00:00
Greg Clayton 7820bd1e52 <rdar://problem/11357711>
Fixed a crasher where the section load list was not thread safe.

llvm-svn: 159884
2012-07-07 01:24:12 +00:00
Greg Clayton 9407302d37 Make const result value objects able to return dynamic types.
Modified the heap.py to be able to correctly indentify the exact ivar for the "ptr_refs" command no matter how deep the ivar is in a class hierarchy. Also fixed the ability for the heap command to symbolicate the stack backtrace when MallocStackLogging is set in the environment and the "--stack" option was specified.

llvm-svn: 159883
2012-07-07 01:22:45 +00:00
Sean Callanan ec440dd774 Since SBTarget::FindFunctions returns a
SBSymbolContextList, we should include the
relevant header file.

llvm-svn: 159840
2012-07-06 17:44:41 +00:00
Jim Ingham 43c555dfcd Work around some problems destroying a process with older debugservers.
rdar://problem/11359989

llvm-svn: 159697
2012-07-04 00:35:43 +00:00
Jim Ingham 03afad8f1e Add an "extra-startup-commands" process setting so we can send some command strings to the actual process plugin to interpret as it wishes.
llvm-svn: 159511
2012-07-02 05:40:07 +00:00
Greg Clayton 9a69ac5d67 Spelling fixes.
llvm-svn: 159467
2012-06-29 21:58:52 +00:00
Greg Clayton fed39aa653 Added the ability to read the dSYM plist file with source remappings even when DebugSymbols isn't used to find the dSYM. We now parse the plist as XML in the MacOSX symbol vendor.
Added the ability to get a section load address given a target which is needed for a previous checking which saves crashlogs.

llvm-svn: 159298
2012-06-27 22:22:28 +00:00
Jim Ingham 70f11f88e3 Make a way to set the result status for Python defined commands, and don't overwrite the status of the result if
the python command has set it.

llvm-svn: 159273
2012-06-27 17:25:36 +00:00
Jim Ingham 0fd1b75f50 Fix ignore counts on breakpoints so they actually work.
llvm-svn: 159233
2012-06-26 22:27:55 +00:00
Jim Ingham 4ceb928f02 Change the Mutex::Locker class so that it takes the Mutex object and locks it, rather
than being given the pthread_mutex_t from the Mutex and locks that.  That allows us to
track ownership of the Mutex better.  

Used this to switch the LLDB_CONFIGURATION_DEBUG enabled assert when we can't get the
gdb-remote sequence mutex to assert when the thread that had the mutex releases it.  This
is generally more useful information than saying just who failed to get it (since the
code that had it locked often had released it by the time the assert fired.)

llvm-svn: 158240
2012-06-08 22:50:40 +00:00
Jim Ingham 5a98841673 Make raw & parsed commands subclasses of CommandObject rather than having the raw version implement an
Execute which was never going to get run and another ExecuteRawCommandString.  Took the knowledge of how
to prepare raw & parsed commands out of CommandInterpreter and put it in CommandObject where it belongs.

Also took all the cases where there were the subcommands of Multiword commands declared in the .h file for
the overall command and moved them into the .cpp file.

Made the CommandObject flags work for raw as well as parsed commands.

Made "expr" use the flags so that it requires you to be paused to run "expr".

llvm-svn: 158235
2012-06-08 21:56:10 +00:00
Sean Callanan 5677536bff Committed a change to the SectionList that introduces
a cache of address ranges for child sections,
accelerating lookups.  This cache is built during
object file loading, and is then set in stone once
the object files are done loading.  (In Debug builds,
we ensure that the cache is never invalidated after
that.)

llvm-svn: 158188
2012-06-08 02:16:08 +00:00
Sean Callanan 64c0cf2134 Added a setting (target.process.disable-memory-cache)
that controls whether memory is cached.  This is off
by default (i.e., memory is cached) because it greatly
improves performance.

llvm-svn: 158173
2012-06-07 22:26:42 +00:00
Enrico Granata 79cc6f7a26 <rdar://problem/11538779> Fixing issues where Python scripts were not able to read user input and/or display output to the user in certain situations - This fix introduces a Python InputReader manager class that mimics the behavior of the interactive interpreter in terms of access to I/O and ensures access to the input and output flows
llvm-svn: 158124
2012-06-07 00:17:18 +00:00
Johnny Chen 89b639e9a8 Update wording for the member field m_error.
llvm-svn: 158095
2012-06-06 19:01:20 +00:00
Jim Ingham ef42a6fb1d Add the SBWatchpoint::GetError back, we have clients who use it.
llvm-svn: 158092
2012-06-06 18:46:25 +00:00
Jim Ingham aacc31813e Make sure that when if we are going to Halt while the process is in the middle of HandlePrivateEvent we
wait till that is done.  We need a stronger way to do this, but in practice this works and using some locking
strategy is harder because Halt & HandlePrivateEvent generally happen on different threads.

llvm-svn: 158042
2012-06-06 00:29:30 +00:00
Johnny Chen c4392d2ad0 rdar://problem/11598332
The output of 'register read' should be prettier.
Modify RegisterValue::Dump() to take an additional parameter:

    uint32_t reg_name_right_align_at

which defaults to 0 (i.e., no alignment at all).  Update the 'register read' command impl to pass 8
as the alignment to RegisterValue::Dump() method.  If more sophisticated scheme is desired, we will
need to introduce an additional command option to 'register read' later on.

llvm-svn: 158039
2012-06-05 23:25:10 +00:00
Jim Ingham 41ec0f9018 Whitespace cleanup.
llvm-svn: 158032
2012-06-05 22:53:34 +00:00
Johnny Chen 3f476c4a72 rdar://problem/11597911
Fix confusing error message about "expression did not evaluate to an address" when doing 'watchpoint set expression".
Instead of using 0 as the fail_value when invoking ValueObject::GetValueAsUnsigned(), modify the API to take an addition
bool pointer (defaults to NULL) to indicate success/failure of value conversion.

llvm-svn: 158016
2012-06-05 19:37:43 +00:00
Johnny Chen d3761a7e10 Cannot break the existing API client of SBValue::Watch(bool resolve_location, bool read, bool write).
Leave this method in the codebase for a while.

llvm-svn: 157967
2012-06-04 23:45:50 +00:00
Johnny Chen b90827e66c rdar://problem/11584012
Refactorings of watchpoint creation APIs so that SBTarget::WatchAddress(), SBValue::Watch(), and SBValue::WatchPointee()
now take an additional 'SBError &error' parameter (at the end) to contain the reason if there is some failure in the
operation.  Update 'watchpoint set variable/expression' commands to take advantage of that.

Update existing test cases to reflect the API change and add test cases to verify that the SBError mechanism works for
SBTarget::WatchAddress() by passing an invalid watch_size.

llvm-svn: 157964
2012-06-04 23:19:54 +00:00
Johnny Chen 3cb41e82cb Give more explicit error messages when watchpoint creation command (watchpoint set) fails,
like number of supported hardware watchpoints reached or the watch size is not allowed.

llvm-svn: 157948
2012-06-04 20:08:23 +00:00