Commit Graph

84 Commits

Author SHA1 Message Date
Johnny Chen e26c721976 Fix a typo.
llvm-svn: 156952
2012-05-16 22:01:10 +00:00
Greg Clayton c0debe8566 Don't intercept the quit command and override what is was doing. This was causing the "lldb" command line to deadlock when the quit command was executed sometimes.
llvm-svn: 156595
2012-05-11 00:27:51 +00:00
Johnny Chen fd02a89960 Make ctrl-c terminate the current input line and start an empty line, instead of the previous content.
rdar://problem/11412821

llvm-svn: 156510
2012-05-09 21:03:07 +00:00
Jim Ingham 8499e1a4cb Print out a notification when the process of a target other than the currently selected target stops.
llvm-svn: 156433
2012-05-08 23:06:07 +00:00
Johnny Chen 5a4b4b86d6 Move the el_source() call after the section of code which sets up the default "ctrl-r" and "ctrl-w" bindings
so that user-provided .editrc has a chance to override the lldb's default key bindings.

llvm-svn: 156314
2012-05-07 18:18:08 +00:00
Johnny Chen 66b7c59593 Jason Molenda convinced me that we should make ctrl-w on the command line bind to ed-delete-prev-word.
If you have ctrl-w key binding specified with your .editrc file, it will be overridden with ed-delete-prev-word. :-)

llvm-svn: 156230
2012-05-05 04:44:12 +00:00
Jim Ingham 57190baa6c Don't call SBDebugger::SetInternalVariable in the sigwinch_handler, since that takes locks and potentially does allocations.
Just call SBDebugger::SetTerminalWidth on the driver's SBDebugger, which does the same job, but no locks.
Also add the value checking to SetTerminalWidth you get with SetInternalVariable(..., "term-width", ...).

rdar://problem/11310563

llvm-svn: 155665
2012-04-26 21:39:32 +00:00
Jim Ingham fab10e89ce Add a command and an SB API to create exception breakpoints. Make the break output prettier for Exception breakpoints.
llvm-svn: 152081
2012-03-06 00:37:27 +00:00
Greg Clayton a9f7b79dfe <rdar://problem/10605072>
Added the ability to override command line commands. In some cases GUI interfaces
might want to intercept commands like "quit" or "process launch" (which might cause
the process to re-run). They can now do so by overriding/intercepting commands
by using functions added to SBCommandInterpreter using a callback function. If the
callback function returns true, the command is assumed to be handled. If false
is returned the command should be evaluated normally.

Adopted this up in the Driver.cpp for intercepting the "quit" command.

llvm-svn: 151708
2012-02-29 04:21:24 +00:00
Jim Ingham 4bddaeb5ab Add a general mechanism to wait on the debugger for Broadcasters of a given class/event bit set.
Use this to allow the lldb Driver to emit notifications for breakpoint modifications.
<rdar://problem/10619974>

llvm-svn: 150665
2012-02-16 06:50:00 +00:00
Jim Ingham e6bc6cb96f Send Breakpoint Changed events for all the relevant changes to breakpoints.
Also, provide and use accessors for the thread options on breakpoints so we
can control sending the appropriate events.

llvm-svn: 150057
2012-02-08 05:23:15 +00:00
Greg Clayton f571b89054 Fixed terminal settings not being properly restored when "quit" was run.
This affected bash users.

llvm-svn: 149623
2012-02-02 19:28:31 +00:00
Greg Clayton 74d4193e2f Cleaned up the Communication class when it tears down ConnectionFileDescriptor
instances to not pthread_cancel the read threads and wreak havoc on the mutex
in our ConnectionFileDescriptor class.

Also cleaned up some shutdown delays.

llvm-svn: 149355
2012-01-31 04:56:17 +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 61e7a58c0c Process IDs (lldb::pid_t) and thread IDs (lldb::tid_t) are now 64 bit. This
will allow us to represent a process/thread ID using a pointer for the OS
plug-ins where they might want to represent the process or thread ID using
the address of the process or thread structure.

llvm-svn: 145644
2011-12-01 23:28:38 +00:00
Greg Clayton 1d8859668f Moved many of the "settings" that used to be in "target.process.*" to just
be in the target. All of the environment, args, stdin/out/err files, etc have
all been moved. Also re-enabled the ability to launch a process in a separate
terminal on MacOSX.

