Commit Graph

2530 Commits

Author SHA1 Message Date
Greg Clayton caab74e02d Adding the DWARF parser side for assited layout where the AST context
will ask ExternalASTSource objects to help laying out a type. This is needed
because the DWARF typically doesn't contain alignement or packing attribute
values, and we need to be able to match up types that the compiler uses
in expressions.

llvm-svn: 149160
2012-01-28 00:48:57 +00:00
Johnny Chen aefcf999d2 Add an InstanceSettings::NotifyOwnerIsShuttingDown() method so that the owner can notify InstanceSettings instances
that their owner reference is no longer valid.

llvm-svn: 149145
2012-01-27 21:27:39 +00:00
Greg Clayton 9620f466af Disable the ConnectionFileDescriptor mutex for now as it is deadlocking our
test suite and I need to investigate this.

llvm-svn: 149141
2012-01-27 18:57:04 +00:00
Johnny Chen f8f0fd765e Fix typo.
llvm-svn: 149140
2012-01-27 18:53:22 +00:00
Johnny Chen 921ca5d4b8 Emit the message about putting ' -- ' between the end of command options and the raw input conditionally,
that is, only if the command object does not want completion.  An example is the "settings set" command.

llvm-svn: 149139
2012-01-27 18:49:33 +00:00
Greg Clayton 29ad7b914f Added a ModuleList::Destroy() method which will reclaim the std::vector
memory by doing a swap.

Also added a few utilty functions that can be enabled for debugging issues
with modules staying around too long when external clients still have references
to them.

llvm-svn: 149138
2012-01-27 18:45:39 +00:00
Greg Clayton ecc6116950 Enable extra error checking for debug builds in our mutexes by
watching for errors from pthread_mutex_destroy () (usually "Resource
busy" errors for when you have a mutex locked and try to destroy
it), and pthread_mutex_lock, and pthread_mutex_unlock (usually for
trying to lock an invalid mutex that might have possible already
been freed).

llvm-svn: 149135
2012-01-27 18:29:47 +00:00
Greg Clayton a73d269294 There is no need to hold onto an ExecutionContext as a member variable.
ExecutionContext objects have shared pointers to Target, Process, Thread
and Frame objects and they can end up being held onto for too long.

llvm-svn: 149133
2012-01-27 18:18:23 +00:00
Greg Clayton b26e6bebac Fixed an issue that could happen during global object destruction in our
map that tracks all live Module classes. We must leak our mutex for our
collection class as it might be destroyed in an order we can't control.

llvm-svn: 149131
2012-01-27 18:08:35 +00:00
Greg Clayton 23f7793b13 <rdar://problem/10760649>
Fixed another double file descriptor close issue that could occur when destroying a ProcessGDBRemote() object. There was a race which was detected by our fd_interposing library:

error: /Applications/Xcode.app/Contents/MacOS/Xcode (pid=55222): close (fd=60) resulted in EBADF:
0   libFDInterposing.dylib              0x00000001082be8ca close$__interposed__ + 666
1   LLDB                                0x00000001194fde91 lldb_private::ConnectionFileDescriptor::Close(int&, lldb_private::Error*) + 97
2   LLDB                                0x00000001194fddcd lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Error*) + 143
3   LLDB                                0x00000001194fe249 lldb_private::ConnectionFileDescriptor::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 835
4   LLDB                                0x00000001194fc320 lldb_private::Communication::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 634
5   LLDB                                0x000000011959c7f4 GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock(StringExtractorGDBRemote&, unsigned int) + 228
6   LLDB                                0x000000011959c6b5 GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSeconds(StringExtractorGDBRemote&, unsigned int) + 49
7   LLDB                                0x0000000119629a71 GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse(ProcessGDBRemote*, char const*, unsigned long, StringExtractorGDBRemote&) + 509
8   LLDB                                0x00000001195a4076 ProcessGDBRemote::AsyncThread(void*) + 514
9   LLDB                                0x0000000119568094 ThreadCreateTrampoline(void*) + 91
10  libsystem_c.dylib                   0x00007fff8ca028bf _pthread_start + 335
11  libsystem_c.dylib                   0x00007fff8ca05b75 thread_start + 13

fd=60 was previously closed with this event:
pid=55222: close (fd=60) => 0
0   libFDInterposing.dylib              0x00000001082be870 close$__interposed__ + 576
1   LLDB                                0x00000001194fde91 lldb_private::ConnectionFileDescriptor::Close(int&, lldb_private::Error*) + 97
2   LLDB                                0x00000001194fddcd lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Error*) + 143
3   LLDB                                0x00000001194fbf00 lldb_private::Communication::Disconnect(lldb_private::Error*) + 92
4   LLDB                                0x00000001195a2a77 ProcessGDBRemote::StopAsyncThread() + 89
5   LLDB                                0x00000001195a2bf6 ProcessGDBRemote::DoDestroy() + 310
6   LLDB                                0x00000001195f938d lldb_private::Process::Destroy() + 85
7   LLDB                                0x0000000118819b48 lldb::SBProcess::Kill() + 72
8   DebuggerLLDB                        0x0000000117264358 DBGLLDBSessionThread(void*) + 4450
9   LLDB                                0x0000000119568094 ThreadCreateTrampoline(void*) + 91
10  libsystem_c.dylib                   0x00007fff8ca028bf _pthread_start + 335
11  libsystem_c.dylib                   0x00007fff8ca05b75 thread_start + 13

fd=60 was created with this event:
pid=55222: socket (domain = 2, type = 1, protocol = 6) => fd=60
0   libFDInterposing.dylib              0x00000001082bc968 socket$__interposed__ + 600
1   LLDB                                0x00000001194fd75f lldb_private::ConnectionFileDescriptor::ConnectTCP(char const*, lldb_private::Error*) + 179
.....

llvm-svn: 149103
2012-01-27 00:46:15 +00:00
Greg Clayton 9ea3fcd845 <rdar://problem/10750012>
Remove a pseudo terminal master open and slave file descriptor that was being
used for pythong stdin. It was not hooked up correctly and was causing file
descriptor leaks.

llvm-svn: 149098
2012-01-27 00:13:27 +00:00
Greg Clayton 6efba4fc97 Fixed formats being able to be applied recursively when using:
target variable -f <format> [args]
frame variable -f <format> [args]
expression -f <format> -- expr

llvm-svn: 149080
2012-01-26 21:08:30 +00:00
Johnny Chen 9ec3c4f5a7 For Dump(Stream *s), use GetOptionsNoCreate()->GetIgnoreCount() and fix the indentation.
llvm-svn: 149002
2012-01-26 00:08:14 +00:00
Johnny Chen 29f7dff581 Typo.
llvm-svn: 148994
2012-01-25 23:08:23 +00:00
Johnny Chen 5f3bf63cac Fix a typo in the error message of the StopInfoWatchpoint class.
llvm-svn: 148876
2012-01-24 23:19:25 +00:00
Sean Callanan 175a0d04b6 Added a mechanism for the IR interpreter to return
an error along with its boolean result.  The
expression parser reports this error if the 
interpreter fails and the expression could not be
run in the target.

