Commit Graph

1561 Commits

Author SHA1 Message Date
Johnny Chen ded0a2c05a Converted to use Makefile.rules.
llvm-svn: 123471
2011-01-14 21:55:29 +00:00
Johnny Chen fa38041dac Add makefile debugging rule for printing out the value of a variable.
From http://blog.melski.net/tag/debugging-makefiles/.

Example:

[13:14:59] johnny:/Volumes/data/lldb/svn/trunk/test/class_static $ make print-CC
CC=gcc
  origin = file
  flavor = recursive
   value = gcc
[13:15:09] johnny:/Volumes/data/lldb/svn/trunk/test/class_static $ make print-LD
LD=  g++
  origin = file
  flavor = recursive
   value = $(call cxx_linker,$(CC))
[13:15:21] johnny:/Volumes/data/lldb/svn/trunk/test/class_static $ make print-CXX
CXX=  g++
  origin = file
  flavor = recursive
   value = $(call cxx_compiler,$(CC))
[13:15:29] johnny:/Volumes/data/lldb/svn/trunk/test/class_static $

llvm-svn: 123469
2011-01-14 21:18:12 +00:00
Caroline Tice 8f5b2eb1e2 Recent modifications to the Python script interpreter caused some problems
when handling one-liner commands that contain escaped characters.  In
order to deal with the new namespace/dictionary stuff, the command was
being embedded within a second string, which messed up the escaping.

This fixes the problem by handling one-liners in a different manner, so they
no longer need to be embedded within another string, and can still be
processed in the proper namespace/dictionary context.

llvm-svn: 123467
2011-01-14 21:09:29 +00:00
Stephen Wilson c6c7ca58e4 Extend the ObjectFile interface to support dynamic loading on ELF platforms.
Debuggers on ELF platforms hook into the runtime linker by monitoring a special
"rendezvous" embedded in the address space of the inferior process.  The exact
location of this structure is filled in by the runtime linker and can be
resolved by locating the DT_DEBUG entry in the processes .dynamic section.  The
new GetImageInfoAddress() method (morally equivalent to
Process::GetImageInfoAddress) provides the mechanism to locate this information.

GetEntryPoint() simply returns the address of the start symbol in the executable
if present.  It is useful to the dynamic loader plugin for ELF systems as this
is the earliest point where LLDB can break and probe the inferiors .dynamic
section and rendezvous structure.  Also, this address can be used in the
computation of the virtual base address for position independent executables.

llvm-svn: 123466
2011-01-14 21:08:59 +00:00
Stephen Wilson 0b8dab726b Do not prematurely invalidate thread handle.
Setting m_private_state_thread to an invalid value when the child thread exits
results in a race condition between calls to ThreadCancel and ThreadJoin.

llvm-svn: 123465
2011-01-14 21:07:56 +00:00
Stephen Wilson 5394e0da9d Do not prefix log messages with ProcessMacOSX from the context of Process.
llvm-svn: 123464
2011-01-14 21:07:07 +00:00
Johnny Chen 6055b44b04 Added comments.
llvm-svn: 123463
2011-01-14 20:55:13 +00:00
Johnny Chen d43e208bb4 Make CC defaults to gcc. The cxx_compiler and cxx_linker functions rely on substituting "g++"
for "gcc".

llvm-svn: 123461
2011-01-14 20:46:49 +00:00
Greg Clayton 1629c43dd3 Removed printf statements in code.
llvm-svn: 123455
2011-01-14 19:21:25 +00:00
Johnny Chen 15a42aefa4 Add an expression command:
expression (int)[nil_mutable_array count]

within NSArray_expr() function and expect a return of 0.

llvm-svn: 123454
2011-01-14 19:19:30 +00:00
Johnny Chen bdb4efcf17 The cxx_compiler function should not blindly return clang++ as the C++ compiler if $(CC) contains "clang".
Instead, it should perform a textual replacement of $(CC) from "clang" to "clang++".  The same is true
for "llvm-gcc" to "llvm-g++" and for "gcc" to "g++".  This way, we keep the path component of the $(CC)
passed in from the user and do not end up with a mixed toolchains with different paths.

Ditto for a newly added function called cxx_linker.

llvm-svn: 123451
2011-01-14 18:19:53 +00:00
Greg Clayton ca512b397c Fixed an error in the type map for "char **" that was a bad memory smasher.
Anytime we had a valid python list that was trying to go from Python down into
our C++ API, it was allocating too little memory and it ended up smashing
whatever was next to the allocated memory.

Added typemap conversions for "void *, size_t" so we can get 
SBProcess::ReadMemory() working. Also added a typemap for "const void *, size_t"
so we can get SBProcess::WriteMemory() to work.