llvm-svn: 144061
2011-11-08 02:43:13 +00:00
Daniel Dunbar a08823fd10 warnings: Fix a bunch of -Wreorder problems.
llvm-svn: 143381
2011-10-31 22:50:49 +00:00
Jim Ingham 12e9a2012f Track whether a process was Launched or Attached to. If Attached, the detach when the debugger is destroyed, rather than killing the process. Also added a Debugger::Clear, which gets called in Debugger::Destroy to deal with all the targets in the Debugger. Also made the Driver's main loop call Destroy on the debugger, rather than just Destroying the currently selected Target's process.
llvm-svn: 139852
2011-09-15 21:30:02 +00:00
Jim Ingham e64f0dc7bf Adding "-n", "-p" and "-w" flags to the lldb command-line tool to
allow attaching from the command line.

llvm-svn: 139665
2011-09-13 23:25:31 +00:00
Jim Ingham e37d605e7d SBSourceManager now gets the real source manager either from the Debugger or Target. Also, move the SourceManager file cache into the debugger
so it can be shared amongst the targets.

llvm-svn: 139564
2011-09-13 00:29:56 +00:00
Jim Ingham a9deaf971d Better help string for "lldb -- file arg1 arg2..."
llvm-svn: 137789
2011-08-16 23:57:58 +00:00
Jim Ingham 556e653b6a Document how to pass program args to lldb command-line.
llvm-svn: 137784
2011-08-16 23:15:02 +00:00
Jim Ingham 06942690b1 Add a version of SBDebugger::Create which allows us to specify whether to source
in the init files or not.

llvm-svn: 137541
2011-08-13 00:22:20 +00:00
Jason Molenda 7efc7e949c Fixes the occasional crash on exit when quitting lldb with control-D.
If the IOChannel has already freed out its m_driver member, and
there's still a character to be read/written (that is, the ^D
character), just skip that char instead of trying to write through
a null object pointer.

llvm-svn: 137421
2011-08-12 02:40:17 +00:00
Johnny Chen 25f3a3cde2 Incremental fixes of issues found by Xcode static analyzer.
llvm-svn: 137257
2011-08-10 22:06:24 +00:00
Jim Ingham 7d6811d60e Remove some commented out code that doesn't connect to anything yet...
llvm-svn: 137081
2011-08-09 00:26:56 +00:00
Johnny Chen 8f3d8384be Patch by David Forsythe to build lldb on FreeBSD!
I did not take the patch for ClangExpressionParser.cpp since there was a
recent change by Peter for the same line.  Feel free to disagree. :-)

Reference:
----------------------------------------------------------------------
r136580 | pcc | 2011-07-30 15:42:24 -0700 (Sat, 30 Jul 2011) | 3 lines

Add reloc arg to standard JIT createJIT()

Fixes non-__APPLE__ build.  Patch by Matt Johnson!
----------------------------------------------------------------------

Also, I ignore the part of the patch to remove the RegisterContextDarwin*.h/.cpp.

llvm-svn: 136720
2011-08-02 20:52:42 +00:00
Jim Ingham a5a97ebe3c Added "command history" command to dump the command history.
Also made:
(lldb) !<NUM>
(lldb) !-<NUM>
(lldb) !!

work with the history.  For added benefit:

(lldb) !<NUM><TAB>

will insert the command at position <NUM> in the history into the command line to be edited.

This is only partial, I still need to sync up editline's history list with the one kept by the interpreter.

llvm-svn: 134955
2011-07-12 03:12:18 +00:00
Greg Clayton fc3f027d33 Don't have the debugger default to ignoring EOF. This is only what the driver
(or anything running in a terminal) wants. Not what a UI (Xcode) would want 
where it creates a debugger per debug window. The current code had an infinite
loop after a debug session ended. 

llvm-svn: 132280
2011-05-29 04:06:55 +00:00
Caroline Tice b5059acc5f Fix places that were writing directly to the debugger's output
handles to go through the appropriate channels instead.

llvm-svn: 131415
2011-05-16 19:20:50 +00:00
Caroline Tice 9088b06899 Make sure writing asynchronous output only backs up
& overwrites prompt if the IOChannel input reader is the top
input reader.

llvm-svn: 131110
2011-05-09 23:06:58 +00:00
Caroline Tice 0de8d4503b Add ability to search backwards through command
history for a particular substring, using ctrl-r key.

llvm-svn: 130871
2011-05-04 21:39:02 +00:00
Caroline Tice fe1bdf291f Minor cleanup: When asynchronous output comes along,
back up over and delete the prompt before writing out the
asynchronous output, rather than just going to a new line.

llvm-svn: 130843
2011-05-04 16:44:57 +00:00
Caroline Tice 86a73f9007 Make the driver listen for asynchronous output, rather than
the IOChannel, so that it can be written out even while the
IOChannel is collecting user input.

llvm-svn: 130789
2011-05-03 20:53:11 +00:00
Caroline Tice 969ed3d10f This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.

As part of this it introduces a new Stream class,
StreamAsynchronousIO.  A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast.  When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string.  When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.

Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.