llvm-svn: 148870
2012-01-24 22:06:48 +00:00
Johnny Chen a5cde26b3e Minor comment change. Plus use member function instead of directly accessing member field.
llvm-svn: 148756
2012-01-24 00:11:02 +00:00
Johnny Chen fab7a91d92 Tiny refactoring to use member functions instead of directly accessing member fields.
llvm-svn: 148743
2012-01-23 23:03:59 +00:00
Johnny Chen 8cc80b2914 Followup check in for http://llvm.org/viewvc/llvm-project?rev=148491&view=rev,
where we changed the CommandObjectSettingsSet object impl to require raw command string.

Do the same for CommandObjectSettingsAppend/InsertBefore/InsertAfter classes and
add test cases for basic functionalities as well as for variable name completion.

llvm-svn: 148719
2012-01-23 19:49:28 +00:00
Greg Clayton 3af493f068 <rdar://problem/10711649>
A Small tweak to handle a zero timeout.

llvm-svn: 148617
2012-01-21 02:28:13 +00:00
Jim Ingham c668f81107 Our Read functions were taking a timeout of UINT32_MAX to mean wait forever, but then
we didn't implement that in setting the socket option.
<rdar://problem/10711649>

llvm-svn: 148616
2012-01-21 02:03:41 +00:00
Johnny Chen 5928f64e2c Followup check in for http://llvm.org/viewvc/llvm-project?rev=148491&view=rev,
where we changed the CommandObjectSettingsSet object impl to require raw command string.

Do the same for CommandObjectSettingsReplace class and add two test cases; one for
the "settings replace" command and the other to ensure that completion for variable
name still works. 

llvm-svn: 148615
2012-01-21 01:45:18 +00:00
Greg Clayton 894f82fa49 <rdar://problem/10732738>
Release more stuff in Process::Destroy().

llvm-svn: 148597
2012-01-20 23:08:34 +00:00
Johnny Chen 98aceb08f8 o CommandObjectSettingsSet.cpp:
Fix a bug where "settings set -r th" wouldn't complete.

o UserSettingsController.cpp:

  Fix a bug where "settings set target.process." wouldn't complete.

o test/functionalities/completion:

  Add various completion test cases related to 'settings set' command.

llvm-svn: 148596
2012-01-20 23:02:51 +00:00
Johnny Chen 6561d15dcb Add comment describing the interaction of WantsRawCommandString()/WantsCompletion() with the completion mechanism.
llvm-svn: 148521
2012-01-20 00:59:19 +00:00
Sean Callanan 0caa21cb25 Made IsArrayOfScalarType handle typedefs correctly.
We should ultimately introduce GetAs...Type
functions in all cases where we have Is...Type
functions that know how to look inside typedefs.

llvm-svn: 148512
2012-01-19 23:54:24 +00:00
Johnny Chen 6f99b63718 rdar://problem/10724187
http://llvm.org/viewvc/llvm-project?rev=148491&view=rev check in broke the argument completion
for "settings set th", followed by TAB.  Provide a way for commands who want raw commands to
hook into the completion mechanism.

llvm-svn: 148500
2012-01-19 22:16:06 +00:00
Jim Ingham 6657d09e8b ValueObjectRegister type value objects should obey the format in ValueAsCString.
<rdar://problem/10719481>

llvm-svn: 148494
2012-01-19 21:10:56 +00:00
Johnny Chen a28b89c700 rdar://problem/10712130
Fixed an issue where backtick char is not properly honored when setting the frame-format variable, like the following:

(lldb) settings set frame-format frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n
(lldb) settings show frame-format
frame-format (string) = "frame #${frame.index}: ${frame.pc}{ `${module.file.basename}{${function.name-with-args}${function.pc-offset}}}{` at ${line.file.basename}:${line.number}}\n"
(lldb)

o CommandObjectSettings.h/.cpp:

  Modify the command object impl to require raw command string instead of parsed command string,
  which also fixes an outstanding issue that customizing the prompt with trailing spaces doesn't
  work.

o Args.cpp:

  During CommandInterpreter::HandleCommand(), there is a PreprocessCommand phase which already
  strips/processes pairs of backticks as an expression eval step.  There's no need to treat
  a backtick as starting a quote.

o TestAbbreviations.py and change_prompt.lldb:

  Fixed incorrect test case/logic.

o TestSettings.py:

  Remove expectedFailure decorator.

llvm-svn: 148491
2012-01-19 19:22:41 +00:00
Sean Callanan 2e93a2ad21 Fixed a problem where Objective-C classes that were
originally imported from symbols for the expression
parser didn't get their superclasses set properly.

llvm-svn: 148488
2012-01-19 18:23:06 +00:00
Greg Clayton bdf3a01bb0 Allow a way to track all allocations for our intrusive ref counted pointers.
It is disabled by default, but can be enabled to track down shared pointer 
cycles.

llvm-svn: 148461
2012-01-19 04:44:00 +00:00
Greg Clayton e42ae8497f Fixed an issue with the Instruction subclasses where the strings might
be fetched too many times and the DisassemblerLLVM was appending to strings
when the opcode, mnemonic and comment accessors were called multiple times
and if any of the strings were empty.

Also fixed the test suite failures from recent Objective C modifications.

llvm-svn: 148460
2012-01-19 03:24:53 +00:00
Sean Callanan a9bc065607 Fixed a problem where maintaining the ObjCInterfaceMap
for each ObjCInterfaceDecl was imposing performance
penalties for Objective-C apps.  Instead, we now use
the normal function query mechanisms, which use the
relevant accelerator tables.

This fix also includes some modifications to the
SymbolFile which allow us to find Objective-C methods
and report their Clang Decls correctly.

llvm-svn: 148457
2012-01-19 02:17:40 +00:00
Sean Callanan b811e4bb5d Fix to ensure that methods aren't called on NULL
objects.

llvm-svn: 148450
2012-01-19 01:10:27 +00:00
Greg Clayton 278a16bb7a Added an extra way to chop up an objective C prototype and use it where necessary.
llvm-svn: 148445
2012-01-19 00:52:59 +00:00
Greg Clayton 7c8104227e Be sure to use the one and only trusted source for chopping up
objective C class names when extracting the class name, selector and
name without category for objective C full class and instance method
names.

llvm-svn: 148435
2012-01-18 23:40:49 +00:00
Greg Clayton 5b6889b1f6 Fixed an issue in the debugger format strings that include "${function.name-with-args}"
where we grabbed the variable list size from the wrong list (we needed it
from "args" and we were getting it from "variable_list_sp").

llvm-svn: 148425
2012-01-18 21:56:18 +00:00
Greg Clayton 68221ec3dc Fixed an issue where we might not find the one true ObjC definition. Now we do things
much smarter by extracting search results more efficiently and by properly obeying the 
must_be_implementation bool in the SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE()
function.

llvm-svn: 148413
2012-01-18 20:58:12 +00:00
Greg Clayton 32720b51e2 <rdar://problem/9731573>
Fixed two double "int close(int fd)" issues found by our file descriptor
interposing library on darwin:

The first is in SBDebugger::SetInputFileHandle (FILE *file, bool transfer_ownership)
where we would give our FILE * to a lldb_private::File object member variable and tell
it that it owned the file descriptor if "transfer_ownership" was true, and then we
would also give it to the communication plug-in that waits for stdin to come in and
tell it that it owned the FILE *. They would both try and close the file.