Fixed an issue in the DWARF parser where we weren't correctly calculating the
DeclContext for all types and classes. We now should be a lot more accurate.
Fixes include: enums should now be setting their parent decl context correctly.
We saw a lot of examples where enums in classes were not being properly
namespace scoped. Also, classes within classes now get properly scoped.

Fixed the objective C runtime pointer checkers to let "nil" pointers through
since these are accepted by compiled code. We also now don't call "abort()"
when a pointer doesn't validate correctly since this was wreaking havoc on
the process due to the way abort() works. We now just dereference memory
which should give us an exception from which we can easily and reliably 
recover.

llvm-svn: 123428
2011-01-14 04:54:56 +00:00
Caroline Tice 2f88aadff1 Split up the Python script interpreter code to allow multiple script interpreter objects to
exist within the same process (one script interpreter object per debugger object).  The
python script interpreter objects are all using the same global Python script interpreter;
they use separate dictionaries to keep their data separate, and mutex's to prevent any object
attempting to use the global Python interpreter when another object is already using it.

llvm-svn: 123415
2011-01-14 00:29:16 +00:00
Sean Callanan e1175b7c67 Fixed handling of explicitly-declared persistent
variables.

llvm-svn: 123398
2011-01-13 21:23:32 +00:00
Sean Callanan 92adcac9ec Implemented a major overhaul of the way variables are handled
by LLDB.  Instead of being materialized into the input structure
passed to the expression, variables are left in place and pointers
to them are materialzied into the structure.  Variables not resident
in memory (notably, registers) get temporary memory regions allocated
for them.

Persistent variables are the most complex part of this, because they
are made in various ways and there are different expectations about
their lifetime.  Persistent variables now have flags indicating their
status and what the expectations for longevity are.  They can be
marked as residing in target memory permanently -- this is the
default for result variables from expressions entered on the command
line and for explicitly declared persistent variables (but more on
that below).  Other result variables have their memory freed.

Some major improvements resulting from this include being able to
properly take the address of variables, better and cleaner support
for functions that return references, and cleaner C++ support in
general.  One problem that remains is the problem of explicitly
declared persistent variables; I have not yet implemented the code
that makes references to them into indirect references, so currently
materialization and dematerialization of these variables is broken.

llvm-svn: 123371
2011-01-13 08:53:35 +00:00
Greg Clayton 87ff1acc0c Plug Free BSD memory leak.
llvm-svn: 123357
2011-01-13 01:27:55 +00:00
Greg Clayton 984cb75b2b Call SetFile instead of constructing a temp object and assigning to g_program_filespec for Free BSD port.
llvm-svn: 123356
2011-01-13 01:25:48 +00:00
Greg Clayton b332639004 Don't have the program path be resolved when they already are when assigning g_program_filespec in the Host calls.
llvm-svn: 123355
2011-01-13 01:23:43 +00:00
Stephen Wilson a08cfb1299 Do not pass an invalid thread to Thread{Cancel,Join}.
A race condition exists between StopReadThread and the reader thread proper.
When StopReadThread sets m_read_thread_enabled to false the reader thread can
terminate and set m_read_thread to LLDB_INVALID_HOST_THREAD on exit.  Thus calls
to ThreadCancel or ThreadJoin in StopReadThread can be passed an invalid handle.

This patch removes the race by using m_read_thread_enabled as the flag thru
which the reader thread can notify the parent thread of early/abnormal
termination.

llvm-svn: 123309
2011-01-12 04:22:54 +00:00
Stephen Wilson c2204398e0 Initialize SymbolFileDWARFDebugMap on Apple platforms only.
SymbolFileDWARFDebugMap handles the parsing of OSO stabs which are effectively a
Mach-O specific feature and is incompatible with other object file formats.

llvm-svn: 123308
2011-01-12 04:22:09 +00:00
Stephen Wilson e5b94a90ca Null terminate path returned by readlink().
llvm-svn: 123307
2011-01-12 04:21:21 +00:00
Stephen Wilson 78a4feb2c4 Log diagnostic when setting software breakpoints only on failure.
Previously we would be posting a "FAILED" message to the log channel even when
the operation succeeded.

Also, take this opportunity to add braces thus eliminating an "ambiguous else"
compiler warning.

llvm-svn: 123306
2011-01-12 04:20:03 +00:00
Greg Clayton ce7b69c3fc Bumped Xcode project version to 40 for lldb-40.
llvm-svn: 123305
2011-01-12 04:03:58 +00:00
Greg Clayton 722a0cdc95 Added the following functions to SBThread to allow threads to be suspended when a process is resumed:
bool SBThread::Suspend();
bool SBThread::Resume();
bool SBThread::IsSuspended();