I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired.  I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).

llvm-svn: 130721
2011-05-02 20:41:46 +00:00
Greg Clayton 7260f6206f Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the 
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example). 

Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.

We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:

(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000) 
(lldb) target list
Current targets:
  target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
  target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
  frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
  frame #1: 0x0000000100000b64 a.out`start + 52

Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.

llvm-svn: 129695
2011-04-18 08:33:37 +00:00
Greg Clayton ab65b34fdc Added auto completion for architecture names and for platforms.
Modified the OptionGroupOptions to be able to specify only some of the options
that should be appended by using the usage_mask in the group defintions and
also provided a way to remap them to a new usage mask after the copy. This 
allows options to be re-used and also targetted for specific option groups.

Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration.
Taught the option parser to be able to automatically use the appropriate
auto completion for a given options if nothing is explicitly specified
in the option definition. So you don't have to specify it in the option
definition tables.

Renamed the default host platform name to "host", and the default platform
hostname to be "localhost".

Modified the "file" and "platform select" commands to make sure all options
and args are good prior to creating a new platform. Also defer the computation
of the architecture in the file command until all options are parsed and the
platform has either not been specified or reset to a new value to avoid
computing the arch more than once.

Switch the PluginManager code over to using llvm::StringRef for string
comparisons and got rid of all the AccessorXXX functions in lieu of the newer
mutex + collection singleton accessors.

llvm-svn: 129483
2011-04-13 22:47:15 +00:00
Stephen Wilson 71c21d18c3 Order of initialization lists.
This patch fixes all of the warnings due to unordered initialization lists.

Patch by Marco Minutoli.

llvm-svn: 129290
2011-04-11 19:41:40 +00:00
Greg Clayton e0d378b334 Fixed the LLDB build so that we can have private types, private enums and
public types and public enums. This was done to keep the SWIG stuff from
parsing all sorts of enums and types that weren't needed, and allows us to
abstract our API better.

llvm-svn: 128239
2011-03-24 21:19:54 +00:00
Stephen Wilson d7b15bd6b7 Fix makefile builds when llvm is configured with -enable-shared.
We were dropping the expansion of -rpath=$(LibDir) on linux, which resulted in
the build not being able to resolve libLLVM.so.  Bring in the definition before
expanding the values hanging off LD.Flags.

Thanks to Jason E. Aten for reporting this!

llvm-svn: 127570
2011-03-13 18:17:16 +00:00
Greg Clayton e996fd30be LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS
that supports LLDB should be registering a "default" platform that will be
used unless a new platform is selected. Platforms are responsible for things
such as:
- getting process information by name or by processs ID
- finding platform files. This is useful for remote debugging where there is 
  an SDK with files that might already or need to be cached for debug access.
- getting a list of platform supported architectures in the exact order they
  should be selected. This helps the native x86 platform on MacOSX select the
  correct x86_64/i386 slice from universal binaries.
- Connect to remote platforms for remote debugging
- Resolving an executable including finding an executable inside platform
  specific bundles (macosx uses .app bundles that contain files) and also
  selecting the appropriate slice of universal files for a given platform.

So by default there is always a local platform, but remote platforms can be
connected to. I will soon be adding a new "platform" command that will support
the following commands:
(lldb) platform connect --name machine1 macosx connect://host:port
Connected to "machine1" platform.
(lldb) platform disconnect macosx

This allows LLDB to be well setup to do remote debugging and also once 
connected process listing and finding for things like:
(lldb) process attach --name x<TAB>

The currently selected platform plug-in can now auto complete any available
processes that start with "x". The responsibilities for the platform plug-in
will soon grow and expand.

llvm-svn: 127286
2011-03-08 22:40:15 +00:00
Greg Clayton 9d0402b1eb Don't limit StreamTee to just two streams. It now can contain
N streams by making the stream a vector of stream shared pointers
that is protected by a mutex. Streams can be get/set by index which
allows indexes to be defined as stream indentifiers. If a stream is
set at index 3 and there are now streams in the collection, then
empty stream objects are inserted to ensure that stream at index 3
has a valid stream. There is also an append method that allows a stream
to be pushed onto the stack. This will allow our streams to be very
flexible in where the output goes.

Modified the CommandReturnObject to use the new StreamTee functionality.
This class now defines two StreamTee indexes: 0 for the stream string
stream, and 1 for the immediate stream. This is used both on the output
and error streams.

Added the ability to get argument types as strings or as descriptions.
This is exported through the SBCommandInterpreter API to allow external
access.

Modified the Driver class to use the newly exported argument names from
SBCommandInterpreter::GetArgumentTypeAsCString().