The seconds was when we use a file descriptor through ConnectionFileDescriptor 
where someone else is creating a connection with ConnectionFileDescriptor and a URL
like: "fd://123". We were always taking ownwership of the fd 123, when we shouldn't
be. There is a TODO in the comments that says we should allow URL options to be passed
to be able to specify this later (something like: "fd://123?transer_ownership=1"), but
we can get to this later.

llvm-svn: 148201
2012-01-14 20:47:38 +00:00
Greg Clayton ccbc08e6ae <rdar://problem/10684141>
When the lldb_private::Debugger goes away, it should cleanup all
of its targets.

llvm-svn: 148189
2012-01-14 17:04:19 +00:00
Sean Callanan cbbe3ac4a9 I made two major improvements to the way the
master AST importer imports types.

- First, before importing the definition of a
  Decl from its source, notify the underlying
  importer of the source->destination mapping.
  Especially for anonymous strucutres that are
  otherwise hard to unique in the target AST
  context, this hint is very helpful.

- When deporting a type or Decl from one
  ASTContext to another (deporting occurs in
  the case of moving result types from the
  parser's AST context to the result AST
  context), don't forget their origin if the
  origin is the original debug information.

llvm-svn: 148152
2012-01-13 22:55:55 +00:00
Sean Callanan ba5be17e7d Only create new ASTImporters on demand, not
proactively.

llvm-svn: 148146
2012-01-13 22:19:53 +00:00
Sean Callanan 7282e2acf4 If the name of a struct or union is NULL in the
debug info, call it anonymous.  This isn't
perfect, because Clang actually considers the
following struct not to be anonymous:
–
struct {
  int x;
  int y;
} g_foo;
-
but DWARF doesn't make the distinction.

llvm-svn: 148145
2012-01-13 22:10:18 +00:00
Sean Callanan a6e61a7820 Fixed some logging in the AST source and added
more information.

llvm-svn: 148144
2012-01-13 22:05:55 +00:00
Greg Clayton 6d3dbf5161 Added a new thread and frame format that can be used to display a function
name + arguments when the data is available. It seems to work really well, 
but some more testing is needed before we make this on by default.

The new function format name is:

 ${function.name-with-args}

To see how to use these formats see the website:

    http://lldb.llvm.org/formats.html

Here is a sample backtrace of debugging LLDB with LLDB using this new format
value:

(lldb) thread backtrace all
* thread #1: tid = 0x2203, 0x00007fff88a17bca libsystem_kernel.dylib __psynch_cvwait + 10, stop reason = signal SIGINT, name = <lldb.driver.main-thread>, queue = com.apple.main-thread
    frame #0: 0x00007fff88a17bca libsystem_kernel.dylib __psynch_cvwait + 10
    frame #1: 0x00007fff884ae274 libsystem_c.dylib _pthread_cond_wait + 840
    frame #2: 0x00000001010778ea LLDB lldb_private::Condition::Wait(this=0x0000000104846770, mutex=0x0000000104846730, abstime=0x0000000000000000, timed_out=0x00007fff5fbfdea7) + 138 at Condition.cpp:92
    frame #3: 0x0000000101244c21 LLDB lldb_private::Predicate<bool>::WaitForValueEqualTo(this=0x0000000104846728, value=true, abstime=0x0000000000000000, timed_out=0x00007fff5fbfdea7) + 209 at Predicate.h:317
    frame #4: 0x0000000100f6eeb2 LLDB lldb_private::Listener::WaitForEventsInternal(this=0x0000000104846660, timeout=0x0000000000000000, broadcaster=0x0000000000000000, broadcaster_names=0x0000000000000000, num_broadcaster_names=0x00000000, event_type_mask=0x00000000, event_sp=0x00007fff5fbfe030) + 386 at Listener.cpp:388
    frame #5: 0x0000000100f6f231 LLDB lldb_private::Listener::WaitForEvent(this=0x0000000104846660, timeout=0x0000000000000000, event_sp=0x00007fff5fbfe030) + 81 at Listener.cpp:436
    frame #6: 0x0000000100098dcd LLDB lldb::SBListener::WaitForEvent(this=0x00007fff5fbff0f0, timeout_secs=0xffffffff, event=0x00007fff5fbfe430) + 685 at SBListener.cpp:181
    frame #7: 0x000000010000628c lldb Driver::MainLoop(this=0x00007fff5fbff620) + 5244 at Driver.cpp:1325
    frame #8: 0x0000000100006ca3 lldb main(argc=1, argv=0x00007fff5fbff758, envp=0x00007fff5fbff768) + 419 at Driver.cpp:1460
    frame #9: 0x0000000100000d54 lldb start + 52

  thread #3: tid = 0x2703, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = <lldb.comm.debugger.input>
    frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10
    frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x000000010524d040, timeout_usec=0x004c4b40, error_ptr=0x0000000105640a18) + 722 at ConnectionFileDescriptor.cpp:542
    frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x000000010524d040, dst=0x0000000105640a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105640a14, error_ptr=0x0000000105640a18) + 301 at ConnectionFileDescriptor.cpp:273
    frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000104846270, dst=0x0000000105640a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105640a14, error_ptr=0x0000000105640a18) + 167 at Communication.cpp:317
    frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000104846270) + 327 at Communication.cpp:344
    frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001045f6650) + 227 at Host.cpp:549
    frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335
    frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13

  thread #4: tid = 0x2803, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = <lldb.comm.driver.editline>
    frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10
    frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x0000000105700370, timeout_usec=0x004c4b40, error_ptr=0x00000001056c3a18) + 722 at ConnectionFileDescriptor.cpp:542
    frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x0000000105700370, dst=0x00000001056c3a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x00000001056c3a14, error_ptr=0x00000001056c3a18) + 301 at ConnectionFileDescriptor.cpp:273
    frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000105700000, dst=0x00000001056c3a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x00000001056c3a14, error_ptr=0x00000001056c3a18) + 167 at Communication.cpp:317
    frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000105700000) + 327 at Communication.cpp:344
    frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x0000000105700430) + 227 at Host.cpp:549
    frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335
    frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13

  thread #5: tid = 0x2903, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = <lldb.comm.driver.editline_output>
    frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10
    frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x00000001057178f0, timeout_usec=0x004c4b40, error_ptr=0x0000000105980a18) + 722 at ConnectionFileDescriptor.cpp:542
    frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x00000001057178f0, dst=0x0000000105980a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105980a14, error_ptr=0x0000000105980a18) + 301 at ConnectionFileDescriptor.cpp:273
    frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000105717580, dst=0x0000000105980a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105980a14, error_ptr=0x0000000105980a18) + 167 at Communication.cpp:317
    frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000105717580) + 327 at Communication.cpp:344
    frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001057179b0) + 227 at Host.cpp:549
    frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335
    frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13

  thread #6: tid = 0x2a03, 0x00007fff88a18af2 libsystem_kernel.dylib read + 10, name = <lldb.driver.commandline_io>
    frame #0: 0x00007fff88a18af2 libsystem_kernel.dylib read + 10
    frame #1: 0x0000000100050c3b libedit.3.dylib read_init + 247
    frame #2: 0x0000000100050e96 libedit.3.dylib el_wgetc + 155
    frame #3: 0x000000010005115d libedit.3.dylib el_wgets + 578
    frame #4: 0x000000010005debc libedit.3.dylib el_gets + 37
    frame #5: 0x000000010000d409 lldb IOChannel::LibeditGetInput(this=0x0000000105700490, new_line=0x0000000105a03db0) + 89 at IOChannel.cpp:311
    frame #6: 0x000000010000d8b6 lldb IOChannel::Run(this=0x0000000105700490) + 806 at IOChannel.cpp:391
    frame #7: 0x000000010000d57d lldb IOChannel::IOReadThread(ptr=0x0000000105700490) + 29 at IOChannel.cpp:345
    frame #8: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001057179f0) + 227 at Host.cpp:549
    frame #9: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335
    frame #10: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13