llvm-svn: 123300
2011-01-12 02:25:42 +00:00
Greg Clayton 02960224aa Bumped Xcode versions to lldb-39 and debugserver-125.
llvm-svn: 123187
2011-01-10 19:28:56 +00:00
Johnny Chen 7ad4ac47ca Fix wrong test case in main.c. Oops!
llvm-svn: 123181
2011-01-10 17:44:08 +00:00
Greg Clayton 1bf55f2af7 Change the default signal setting for SIBABRT to SUPPRESS the signal. Why?
When debugging, if an expression hits a SIGABRT, it the expression ends up
completing and stopping due the the "SIGABRT". Then the next thing that runs
(another expression, or continuing the program) ends up progating the SIGABRT
and causing the parent processes to die.

We should probably think of a different solution where we suppress any signal
that resulted due to an expression, or we modifyin the UnixSignals class to
contain a row for "suppress for expression".

So the settings for SIGABRT are: suppress = true, stop = true, and 
notify = true.

llvm-svn: 123157
2011-01-10 03:47:25 +00:00
Greg Clayton dc000fbfcf Removed a few bad assert() statement regarding bitfields.
llvm-svn: 123132
2011-01-09 22:26:45 +00:00
Greg Clayton 3e06bd90b5 Put more smarts into the RegisterContext base class. Now the base class has
a method:

    void RegisterContext::InvalidateIfNeeded (bool force);

Each time this function is called, when "force" is false, it will only call
the pure virtual "virtual void RegisterContext::InvalideAllRegisters()" if
the register context's stop ID doesn't match that of the process. When the
stop ID doesn't match, or "force" is true, the base class will clear its
cached registers and the RegisterContext will update its stop ID to match
that of the process. This helps make it easier to correctly flush the register
context (possibly from multiple locations depending on when and where new
registers are availabe) without inadvertently clearing the register cache 
when it doesn't need to be.

Modified the ProcessGDBRemote plug-in to be much more efficient when it comes
to:
- caching the expedited registers in the stop reply packets (we were ignoring
  these before and it was causing us to read at least three registers every
  time we stopped that were already supplied in the stop reply packet).
- When a thread has no stop reason, don't keep asking for the thread stopped
  info. Prior to this fix we would continually send a qThreadStopInfo packet
  over and over when any thread stop info was requested. We now note the stop
  ID that the stop info was requested for and avoid multiple requests.

Cleaned up some of the expression code to not look for ClangExpressionVariable
objects up by name since they are now shared pointers and we can just look for
the exact pointer match and avoid possible errors.

Fixed an bug in the ValueObject code that would cause children to not be 
displayed.

llvm-svn: 123127
2011-01-09 21:07:35 +00:00
Greg Clayton c925f02863 Fixed the "-b" option on disassembly to always pad out the bytes with for
i386 and for x86_64 to allow 15 byte opcodes to be displayed. This outputs
clean looking disassembly when the bytes are shown.

llvm-svn: 123094
2011-01-08 22:55:04 +00:00
Greg Clayton 97a4371c96 Make sure we don't assert if we have a child with zero byte size. Also
we now say that "void *" value objects don't have children. 

llvm-svn: 123092
2011-01-08 22:26:47 +00:00
Greg Clayton 877aaa589b Made FuncUnwinders threadsafe.
Other small cleanups as well.

llvm-svn: 123088
2011-01-08 21:19:00 +00:00
Greg Clayton 710dd5aebf Spelling changes applied from lldb_spelling.diffs from Bruce Mitchener.
Thanks Bruce!

llvm-svn: 123083
2011-01-08 20:28:42 +00:00
Greg Clayton de9d0494ef Modified the stop reply packet to be able to send the thread name using the
new "hexname" key for the "key:value;" duple that is part of the packet. This
allows for thread names to contain special characters such as $ # : ; + -

Debugserver now detects if the thread name contains special characters and
sends the chars in hex format if needed.

llvm-svn: 123053
2011-01-08 03:17:57 +00:00
Greg Clayton 671cabeeb5 Fixed an issue with the UnwindLLDB code where if there were inlined stack
frames, UnwindLLDB could create the incorrect RegisterContext for a given
stack frame because it was using the frame index (not the concrete frame
index). This was causing crashes when doing backtraces through the 
SBFrame::GetFP() because a NULL register context was being returned for the
deepest stack frame.

llvm-svn: 123052
2011-01-08 01:53:06 +00:00
Johnny Chen d32110895b Blacklisted testclass STLTestCase for a known crasher <rdar://problem/8837118>.
llvm-svn: 123049
2011-01-08 01:37:33 +00:00
Greg Clayton b0848c5d91 Fixed issues with the unwinding code where the collection of FuncUnwinders
was being searched and sorted using a shared pointer as the value which means
the pointer value was what was being searched for. This means that anytime
you did a stack backtrace, the collection of FuncUnwinders doubled and then
the array or shared pointer got sorted (by pointer value), so you had an ever
increasing collection of shared pointer where a match was never found. This
means we had a ton of duplicates in this table and would cause issues after
one had been debugging for a long time.