llvm-svn: 126067
2011-02-20 02:15:07 +00:00
Jim Ingham 85e8b81492 - Changed all the places where CommandObjectReturn was exporting a StreamString to just exporting
a Stream, and then added GetOutputData & GetErrorData to get the accumulated data.
- Added a StreamTee that will tee output to two provided lldb::StreamSP's.
- Made the CommandObjectReturn use this so you can Tee the results immediately to
the debuggers output file, as well as saving up the results to return when the command
is done executing.
- HandleCommands now uses this so that if you have a set of commands that continue the target
you will see the commands come out as they are processed.
- The Driver now uses this to output the command results as you go, which makes the interface
more reactive seeming.

llvm-svn: 126015
2011-02-19 02:53:09 +00:00
Greg Clayton 2da6d49523 Patch that allows for thread_t to be something more complex than an
integer. Modified patch from Kirk Beitz.

llvm-svn: 125067
2011-02-08 01:34:25 +00:00
Greg Clayton 6083026822 Applied a fix to qualify "UUID" with the lldb_private namespace to fix
build issues on MinGW.

llvm-svn: 124888
2011-02-04 18:53:10 +00:00
Greg Clayton b766a73dfc Added support for attaching to a remote debug server with the new command:
(lldb) process connect <remote-url>

Currently when you specify a file with the file command it helps us to find
a process plug-in that is suitable for debugging. If you specify a file you
can rely upon this to find the correct debugger plug-in:

% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) process connect connect://localhost:2345
...

If you don't specify a file, you will need to specify the plug-in name that
you wish to use:

% lldb
(lldb) process connect --plugin process.gdb-remote connect://localhost:2345

Other connection URL examples:

(lldb) process connect connect://localhost:2345
(lldb) process connect tcp://127.0.0.1
(lldb) process connect file:///dev/ttyS1

We are currently treating the "connect://host:port" as a way to do raw socket
connections. If there is a URL for this already, please let me know and we
will adopt it.

So now you can connect to a remote debug server with the ProcessGDBRemote
plug-in. After connection, it will ask for the pid info using the "qC" packet
and if it responds with a valid process ID, it will be equivalent to attaching.
If it response with an error or invalid process ID, the LLDB process will be
in a new state: eStateConnected. This allows us to then download a program or
specify the program to run (using the 'A' packet), or specify a process to
attach to (using the "vAttach" packets), or query info about the processes
that might be available.

llvm-svn: 124846
2011-02-04 01:58:07 +00:00
Jim Ingham a462f5cc07 Adding a Xcode workspace for lldb.
llvm-svn: 124416
2011-01-27 20:15:39 +00:00
Greg Clayton 8d846daa81 Any arguments that are not options to the "lldb" command line driver, now get
used as the arguments for the inferior program. So for example you can do

% lldb /bin/ls /tmp ~/Documents

And "lldb" will use "/bin/ls" as the program and send arguments "/tmp" and
"~/Documents" as the launch args.

If you specify a file, then all remaining args after option parsing
will be used for program arguments:

% lldb -f /bin/ls /tmp ~/Documents

If you need to pass option values to your inferior program, just terminate
the "lldb" command line driver options with "--":

% lldb -- /bin/ls -AFl /tmp

The arguments are placed into the "settings" variable named 
"target.process.run-args". This allows you to just run the program using
"process launch" and, if no args are specified on that command, the 
"target.process.run-args" values will be used:

% lldb -- /bin/ls -AFl /tmp
Current executable set to '/bin/ls' (x86_64).
(lldb) settings show target.process.run-args 
target.process.run-args (array):
  [0]: '-AFl'
  [1]: '/tmp'
(lldb) 
(lldb) r
Process 56753 launched: '/bin/ls' (x86_64)
lrwxr-xr-x@ 1 root  wheel  11 Nov 19  2009 /tmp@ -> private/tmp

llvm-svn: 121295
2010-12-08 22:23:24 +00:00
Greg Clayton d46c87a1a8 More reverting of the EOF stuff as the API was changed which we don't want to
do. Closing on EOF is an option that can be set on the 
lldb_private::Communication or the lldb::SBCommunication objects after they
are created. Of course the EOF support isn't hooked up, so they don't do 
anything at the moment, but they are left in so when the code is fixed, it 
will be easy to get working again.

llvm-svn: 120885
2010-12-04 02:39:47 +00:00
Caroline Tice 82305fc59a Add proper EOF handling to Communication & Connection classes:
Add bool member to Communication class indicating whether the
Connection should be closed on receiving an EOF or not.  Update the
Connection read to return an EOF status when appropriate.  Modify the
Communication class to pass the EOF along or not, and to close the
Connection or not, as appropriate.

llvm-svn: 120723
2010-12-02 18:31:56 +00:00