(lldb) 

llvm-svn: 148110
2012-01-13 08:39:16 +00:00
Greg Clayton d66945ae3d <rdar://problem/10688864>
Fixed the new __apple_types to be able to accept a DW_TAG_structure_type
forward declaration and then find a DW_TAG_class_type definition, or vice
versa.

llvm-svn: 148097
2012-01-13 05:38:24 +00:00
Jim Ingham bc2f918200 Don't set breakpoints independently comp unit by comp unit, but look over all the file & line matches
and only pick the "best" ones.
<rdar://problem/10685990>

llvm-svn: 148087
2012-01-13 02:04:05 +00:00
Jim Ingham 18f4629c78 Discriminate between the lldb_private::Type's for ObjC Classes that come from debug info, and those that
are made up from the ObjC runtime symbols.  For now the latter contain nothing but the fact that the name
describes an ObjC class, and so are not useful for things like dynamic types.

llvm-svn: 148059
2012-01-12 22:45:31 +00:00
Jim Ingham 5cfbe4aa53 Fix a comment typo.
llvm-svn: 148057
2012-01-12 22:42:34 +00:00
Jim Ingham 50b3d507bd Let the Module FindType do the stripping of namespace components, that's not expensive
and doing it both at the ModuleList and Module levels means we look 4 times for a negative
search.  Also, don't do the search for the stripped name if that is the same as the original
one.

llvm-svn: 148054
2012-01-12 22:35:29 +00:00
Greg Clayton 44435ed07a Big change in the way ObjectFile file contents are managed. We now
mmap() the entire object file contents into memory with MAP_PRIVATE.
We do this because object file contents can change on us and currently
this helps alleviate this situation. It also make the code for accessing
object file data much easier to manage and we don't end up opening the
file, reading some data and closing the file over and over.

llvm-svn: 148017
2012-01-12 05:25:17 +00:00
Greg Clayton c7f03b6155 <rdar://problem/10681814>
Fix DWARF parsing issue we can run into when using llvm-gcc based dSYM files.

Also fix the parsing of objective C built-in types (Class, id and SEL) so
they don't parse more information that is not needed due to the way they
are represented in DWARF.

llvm-svn: 148016
2012-01-12 04:33:28 +00:00
Jim Ingham c07fe69850 Don't dereference the oso_dwarf without checking for NULL.
llvm-svn: 148005
2012-01-12 01:45:53 +00:00
Greg Clayton fa8c004aba Revert some changes I did for logging that affected the ability to
load .o files in BSD archive parsing.

llvm-svn: 147987
2012-01-12 01:21:31 +00:00
Sean Callanan ee458a7785 After thinking about it, it doesn't seem right
to make assumptions if the type is unsized.  We
just give up (and let the JIT handle it) instead.

llvm-svn: 147915
2012-01-11 02:23:25 +00:00
Jim Ingham c354928786 Don't assert but report & return a NULL type if we end up parsing a type we are in the middle of parsing.
llvm-svn: 147914
2012-01-11 02:21:12 +00:00
Greg Clayton 8b35334e0c Fixed a missing space when reporting errors and warning through the module
and also print out the full path and architecture.

llvm-svn: 147908
2012-01-11 01:59:18 +00:00
Sean Callanan 285e4b22f5 If the size of a type can't be determined, default
to assume it's of pointer size.

llvm-svn: 147906
2012-01-11 01:36:21 +00:00
Greg Clayton 7d7850af64 Since clang modifies .o files in place, use MAP_PRIVATE as it seems
to fix the issues we run into on darwin even though the docs don't
seems to say it will.

llvm-svn: 147835
2012-01-10 02:53:13 +00:00
Jim Ingham aa1bc80f5d Don't call lldb_private::Process::GetLoadAddressPermissions to sanity check the unwind addresses
when you already know that the address is contained in a bona fide function.  This can be a 
slow call.

llvm-svn: 147829
2012-01-10 02:14:47 +00:00
Greg Clayton e51363857f When doing a "target modules lookup --address <addr>", show the file address
in the module when dumping the information in addition to all info that we
were previously showing.

llvm-svn: 147815
2012-01-10 00:25:18 +00:00
Greg Clayton aecb12b5c6 Make a log timer for the BSD archive creation so we can track the time it
takes to open and index BSD archives.

llvm-svn: 147813
2012-01-09 23:59:30 +00:00
Greg Clayton 01a82d1918 Fixed a return value problem with the new ABI::FixCodeAddress () function:
it was checked in as:
 virtual bool ABI::FixCodeAddress (lldb::addr_t pc);

when it should have been:

virtual lldb::addr_t ABI::FixCodeAddress (lldb::addr_t pc);


 

llvm-svn: 147790
2012-01-09 19:23:34 +00:00
Greg Clayton 4abd6eaaa0 <rdar://problem/10645694>
Fixed an ARM backtracing issue where if the previous frame was a thumb
function and it was a tail call so that the current frame returned to
an address that would fall into the next function, we would use the
next function as the basis for how we unwound the previous frame's
registers and of course get things wrong. We now fix the PC code
address using the current ABI plug-in, and the ARM ABI plug-in has
been modified to correctly fix the code address. So when we do the
symbol context lookup, instead of taking an address like 0x1001 and
decrementing 1, and looking up the symbol context for a frame, we
now correctly fix 0x1001 to 0x1000, then decrement that by 1 to
get the correct symbol context.

I added a bunch more logging to "log enable lldb uwnind" to help
us in the future. We now log the PC, FP and SP (if they are available),
and we also dump the "active_row" that we find for unwinding a frame.

llvm-svn: 147747
2012-01-08 05:54:35 +00:00
Greg Clayton 6e527321b3 <rdar://problem/10660369>
Fixed the default ARM regiter set to be able to refer to "r7" as "fp" for the apple debugserver.

llvm-svn: 147746
2012-01-08 05:49:22 +00:00
Greg Clayton 48ca8b8fe2 Recursive calls to ValueObject::GetSummaryAsCString() are causing crashes.
The previous approach to controlling the recursion was doing it from
outside the function which is not reliable. Now it is being done inside
the function. This might not solve all of the crashes that we were seeing
since there are other functions that clear the bit that indicates that
the summary is in the process of being generated, but it might solve some.

llvm-svn: 147741
2012-01-07 20:58:07 +00:00
Greg Clayton 11c99162c4 <rdar://problem/10658091>
Fixed dynamic types for objective C to not try and make everything dynamic including base classes.

llvm-svn: 147722
2012-01-07 04:21:42 +00:00
Greg Clayton 0f28986a54 Patch from Enrico Granata that moves SBData related functions into the SBData
class instead of requiring a live process in order to be able to create useful
SBData objects.