llvm-svn: 123045
2011-01-08 00:05:12 +00:00
Greg Clayton 46595b9ae2 Added a recursive loop stress test for the unwinder. Not a real world test
by any means, but something to stress test our unwinder with 260,000+ frames
on a standard darwin thread.

llvm-svn: 123037
2011-01-07 22:10:25 +00:00
Johnny Chen 117ff9005c Modify disassemble_call_stack_python() to not rely on the "disassemble -n function_name"
command to do the disassembly.  Instead, use the Python API.

llvm-svn: 123029
2011-01-07 20:34:32 +00:00
Caroline Tice ab174c9d44 Apply patch from Bruce Mitchener to fix spelling errors.
llvm-svn: 123002
2011-01-07 17:16:03 +00:00
Greg Clayton 58be07b28c Added memory caching to lldb_private::Process. All lldb_private::Process
subclasses will automatically be able to take advantage of caching. The
cache line size is set to 512 by default.

This greatly speeds up stack backtraces on MacOSX when using the 
ProcessGDBRemote process plug-in since only about 6300 packets per second
can be sent.

Initial speedups show:

Prior to caching: 10,000 stack frames took 5.2 seconds
After caching: 10,000 stack frames in 240 ms!

About a 20x speedup!

llvm-svn: 122996
2011-01-07 06:08:19 +00:00
Greg Clayton db59823068 Added the ability for Target::ReadMemory to prefer to read from the file
cache even when a valid process exists. Previously, Target::ReadMemory would
read from the process if there was a valid one and then fallback to the
object file cache.

llvm-svn: 122989
2011-01-07 01:57:07 +00:00
Johnny Chen b13ee84c26 Print out a more meaningful exception message when/if CFBundleVersion matching failed.
llvm-svn: 122985
2011-01-07 00:17:44 +00:00
Stephen Wilson 6c0cece252 Fix a few small issues in r122981 to ensure compilation on Linux.
Also, call GetProcess instead of CalculateProcess as the latter is morally part
of the ExecutionContextScope API.

llvm-svn: 122984
2011-01-07 00:10:43 +00:00
Greg Clayton 43b4e213cb First try at patching linux for the recent RegisterContext patch. Can someone
try and build this and let me know how it goes?

llvm-svn: 122981
2011-01-06 22:35:55 +00:00
Greg Clayton 5ccbd294b2 Fixed issues with RegisterContext classes and the subclasses. There was
an issue with the way the UnwindLLDB was handing out RegisterContexts: it
was making shared pointers to register contexts and then handing out just
the pointers (which would get put into shared pointers in the thread and
stack frame classes) and cause double free issues. MallocScribble helped to
find these issues after I did some other cleanup. To help avoid any
RegisterContext issue in the future, all code that deals with them now
returns shared pointers to the register contexts so we don't end up with
multiple deletions. Also now that the RegisterContext class doesn't require
a stack frame, we patched a memory leak where a StackFrame object was being
created and leaked.

Made the RegisterContext class not have a pointer to a StackFrame object as
one register context class can be used for N inlined stack frames so there is
not a 1 - 1 mapping. Updates the ExecutionContextScope part of the 
RegisterContext class to never return a stack frame to indicate this when it
is asked to recreate the execution context. Now register contexts point to the
concrete frame using a concrete frame index. Concrete frames are all of the
frames that are actually formed on the stack of a thread. These concrete frames
can be turned into one or more user visible frames due to inlining. Each 
inlined stack frame has the exact same register context (shared via shared
pointers) as any parent inlined stack frames all the way up to the concrete 
frame itself.

So now the stack frames and the register contexts should behave much better.

llvm-svn: 122976
2011-01-06 22:15:06 +00:00
Stephen Wilson 842a9bac48 Makefile updates.
Update lib/Makefile to use current LLVM and Clang components and add the
PluginUtility library to the build.

llvm-svn: 122975
2011-01-06 22:11:47 +00:00
Stephen Wilson c08a6c15be Ignore unknown pragmas.
In particular, we are looking to ignore the "#pragma mark" construct which GCC
warns about on platforms other than Darwin.  This cleans up diagnostic output
significantly.

llvm-svn: 122974
2011-01-06 22:10:24 +00:00
Johnny Chen 849398910f Modify test_help_version() test case to be more precise in matching the version
number string as found in the resources/LLDB-info.plist file.

llvm-svn: 122930
2011-01-06 00:03:01 +00:00
Johnny Chen 64e3868cf0 Properly indent the short description of the test case to make it align with the
previously added ordinal number of the currently running test case.

llvm-svn: 122922
2011-01-05 22:50:11 +00:00