llvm-svn: 147702
2012-01-07 00:45:50 +00:00
Sean Callanan d1a5e01ff9 Fixed a bug where the DWARF location expression
parser was creating malformed resuls.  When the
location of a variable is computed by reading a
register and adding an offset, we shouldn't say
that the variable's value is located in that
register.  This was confusing the expression
parser when trying to read a variable captured
by a block.

llvm-svn: 147668
2012-01-06 18:24:47 +00:00
Greg Clayton 4017fa399b <rdar://problem/10652336>
Fixed a crasher when trying to load an expression prefix file:

% touch /tmp/carp.txt
% xcrun lldb
(lldb) settings set target.expr-prefix /tmp/carp.txt
Segmentation fault

llvm-svn: 147646
2012-01-06 02:01:06 +00:00
Greg Clayton 1a0be3b1f2 <rdar://problem/10649734>
Fixed an issue where the python interpreter could deadlock LLDB.

llvm-svn: 147640
2012-01-06 00:47:38 +00:00
Johnny Chen 39c6d0f9ae http://llvm.org/bugs/show_bug.cgi?id=11619
Allow creating SBData values from arrays or primitives in Python

Patch submitted by Enrico Granata.

llvm-svn: 147639
2012-01-06 00:46:12 +00:00
Greg Clayton 650e3b014e <rdar://problem/10647191>
Removed an extra call to close that was causing problems and also
now use the Host::File class to open the file.

llvm-svn: 147638
2012-01-06 00:43:54 +00:00
Johnny Chen b49440fa92 http://llvm.org/bugs/show_bug.cgi?id=11618
lldb::SBValue::AddressOf does not work on dereferenced registers in synthetic children provider

Patch submitted by Enrico Granata.

llvm-svn: 147637
2012-01-06 00:35:38 +00:00
Greg Clayton ae920b69f5 We finalized on the new .apple_types accelerator table format where we don't
emit fully qualified names, so now we make sure the DW_TAG values match and
still lookup using the basename.

llvm-svn: 147634
2012-01-06 00:17:16 +00:00
Johnny Chen e7526b7daf http://llvm.org/bugs/show_bug.cgi?id=11715
comma at end of enumerator list

llvm-svn: 147633
2012-01-06 00:05:01 +00:00
Johnny Chen 3e8cd274e8 Fix indentation.
llvm-svn: 147629
2012-01-05 23:51:37 +00:00
Johnny Chen 2a189134b9 Add back the file I wrongly deleted in r147613.
llvm-svn: 147627
2012-01-05 23:50:14 +00:00
Johnny Chen 9ed5b49c45 Fix incomplete commit of http://llvm.org/viewvc/llvm-project?rev=147609&view=rev:
This patch combines common code from Linux and FreeBSD into
a new POSIX platform.  It also contains fixes for 64bit FreeBSD.

The patch is based on changes by Mark Peek <mp@FreeBSD.org> and
"K. Macy" <kmacy@freebsd.org> in their github repo located at
https://github.com/fbsd/lldb.

llvm-svn: 147613
2012-01-05 21:48:15 +00:00
Johnny Chen 30213ffc28 This patch combines common code from Linux and FreeBSD into
a new POSIX platform.  It also contains fixes for 64bit FreeBSD.

The patch is based on changes by Mark Peek <mp@FreeBSD.org> and
"K. Macy" <kmacy@freebsd.org> in their github repo located at
https://github.com/fbsd/lldb.

llvm-svn: 147609
2012-01-05 19:17:38 +00:00
Greg Clayton e38a5edd9e Added code in the Host layer that can report system log messages
so that we don't have "fprintf (stderr, ...)" calls sprinkled everywhere.
Changed all needed locations over to using this.

For non-darwin, we log to stderr only. On darwin, we log to stderr _and_
to ASL (Apple System Log facility). This will allow GUI apps to have a place
for these error and warning messages to go, and also allows the command line
apps to log directly to the terminal.

llvm-svn: 147596
2012-01-05 03:57:59 +00:00
Sean Callanan c1b312a5c3 Fixed a potential hang while trying to execute
a function in the inferior.

llvm-svn: 147592
2012-01-05 02:00:14 +00:00
Johnny Chen cdc21d4c85 Add comment explaining the default constructor (ArchSpec) used in CreateTarget().
llvm-svn: 147590
2012-01-05 01:26:01 +00:00
Sean Callanan 31a8d051dd Fixed a dangling pointer bug associated with the
result variable on a "finish" statement.  The
ownership of the result value was not being properly
assigned to the newly-created persistent result
variable; now it is.

llvm-svn: 147587
2012-01-05 01:11:09 +00:00
Greg Clayton 96c09687bc <rdar://problem/10507811>
Be better at detecting when DWARF changes and handle this more
gracefully than asserting and exiting.

Also fixed up a bunch of system calls that weren't properly checking
for EINTR.

llvm-svn: 147559
2012-01-04 22:56:43 +00:00
Sean Callanan 3441d5ae34 Added logging to track when the IR interpreter
resolves values in registers.

llvm-svn: 147551
2012-01-04 21:42:46 +00:00
Sean Callanan a4c6ad1914 Fixed the help text for raw commands like "expr"
to include -- in sample command lines.  Now LLDB
prints

  expression [-f <format>] -- <expr>

instead of

  expression [-f <format>] <expr>

and also adds a new example line:

  expression <expr>

to show that in the absense of arguments the --
can be ommitted.

llvm-svn: 147540
2012-01-04 19:11:25 +00:00
Sean Callanan 06d3d01295 Instead of blindly printing a string when
eFormatCString is specified, I have made
DataExtractor::Dump properly escape the string.
This prevents LLDB from printing characters
that confuse terminals.

llvm-svn: 147536
2012-01-04 17:36:30 +00:00
Greg Clayton 77ccca718d <rdar://problem/10368163>
Watch for empty symbol tables by doing a lot more error checking on
all mach-o symbol table load command values and data that is obtained.
This avoids a crash that was happening when there was no string table.

llvm-svn: 147358
2011-12-30 00:32:24 +00:00
Greg Clayton 360f9a7663 <rdar://problem/10551280>
Fixed a crasher that can occur when parsing invalid DWARF.

llvm-svn: 147350
2011-12-29 19:47:20 +00:00
Greg Clayton d344484865 <rdar://problem/10568905>
Fixed an issue where our new accelerator tables could cause a crash
when we got a full 32 bit hash match, yet a C string mismatch.

We had a member variable in DWARFMappedHash::Prologue named 
"min_hash_data_byte_size" the would compute the byte size of HashData
so we could skip hash data efficiently. It started out with a byte size
value of 4. When we read the table in from disk, we would clear the
atom array and read it from disk, and the byte size would still be set
to 4. We would then, as we read each atom from disk, increment this count. 
So the byte size of the HashData was off, which means when we get a lookup
whose 32 bit hash does matches, but the C string does NOT match (which is
very very rare), then we try and skip the data for that hash and we would
add an incorrect offset and get off in our parsing of the hash data and 
cause this crash. 

To fix this I added a few safeguards:
1 - I now correctly clear the hash data size when we reset the atom array using the new DWARFMappedHash::Prologue::ClearAtoms() function. 
2 - I now correctly always let the AppendAtom() calculate the byte size of the hash (before we were doing things manually some times, which was correct, but not good)
3 - I also track if the size of each HashData is a fixed byte size or not, and "do the right thing" when we need to skip the data.
4 - If we do get off in the weeds, then I make sure to return an error and stop any further parsing from happening. 

llvm-svn: 147334
2011-12-29 02:58:31 +00:00
Greg Clayton dcad5021d4 <rdar://problem/10546739>
Fixed SBValue::GetValueAsUnsigned() and SBValue::GetValueAsSigned() calls to
work for bitfields.

llvm-svn: 147332
2011-12-29 01:26:56 +00:00
Greg Clayton f97c521368 Centralize the code the reads the CFI so that we always log.
llvm-svn: 147330
2011-12-29 00:05:26 +00:00
Greg Clayton d2c46a6e39 Save a little bit of memory that was being reserved in a UniqueCStringMap
vector that can be sized to fit.

llvm-svn: 147324
2011-12-28 22:24:04 +00:00
Jim Ingham 6aa664641e Sanity check the data I am going to read from the extractor to avoid asserting.
llvm-svn: 147214
2011-12-23 00:57:42 +00:00
Johnny Chen 3f0b90dcd0 rdar://problem/10216227
LLDB (python bindings) Crashing in lldb::SBDebugger::DeleteTarget(lldb::SBTarget&)

Need to check the validity of (SBTarget&)target passed to SBDebugger::DeleteTarget()
before calling target->Destroy().

llvm-svn: 147213
2011-12-23 00:53:45 +00:00
Jim Ingham 8570abdc56 Fixed a thinko when returning a struct like {short a; short b; short c; float d}.
llvm-svn: 147209
2011-12-23 00:30:10 +00:00
Sean Callanan 694e244176 Added checking to prevent a rare crash when getting
the name for an external variable in the IR.

llvm-svn: 147178
2011-12-22 21:24:49 +00:00
Jim Ingham ef65160016 Improve the x86_64 return value decoder to handle most structure returns.
Switch from GetReturnValue, which was hardly ever used, to GetReturnValueObject
which is much more convenient.
Return the "return value object" as a persistent variable if requested.

llvm-svn: 147157
2011-12-22 19:12:40 +00:00
Jim Ingham b7c91a27fb Add check for non-NULL Variable with a NULL Type.
llvm-svn: 147149
2011-12-22 17:03:37 +00:00
Sean Callanan 960534c866 Made IRForTarget error out correctly when it can't
complete the result type, preventing crashes later.

llvm-svn: 147107
2011-12-21 23:44:05 +00:00
Sean Callanan 20bb3aa53a The "desired result type" code in the expression
parser has hitherto been an implementation waiting
for a use.  I have now tied the '-o' option for
the expression command -- which indicates that the
result is an Objective-C object and needs to be
printed -- to the ExpressionParser, which
communicates the desired type to Clang.

Now, if the result of an expression is determined
by an Objective-C method call for which there is
no type information, that result is implicitly
cast to id if and only if the -o option is passed
to the expression command.  (Otherwise if there
is no explicit cast Clang will issue an error.
This behavior is identical to what happened before
r146756.)

Also added a testcase for -o enabled and disabled.

llvm-svn: 147099
2011-12-21 22:22:58 +00:00
Sean Callanan 5bc5a76d9b Fixed a bug in the ASTImporter that affects
types that have been imported multiple times.

The discussion below uses this diagram:

ASTContext     A      B      C
Decl           Da     Db     Dc
ASTImporter    \-Iab-/\-Iac-/
               \-----Iac----/

When a Decl D is imported from ASTContext A to
ASTContext B, the ASTImporter Iab records the
pair <Da, Db> in a DenseMap.  That way, if Iab
ever encounters Da again (for example, as the
DeclContext for another Decl), it can use the
imported version.  This is not an optimization,
it is critical: if I import the field "st_dev"
as part of importing "struct stat," the field
must have DeclContext equal to the parent
structure or we end up with multiple different
Decls containing different parts of "struct
stat."  "struct stat" is imported once and
recorded in the DenseMap; then the ASTImporter
finds that same version when looking for the
DeclContext of "st_dev."

The bug arises when Db is imported into another
ASTContext C and ASTContext B goes away.  This
often occurs when LLDB produces result variables
for expressions.  Ibc is aware of the transport
of Db to Dc, but a brand new ASTImporter, Iac,
is responsible for completing Dc from its source
upon request.  That ASTImporter has no mappings,
so it will produce a clone of Dc when attempting
to import its children.  That means that type
completion operations on Dc will fail.

The solution is to create Iac as soon as Ibc
imports D from B to C, and inform Iac of the
mapping between Da and Dc.  This allows type
completion to happen correctly.

llvm-svn: 147016
2011-12-20 23:55:47 +00:00
Johnny Chen 50660440a1 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add a NULL check for SBValue.CreateValueFromExpression().

llvm-svn: 146954
2011-12-20 01:52:44 +00:00
Johnny Chen 3ac503e042 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add a NULL check for SBTarget.AttachToProcessWithName() so it will not hang.

llvm-svn: 146948
2011-12-20 01:22:03 +00:00
Johnny Chen 9530770bd6 Remove dead code found.
llvm-svn: 146936
2011-12-20 00:58:20 +00:00
Johnny Chen 4f8189bc6b Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBStream APIs.

llvm-svn: 146934
2011-12-20 00:41:28 +00:00
Johnny Chen 1cbbdac108 Minor format update (no semantic change).
llvm-svn: 146930
2011-12-20 00:04:58 +00:00
Johnny Chen fee6e493b0 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBDebugger APIs.

llvm-svn: 146917
2011-12-19 22:51:27 +00:00
Johnny Chen a715452757 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBCommandReturnObject.AppendMessage().

llvm-svn: 146911
2011-12-19 21:36:23 +00:00
Johnny Chen 872e062566 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBCommandInterpreter APIs.

llvm-svn: 146909
2011-12-19 21:16:29 +00:00
Jim Ingham 5d3bca4ec3 Add needed Clear methods.
<rdar://problem/10596340>

llvm-svn: 146902
2011-12-19 20:39:44 +00:00
Johnny Chen 4efffd9ae5 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBModule and SBSection APIs.

llvm-svn: 146899
2011-12-19 20:16:22 +00:00
Sean Callanan bfb7c68b5f Added some strength to the checks that prevent
"id" from being found by the parser as an
externally-defined type.  Before, "id" would
sometimes make it through if it was defined in
a namespace, but this sometimes caused
confusion, for example when it conflicted with
std::locale::id.

llvm-svn: 146891
2011-12-19 19:38:39 +00:00
Johnny Chen 290fa41bf6 Fixed code rot pointed out by Jim.
SBThread::GetStopReasonDataCount/GetStopReasonDataAtIndex() need to handle eStopReasonWatchpoint.

llvm-svn: 146812
2011-12-17 02:07:52 +00:00
Jim Ingham 73ca05a2a0 Add the ability to capture the return value in a thread's stop info, and print it
as part of the thread format output.
Currently this is only done for the ThreadPlanStepOut.
Add a convenience API ABI::GetReturnValueObject.
Change the ValueObject::EvaluationPoint to BE an ExecutionContextScope, rather than
trying to hand out one of its subsidiary object's pointers.  That way this will always
be good.

llvm-svn: 146806
2011-12-17 01:35:57 +00:00
Greg Clayton 3cac132d05 Modified LLDB to be able to handle our updated __apple_types accelerator tables
which have the dwarf DIE tag (DW_TAG_XXX enum) and TypeFlags for each type.

llvm-svn: 146802
2011-12-17 01:16:39 +00:00
Jim Ingham 105d7234df Remove an unnecessary #include.
llvm-svn: 146798
2011-12-17 00:58:46 +00:00
Johnny Chen b456b792e0 http://llvm.org/bugs/show_bug.cgi?id=11588
valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider

Patch from Enrico Granata:

The problem was that the frozen object created by the expression parser was a copy of the contents of the StgClosure, rather than a pointer to it. Thus, the expression parser was correctly computing the result of the arithmetic&cast operation along with its address, but only saving it in the live object. This meant that the frozen copy acted as an address-less variable, hence the problem.

The fix attached to this email lets the expression parser store the "live address" in the frozen copy of the address when the object is built without a valid address of its own.
Doing so, along with delegating ValueObjectConstResult to calculate its own address when necessary, solves the issue. I have also added a new test case to check for regressions in this area, and checked that existing test cases pass correctly.

llvm-svn: 146768
2011-12-16 23:04:52 +00:00
Sean Callanan bb12004c38 Updated Clang to take an enhancement to the way
we handle Objective-C method calls.  Currently,
LLDB treats the result of an Objective-C method
as unknown if the type information doesn't have
the method's signature.  Now Clang can cast the
result to id if it isn't explicitly cast.

I also added a test case for this, as well as a
fix for a type import problem that this feature
exposed.

llvm-svn: 146756
2011-12-16 21:06:35 +00:00
Greg Clayton b5c39fe9cc Handle all of the "thumb" target triple architecture variants that llvm
handles.

llvm-svn: 146746
2011-12-16 18:15:52 +00:00
Jason Molenda 9d828ac0aa When we're unwinding out of frame 0 and we end up with a bogus frame
1 -- an address pointing off into non-executable memory -- don't
abort the unwind.  We'll use the ABI's default UnwindPlan to try
to get out of frame 1 and on many platforms with a standard frame
chain stack layout we can get back on track and get a valid frame
2.  This preserves the lldb behavior to-date; the change last week
to require the memory region to be executable broke it.

I'd like to mark this frame specially when displayed to the user;
I tried to override the places where the frame's pc value is returned
to change it to a sentinel value (e.g. LLDB_INVALID_ADDRESS) but
couldn't get that to work cleanly so I backed that part out for
now.  When this happens we'll often miss one of the user's actual
frames, the one that's of most interest to the user, so I'd like
to make this visually distinctive.

Note that a frame in non-executable memory region is only allowed
for frame 1.  After that we should be solid on the unwind and any
pc address in non-executable memory indicates a failure and we
should stop unwinding.

llvm-svn: 146723
2011-12-16 04:30:31 +00:00
Jim Ingham 30b74fa886 Remove unnecessary #include.
llvm-svn: 146717
2011-12-16 00:46:12 +00:00
Jim Ingham 918533bcfe Fix a bug where when debugging with .o files, we end up with two symbols for each real OBJC_CLASS_$_whatever, one of which is correctly classified as an ObjCClass symbol, and the other is just a data symbol. This was messing up the ObjC dynamic type detection.
<rdar://problem/10589527>

llvm-svn: 146712
2011-12-16 00:05:58 +00:00
Greg Clayton f9322415dc <rdar://problem/10584789>
Added a static memory pressure function in SBDebugger:

    void SBDebugger::MemoryPressureDetected ()

This can be called by applications that detect memory pressure to cause LLDB to release cached information.

llvm-svn: 146640
2011-12-15 04:38:41 +00:00
Greg Clayton e91b7957b2 Expose new read memory fucntion through python in SBProcess:
size_t
    SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);

    uint64_t
    SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);

    lldb::addr_t
    SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &error);

These ReadCStringFromMemory() has some SWIG type magic that makes it return the
python string directly and the "buf" is not needed:

error = SBError()
max_cstr_len = 256
cstr = lldb.process.ReadCStringFromMemory (0x1000, max_cstr_len, error)
if error.Success():
    ....

The other two functions behave as expteced. This will make it easier to get integer values
from the inferior process that are correctly byte swapped. Also for pointers, the correct
pointer byte size will be used.

Also cleaned up a few printf style warnings for the 32 bit lldb build on darwin.

llvm-svn: 146636
2011-12-15 03:14:23 +00:00
Johnny Chen 95873a68f4 http://llvm.org/bugs/show_bug.cgi?id=11579
lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds

SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type
before using it.  Add a test case.

llvm-svn: 146629
2011-12-15 01:55:36 +00:00
Sean Callanan 50952e9571 I have added a function to SBTarget that allows
clients to disassemble a series of raw bytes as
demonstrated by a new testcase.

In the future, this API will also allow clients
to provide a callback that adds comments for
addresses in the disassembly.

I also modified the SWIG harness to ensure that
Python ByteArrays work as well as strings as
sources of raw data.

llvm-svn: 146611
2011-12-14 23:49:37 +00:00
Jason Molenda 4f6f5f9cd2 On Mac OS X the Objective-C runtime (libobjc) has many critical
dispatch functions that are implemented in hand-written assembly.
There is also hand-written eh_frame instructions for unwinding
from these functions.

Normally we don't use eh_frame instructions for the currently
executing function, prefering the assembly instruction profiling
method.  But in these hand-written dispatch functions, the
profiling is doomed and we should use the eh_frame instructions.

Unfortunately there's no easy way to flag/extend the eh_frame/debug_frame
sections to annotate if the unwind instructions are accurate at
all addresses ("asynchronous") or if they are only accurate at locations
that can throw an exception ("synchronous" and the normal case for 
gcc/clang generated eh_frame/debug_frame CFI).

<rdar://problem/10508134>

llvm-svn: 146551
2011-12-14 04:22:18 +00:00
Johnny Chen c6770763e6 http://llvm.org/bugs/show_bug.cgi?id=11560 lldb::SBTarget::FindFirstType crashes when passed None
Add null checks to several functions.  Plus add test scenario for passing None to SBTarget.FindFirstType(None) and friends.

llvm-svn: 146540
2011-12-14 01:43:31 +00:00
Sean Callanan fc4f2fb0da This commit is the result of a general audit of
the expression parser to locate instances where
dyn_cast<>() and isa<>() are used on types, and
replace them with getAs<>() as appropriate.

The difference is that dyn_cast<>() and isa<>()
are essentially LLVM/Clang's equivalent of RTTI
-- that is, they try to downcast the object and
return NULL if they cannot -- but getAs<>() can
traverse typedefs to perform a semantic cast.

llvm-svn: 146537
2011-12-14 01:13:04 +00:00
Jason Molenda 87698349b3 Add two new memory region based checks to the Unwinder:
Check that the pc value for frames up the stack is in a
mapped+executable region of memory.

Check that the stack pointer for frames up the stack is
in a mapped+readable region of memory.

If the unwinder ever makes a mistake walking the stack,
these checks will help to keep it from going too far into
the weeds.

These aren't fixing any bugs that I know of, but they
add extra robustness to a complicated task.

llvm-svn: 146478
2011-12-13 06:00:49 +00:00
Jason Molenda cb349ee19c When unwinding from the first frame, try to ask the remote debugserver
if this is a mapped/executable region of memory.  If it isn't, we've jumped
through a bad pointer and we know how to unwind the stack correctly based
on the ABI.  

Previously I had 0x0 special cased but if you jumped to 0x2 on x86_64 one
frame would be skipped because the unwinder would try using the x86_64 
ArchDefaultUnwindPlan which relied on the rbp.

Fixes <rdar://problem/10508291>

llvm-svn: 146477
2011-12-13 05:39:38 +00:00
Greg Clayton 8eb732e9e5 Use forward declarations more of the time to save on things that we need to
parse.

llvm-svn: 146473
2011-12-13 04:34:06 +00:00
Sean Callanan d5cc132b98 I have modified the part of the code that finds and
validates the "self," "this," and "_cmd" pointers
that get passed into expressions.  It used to check
them aggressively for validity before allowing the
expression to run as an object method; now, this
functionality is gated by a bool and off by default.

Now the default is that when LLDB is stopped in a
method of a class, code entered using "expr" will
always masquerade as an instance method.  If for
some reason "self," "this," or "_cmd" is unavailable
it will be reported as NULL.  This may cause the
expression to crash if it relies on those pointers,
but for example getting the addresses of ivars will
now work as the user would expect.

llvm-svn: 146465
2011-12-13 01:42:04 +00:00
Johnny Chen 64bab4894e rdar://problem/10227672
There were two problems associated with this radar:
1. "settings show target.source-map" failed to show the source-map after, for example,
   "settings set target.source-map /Volumes/data/lldb/svn/trunk/test/source-manager /Volumes/data/lldb/svn/trunk/test/source-manager/hidden"
   has been executed to set the source-map.
2. "list -n main" failed to display the source of the main() function after we properly set the source-map.

The first was fixed by adding the missing functionality to TargetInstanceSettings::GetInstanceSettingsValue (Target.cpp)
and updating the support files PathMappingList.h/.cpp; the second by modifying SourceManager.cpp to fix several places
with incorrect logic.

Also added a test case test_move_and_then_display_source() to TestSourceManager.py, which moves main.c to hidden/main.c,
sets target.source-map to perform the directory mapping, and then verifies that "list -n main" can still show the main()
function.

llvm-svn: 146422
2011-12-12 21:59:28 +00:00
Greg Clayton 42ce2f35fd Use forward types where possible to avoid having to parse extra DWARF when
it is not required.

llvm-svn: 146418
2011-12-12 21:50:19 +00:00
Greg Clayton 6f6bf26a3e <rdar://problem/9958446>
<rdar://problem/10561406>

Stopped the SymbolFileDWARF::FindFunctions (...) from always calculating
the line table entry for all functions that were found. This can slow down
the expression parser if it ends up finding a bunch of matches. Fixed the 
places that were relying on the line table entry being filled in.

Discovered a recursive stack blowout that happened when "main" didn't have
line info for it and there was no line information for "main"

llvm-svn: 146330
2011-12-10 21:05:26 +00:00
Sean Callanan fd1ba911f8 Fixed a problem where if a frame was present the
expression parser would never try getting typed
variables from the target.

llvm-svn: 146317
2011-12-10 04:03:38 +00:00
Sean Callanan 9b3569bacc Two fixes for file variables:
- Even if a frame isn't present, we always try
  to use FindGlobalVariable to find variables.
  Instead of using frame->TrackGlobalVariable()
  to promote the VariableSP into a ValueObject,
  we now simply use ValueObjectVariable.

- When requesting the value of a variable, we
  allow returning of the "live version" of the
  variable -- that is, the variable in the
  target instead of a pointer to its freeze
  dried version in LLDB -- even if there is no
  process present.

llvm-svn: 146315
2011-12-10 03:12:34 +00:00
Greg Clayton 3bffb085f4 <rdar://problem/10559329>
An assertion was firing when parsing types due to trying to complete parent
class decl contenxt types too often.

Also, relax where "dsymutil" binary can come from in the Makefile.rules.

llvm-svn: 146310
2011-12-10 02:15:28 +00:00
Jim Ingham 9ee0115147 Don't try to cache the ExecutionContextScope in the ValueObject::EvaluationPoint, it is too
hard to ensure it doesn't get invalidated out from under us.  Instead look it up from the ThreadID
and StackID when asked for it.
<rdar://problem/10554409>

llvm-svn: 146309
2011-12-10 01:49:43 +00:00
Sean Callanan 8a6a6acd1f Fixed a problem with properties where LLDB was not
creating appropriate setter/getter methods for
property definitions.

llvm-svn: 146295
2011-12-09 23:24:26 +00:00
Greg Clayton 220a00772a Tested a theory on the where when we lookup things in the accelerator tables
that if we prefer the current compile unit, followed by any compile units that
already had their DIEs parsed, followed by the rest of the matches, that we
might save some memory. This turned out not to help much. The code is commented
out, but I want to check it in so I don't lose the code in case it could help
later.

Added the ability to efficiently find the objective C class implementation
when using the new .apple_types acclerator tables with the type flags. If the
type flags are not available, we default back to what we were doing before.

llvm-svn: 146250
2011-12-09 08:48:30 +00:00
Jason Molenda d74db47a41 Move the ARM specific arch picker from PlatformRemoteiOS.cpp to
PlatformDarwin.cpp -- call it from both PlatformRemoteiOS.cpp
and the native process PlatformDarwin.cpp when running on an arm
system.

Bump lldb version number to 94.

llvm-svn: 146249
2011-12-09 07:50:50 +00:00
Jim Ingham 79ea1d8877 Rework how the breakpoint conditions & callbacks are handled. We now iterate over all the locations at the site
that got hit, and first check the condition, and if that location's condition says we should stop, then we
run the callback.  In the end if any location's condition and callback say we should stop, then we stop. 

llvm-svn: 146242
2011-12-09 04:17:31 +00:00
Sean Callanan 12014a0471 If the expression parser is unable to complete a TagDecl
in the context in which it was originally found, the
expression parser now goes hunting for it in all modules
(in the appropriate namespace, if applicable).  This means
that forward-declared types that exist in another shared
library will now be resolved correctly.

Added a test case to cover this.  The test case also tests
"frame variable," which does not have this functionality
yet.

llvm-svn: 146204
2011-12-08 23:45:45 +00:00
Jim Ingham 60dbabbaa7 Add SBValue::GetDynamicValue and SBValue::GetStaticValue API's.
<rdar://problem/10545069>

llvm-svn: 146173
2011-12-08 19:44:08 +00:00
Sean Callanan 5780f9df56 Added the ability to dereference an Objective-C object
pointer to make the result of an expression.  LLDB now
dumps the ivars of the Objective-C object and all of
its parents.  This just required fixing a bug where we
didn't distinguish between Objective-C object pointers
and regular C-style pointers.

Also added a testcase to verify that this continues to
work.

llvm-svn: 146164
2011-12-08 19:04:34 +00:00
Greg Clayton cab36a3a59 Fixed an issue where we are asking to get the decl context for a function
that is in a class from the expression parser, and it was causing an
assertion. There is now a function that will correctly resolve a type
even if it is in a class.

llvm-svn: 146141
2011-12-08 05:16:30 +00:00