Commit Graph

115 Commits

Author SHA1 Message Date
Greg Clayton a3406614e0 Abtract terminal stuff into a new lldb_private::Terminal class
where the implementation is hidden in the host layer. This avoids
a slew of "#if LLDB_CONFIG_TERMIOS_SUPPORTED" statements in the
code and keeps things cleaner.

llvm-svn: 125057
2011-02-07 23:24:47 +00:00
Greg Clayton 75852f56ae Added a "ArchSpec::SetElfArch()" that was removed by a previous patch and
avoid using RTLD_FIRST with dlopen to keep things compatible with other *NIX
variants. Patch from Jai Menon.

llvm-svn: 125015
2011-02-07 17:43:47 +00:00
Greg Clayton 8442fba3b4 Apple specific fix for Host.cpp from Kirk Beitz.
llvm-svn: 124942
2011-02-05 06:36:35 +00:00
Greg Clayton 95e314260e Header patch, virtual dtor patch and missed UUID patch from Kirk Beitz.
llvm-svn: 124931
2011-02-05 02:56:16 +00:00
Greg Clayton 72b77ebc8a Remove bzero use and replace with memset (patch from Kirk Beitz).
llvm-svn: 124897
2011-02-04 21:13:05 +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
Greg Clayton 4272cc7d4c Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are 
prepared for plug-ins. Plug-ins will attempt to be loaded from the 
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins" 
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:

extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);

If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:

    bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
    bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);

This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.

To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:

    static void *
    Host::DynamicLibraryOpen (const FileSpec &file_spec, 
                              Error &error);

    static Error
    Host::DynamicLibraryClose (void *dynamic_library_handle);

    static void *
    Host::DynamicLibraryGetSymbol (void *dynamic_library_handle, 
                                  const char *symbol_name, 
                                  Error &error);

lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:


    typedef enum EnumerateDirectoryResult
    {
        eEnumerateDirectoryResultNext,  // Enumerate next entry in the current directory
        eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
        eEnumerateDirectoryResultExit,  // Exit from the current directory at the current level.
        eEnumerateDirectoryResultQuit   // Stop directory enumerations at any level
    };

    typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
                                                                                  FileSpec::FileType file_type,
                                                                                  const FileSpec &spec);

    static FileSpec::EnumerateDirectoryResult
    FileSpec::EnumerateDirectory (const char *dir_path,
                                  bool find_directories,
                                  bool find_files,
                                  bool find_other,
                                  EnumerateDirectoryCallbackType callback,
                                  void *callback_baton);

This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to 
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at 
all levels.

Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based 
declaration information. Columns support can be re-enabled with the
additions of a #define.

Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.

Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.

llvm-svn: 124716
2011-02-02 02:24:04 +00:00
Greg Clayton 293d593294 Added a cleanup helper object to make sure the directory that was opened with "DIR *opendir(const char *)" is closed if it is valid with a call to "int closedir (DIR *)".
llvm-svn: 124648
2011-02-01 05:15:02 +00:00
Greg Clayton 7fb56d0a1a Endian patch from Kirk Beitz that allows better cross platform building.
llvm-svn: 124643
2011-02-01 01:31:41 +00:00
Greg Clayton bd82a5d2cc Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.

Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory 
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.

Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr. 

After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.

Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.

llvm-svn: 124060
2011-01-23 05:56:20 +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 e5b94a90ca Null terminate path returned by readlink().
llvm-svn: 123307
2011-01-12 04:21:21 +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
Johnny Chen 592b50e9dc Patch from Stephen:
Provide a missing resolve_path argument in calls to FileSpec's
constructor for both Linux and FreeBSD code fragments.

llvm-svn: 122275
2010-12-20 21:52:18 +00:00
Greg Clayton 3b14763356 Linux patches from Stephen Wilson.
llvm-svn: 122130
2010-12-18 01:54:34 +00:00
Greg Clayton 85851dde89 Added the ability for a process to inherit the current host environment. This
was done as an settings variable in the process for now. We will eventually
move all environment stuff over to the target, but we will leave it with the
process for now. The default setting is for a process to inherit the host
environment. This can be disabled by setting the "inherit-env" setting to
false in the process.

llvm-svn: 120862
2010-12-04 00:10:17 +00:00
Greg Clayton e521966054 Fixed a race condition that could cause ProcessGDBRemote::DoResume() to return
an error saying the resume timed out. Previously the thread that was trying
to resume the process would eventually call ProcessGDBRemote::DoResume() which
would broadcast an event over to the async GDB remote thread which would sent the
continue packet to the remote gdb server. Right after this was sent, it would
set a predicate boolean value (protected by a mutex and condition) and then the
thread that issued the ProcessGDBRemote::DoResume() would then wait for that
condition variable to be set. If the async gdb thread was too quick though, the
predicate boolean value could have been set to true and back to false by the
time the thread that issued the ProcessGDBRemote::DoResume() checks the boolean
value. So we can't use the predicate value as a handshake. I have changed the code
over to using a Event by having the GDB remote communication object post an
event: 

	GDBRemoteCommunication::eBroadcastBitRunPacketSent

This allows reliable handshaking between the two threads and avoids the erroneous
ProcessGDBRemote::DoResume() errors.

Added a host backtrace service to allow in process backtraces when trying to track
down tricky issues. I need to see if LLVM has any backtracing abilities abstracted
in it already, and if so, use that, but I needed something ASAP for the current issue
I was working on. The static function is:

void
Host::Backtrace (Stream &strm, uint32_t max_frames);

And it will backtrace at most "max_frames" frames for the current thread and can be
used with any of the Stream subclasses for logging.

llvm-svn: 120793
2010-12-03 06:02:24 +00:00
Benjamin Kramer 2c88643a22 Silence a bunch of clang warnings.
llvm-svn: 118710
2010-11-10 20:16:47 +00:00
Greg Clayton cf7e9a0485 Don't keep appending to the current crash description with each formatted crash description call.
llvm-svn: 118703
2010-11-10 19:43:40 +00:00
Greg Clayton 2d95dc9b22 Modified lldb_private::SymboleFile to be able to override where its TypeList
comes from by using a virtual function to provide it from the Module's
SymbolVendor by default. This allows the DWARF parser, when being used to
parse DWARF in .o files with a parent DWARF + debug map parser, to get its
type list from the DWARF + debug map parser so when we go and find full 
definitions for types (that might come from other .o files), we can use the
type list from the debug map parser. Otherwise we ended up mixing clang types
from one .o file (say a const pointer to a forward declaration "class A") with
the a full type from another .o file. This causes expression parsing, when 
copying the clang types from those parsed by the DWARF parser into the 
expression AST, to fail -- for good reason. Now all types are created in the
same list.

Also added host support for crash description strings that can be set before
doing a piece of work. On MacOSX, this ties in with CrashReporter support
that allows a string to be dispalyed when the app crashes and allows 
LLDB.framework to print a description string in the crash log. Right now this
is hookup up the the CommandInterpreter::HandleCommand() where each command
notes that it is about to be executed, so if we crash while trying to do this
command, we should be able to see the command that caused LLDB to exit. For
all other platforms, this is a nop.

llvm-svn: 118672
2010-11-10 04:57:04 +00:00
Greg Clayton 21184644af Fixed an issue where if you try and run something in a TTY that isn't
the same architecture as a default program, the attach architecture auto
detection would change the architecture to the architecture of the darwin-debug
(which was always x86_64) and hose up your debug session.

llvm-svn: 118399
2010-11-08 03:06:10 +00:00
Greg Clayton 2d4edfbc6a Modified all logging calls to hand out shared pointers to make sure we
don't crash if we disable logging when some code already has a copy of the
logger. Prior to this fix, logs were handed out as pointers and if they were
held onto while a log got disabled, then it could cause a crash. Now all logs
are handed out as shared pointers so this problem shouldn't happen anymore.
We are also using our new shared pointers that put the shared pointer count
and the object into the same allocation for a tad better performance.

llvm-svn: 118319
2010-11-06 01:53:30 +00:00
Greg Clayton cfd1aced7e Cleaned up the API logging a lot more to reduce redundant information and
keep the file size a bit smaller.

Exposed SBValue::GetExpressionPath() so SBValue users can get an expression
path for their values.

llvm-svn: 117851
2010-10-31 03:01:06 +00:00
Caroline Tice 20ad3c40f4 Add the ability to disable individual log categories, rather
than just the entire log channel.

Add checks, where appropriate, to make sure a log channel/category has 
not been disabled before attempting to write to it.

llvm-svn: 117715
2010-10-29 21:48:37 +00:00
Greg Clayton 274060b6f1 Fixed an issue where we were resolving paths when we should have been.
So the issue here was that we have lldb_private::FileSpec that by default was 
always resolving a path when using the:

FileSpec::FileSpec (const char *path);

and in the:

void FileSpec::SetFile(const char *pathname, bool resolve = true);

This isn't what we want in many many cases. One example is you have "/tmp" on
your file system which is really "/private/tmp". You compile code in that
directory and end up with debug info that mentions "/tmp/file.c". Then you 
type:

(lldb) breakpoint set --file file.c --line 5

If your current working directory is "/tmp", then "file.c" would be turned 
into "/private/tmp/file.c" which won't match anything in the debug info.
Also, it should have been just a FileSpec with no directory and a filename
of "file.c" which could (and should) potentially match any instances of "file.c"
in the debug info.

So I removed the constructor that just takes a path:

FileSpec::FileSpec (const char *path); // REMOVED

You must now use the other constructor that has a "bool resolve" parameter that you must always supply:

FileSpec::FileSpec (const char *path, bool resolve);

I also removed the default parameter to SetFile():

void FileSpec::SetFile(const char *pathname, bool resolve);

And fixed all of the code to use the right settings.

llvm-svn: 116944
2010-10-20 20:54:39 +00:00
Greg Clayton 913c4fa15b Ok, last commit for the running processes in a new window. Now you can
optionally specify the tty you want to use if you want to use an existing
terminal window by giving a partial or full path name:

(lldb) process launch --tty=ttys002

This would find the terminal window (or tab on MacOSX) that has ttys002 in its
tty path and use it. If it isn't found, it will use a new terminal window.

llvm-svn: 116878
2010-10-19 23:16:00 +00:00
Greg Clayton 6162f9774a Fixed all known race conditions with starting a process in a new terminal.
We now spawn a thread to accept a unix socket connection from the inferior
when it spawns in the terminal, then we launch the process, then we get
the pid back through the unix socket, and then wait for it to SIGSTOP.

darwin-debug now clears the terminal screen and prints out the program and
arguments that are about to be launched.

llvm-svn: 116841
2010-10-19 18:15:50 +00:00
Greg Clayton add29982be Use AppleScript when lauching inferior in terminal so the command that
is being run is visible in the terminal as opposed to just seeing a path
to a .command file.

llvm-svn: 116814
2010-10-19 17:03:58 +00:00
Greg Clayton 3fcbed6bda Stop the driver from handling SIGPIPE in case we communicate with stale
sockets so the driver doesn't just crash.

Added support for connecting to named sockets (unix IPC sockets) in
ConnectionFileDescriptor.

Modified the Host::LaunchInNewTerminal() for MacOSX to return the process
ID of the inferior process instead of the process ID of the Terminal.app. This
was done by modifying the "darwin-debug" executable to connect to lldb through
a named unix socket which is passed down as an argument. This allows a quick
handshake between "lldb" and "darwin-debug" so we can get the process ID
of the inferior and then attach by process ID and avoid attaching to the 
inferior by process name since there could be more than one process with 
that name. This still has possible race conditions, those will be fixed
in the near future. This fixes the SIGPIPE issues that were sometimes being
seen when task_for_pid was failing.

llvm-svn: 116792
2010-10-19 03:25:40 +00:00
Greg Clayton 19388cfc6e Fixed debugserver to properly attach to a process by name with the
"vAttachName;<PROCNAME>" packet, and wait for a new process by name to launch 
with the "vAttachWait;<PROCNAME>".

Fixed a few issues with attaching where if DoAttach() returned no error, yet
there was no valid process ID, we would deadlock waiting for an event that
would never happen.

Added a new "process launch" option "--tty" that will launch the process 
in a new terminal if the Host layer supports the "Host::LaunchInNewTerminal(...)"
function. This currently works on MacOSX and will allow the debugging of 
terminal applications that do complex operations with the terminal. 

Cleaned up the output when the process resumes, stops and halts to be 
consistent with the output format.

llvm-svn: 116693
2010-10-18 01:45:30 +00:00
Greg Clayton dd36defda7 Added a new Host call to find LLDB related paths:
static bool
    Host::GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec);
    
This will fill in "file_spec" with an appropriate path that is appropriate
for the current Host OS. MacOSX will return paths within the LLDB.framework,
and other unixes will return the paths they want. The current PathType
enums are:

typedef enum PathType
{
    ePathTypeLLDBShlibDir,          // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists
    ePathTypeSupportExecutableDir,  // Find LLDB support executable directory (debugserver, etc)
    ePathTypeHeaderDir,             // Find LLDB header file directory
    ePathTypePythonDir              // Find Python modules (PYTHONPATH) directory
} PathType;

All places that were finding executables are and python paths are now updated
to use this Host call.

Added another new host call to launch the inferior in a terminal. This ability
will be very host specific and doesn't need to be supported on all systems.
MacOSX currently will create a new .command file and tell Terminal.app to open
the .command file. It also uses the new "darwin-debug" app which is a small
app that uses posix to exec (no fork) and stop at the entry point of the 
program. The GDB remote plug-in is almost able launch a process and attach to
it, it currently will spawn the process, but it won't attach to it just yet.
This will let LLDB not have to share the terminal with another process and a
new terminal window will pop up when you launch. This won't get hooked up
until we work out all of the kinks. The new Host function is:

    static lldb::pid_t
    Host::LaunchInNewTerminal (
        const char **argv,   // argv[0] is executable
        const char **envp,
        const ArchSpec *arch_spec,
        bool stop_at_entry,
        bool disable_aslr);

Cleaned up FileSpec::GetPath to not use strncpy() as it was always zero 
filling the entire path buffer.

Fixed an issue with the dynamic checker function where I missed a '$' prefix
that should have been added.

llvm-svn: 116690
2010-10-17 22:03:32 +00:00
Greg Clayton 222f5700c2 Plugged memory leak.
llvm-svn: 116175
2010-10-10 22:07:18 +00:00
Greg Clayton 4957bf69e5 Cleaned up a unused member variable in Debugger.
Added the start of Host specific launch services, though it currently isn't
hookup up to anything. We want to be able to launch a process and use the
native launch services to launch an app like it would be launched by the
user double clicking on the app. We also eventually want to be able to run
a command line app in a newly spawned terminal to avoid terminal sharing.

Fixed an issue with the new DWARF forward type declaration stuff. A crasher
was found that was happening when trying to properly expand the forward
declarations.

llvm-svn: 115213
2010-09-30 21:49:03 +00:00
Caroline Tice 391a9603a0 Remove Host::ResolveExecutableLocation (very recent addition); replace use of
it with llvm::sys::Program::FindProgramByName.

llvm-svn: 113709
2010-09-12 00:10:52 +00:00
Jason Molenda fbcb7f2c4e The first part of an lldb native stack unwinder.
The Unwind and RegisterContext subclasses still need
to be finished; none of this code is used by lldb at
this point (unless you call into it by hand).

The ObjectFile class now has an UnwindTable object.

The UnwindTable object has a series of FuncUnwinders
objects (Function Unwinders) -- one for each function
in that ObjectFile we've backtraced through during this
debug session.

The FuncUnwinders object has a few different UnwindPlans.
UnwindPlans are a generic way of describing how to find
the canonical address of a given function's stack frame
(the CFA idea from DWARF/eh_frame) and how to restore the
caller frame's register values, if they have been saved
by this function.

UnwindPlans are created from different sources.  One source is the
eh_frame exception handling information generated by the compiler
for unwinding an exception throw.  Another source is an assembly
language inspection class (UnwindAssemblyProfiler, uses the Plugin
architecture) which looks at the instructions in the funciton
prologue and describes the stack movements/register saves that are
done.

Two additional types of UnwindPlans that are worth noting are
the "fast" stack UnwindPlan which is useful for making a first
pass over a thread's stack, determining how many stack frames there
are and retrieving the pc and CFA values for each frame (enough
to create StackFrameIDs).  Only a minimal set of registers is
recovered during a fast stack walk.  

The final UnwindPlan is an architectural default unwind plan.
These are provided by the ArchDefaultUnwindPlan class (which uses
the plugin architecture).  When no symbol/function address range can
be found for a given pc value -- when we have no eh_frame information
and when we don't have a start address so we can't examine the assembly
language instrucitons -- we have to make a best guess about how to 
unwind.  That's when we use the architectural default UnwindPlan.
On x86_64, this would be to assume that rbp is used as a stack pointer
and we can use that to find the caller's frame pointer and pc value.
It's a last-ditch best guess about how to unwind out of a frame.

There are heuristics about when to use one UnwindPlan versues the other --
this will all happen in the still-begin-written UnwindLLDB subclass of
Unwind which runs the UnwindPlans.

llvm-svn: 113581
2010-09-10 07:49:16 +00:00
Caroline Tice 428a9a58fa If the file the user specifies can't be found in the current directory,
and the user didn't specify a particular directory, search for the file 
using the $PATH environment variable.

llvm-svn: 113575
2010-09-10 04:48:55 +00:00
Chris Lattner 311adf3d5b eliminate some clang warnings.
llvm-svn: 113438
2010-09-08 23:01:14 +00:00
Greg Clayton 2bddd3442f Patch from Jay Cornwall that modifies the LLDB "Host" layer to reuse more
code between linux, darwin and BSD.

llvm-svn: 113263
2010-09-07 20:11:56 +00:00
Greg Clayton 54512bd6c9 Fixed a case where we might be able to acquire a mutex with a try lock and
not release it by making sure a mutex locker object is appropriately used.

llvm-svn: 112996
2010-09-03 19:15:43 +00:00
Greg Clayton bda8065107 Cleaned up my previous submission which had some header search paths that
were not needed and fixed a merge issue.

llvm-svn: 112626
2010-08-31 18:56:24 +00:00
Greg Clayton f681b94f90 Added the ability to disable ASLR (Address Space Layout Randomization). ASLR
is disabled by default, and can be enabled using:

(lldb) set disable-aslr 0

llvm-svn: 112616
2010-08-31 18:35:14 +00:00
Jim Ingham b4dcbaeec2 Add a "lldb host" logging channel, and put logging in the Host::OpenInExternalEditor code.
llvm-svn: 112614
2010-08-31 18:05:13 +00:00
Jim Ingham 5024baba16 Add LLDB_EXTERNAL_EDITOR
llvm-svn: 112558
2010-08-30 23:48:25 +00:00
Greg Clayton ff3c05419e Stopped the external editor from adding stuff to the recent list when lldb
is launched with the -e option on Mac OS X.

llvm-svn: 112536
2010-08-30 22:00:34 +00:00
Jim Ingham e40e42181f Added a way to open the current source file & line in an external editor, and you can turn this on with:
lldb -e

llvm-svn: 112502
2010-08-30 19:44:40 +00:00
Johnny Chen a73af6f698 Fixed a crasher where during shutdown, loggings attempted to access the
thread name but the static map instance had already been destructed.

rdar://problem/8153284

llvm-svn: 111812
2010-08-23 17:13:12 +00:00
Greg Clayton 0b76a2c21f Modified the host process monitor callback function Host::StartMonitoringChildProcess
to spawn a thread for each process that is being monitored. Previously
LLDB would spawn a single thread that would wait for any child process which
isn't ok to do as a shared library (LLDB.framework on Mac OSX, or lldb.so on
linux). The old single thread used to call wait4() with a pid of -1 which 
could cause it to reap child processes that it shouldn't have.

Re-wrote the way Function blocks are handles. Previously I attempted to keep
all blocks in a single memory allocation (in a std::vector). This made the
code somewhat efficient, but hard to work with. I got rid of the old BlockList
class, and went to a straight parent with children relationship. This new 
approach will allow for partial parsing of the blocks within a function.

llvm-svn: 111706
2010-08-21 02:22:51 +00:00
Benjamin Kramer cb61b8c42b Fix clang warnings.
llvm-svn: 110676
2010-08-10 13:22:03 +00:00
Jim Ingham 5aee162f97 Change Target & Process so they can really be initialized with an invalid architecture.
Arrange that this then gets properly set on attach, or when a "file" is set.
Add a completer for "process attach -n".

Caveats: there isn't currently a way to handle multiple processes with the same name.  That
will have to wait on a way to pass annotations along with the completion strings.

llvm-svn: 110624
2010-08-09 23:31:02 +00:00
Greg Clayton 572404311a Remove a deadlock condition. A bit of explanation is needed: When calling
ThreadCancel in Host::WillTerminate g_monitor_thread may be blocked on a call
to pthread_cond_wait (for example, line 640).  Now, by default, when a 
cancellation request is serviced g_monitor_thread will again own the mutex
guarding the condition variable it was waiting on.  This causes the call to 
SetValue in Host::WillTerminate to hit a deadlock.

The call to SetValue does not appear to be needed, so removing it solves
the issue.

Patch from Stephen Wilson.

llvm-svn: 109228
2010-07-23 15:47:19 +00:00
Greg Clayton 19503a2a78 Warnings cleanup patch from Jean-Daniel Dupas.
llvm-svn: 109226
2010-07-23 15:37:46 +00:00
Greg Clayton e1a916a74d Change over to using the definitions for mach-o types and defines to the
defines that are in "llvm/Support/MachO.h". This should allow ObjectFileMachO
and ObjectContainerUniversalMachO to be able to be cross compiled in Linux.

Also did some cleanup on the ASTType by renaming it to ClangASTType and
renaming the header file. Moved a lot of "AST * + opaque clang type *"
functionality from lldb_private::Type over into ClangASTType.

llvm-svn: 109046
2010-07-21 22:12:05 +00:00
Greg Clayton c982c768d2 Merged Eli Friedman's linux build changes where he added Makefile files that
enabled LLVM make style building and made this compile LLDB on Mac OS X. We
can now iterate on this to make the build work on both linux and macosx.

llvm-svn: 108009
2010-07-09 20:39:50 +00:00
Greg Clayton 69b518f6ef typedef fixups, patch from Jean-Daniel Dupas.
llvm-svn: 107794
2010-07-07 17:07:17 +00:00
Greg Clayton 3afe8a9f1d Applied pid.patch from Jean-Daniel Dupas.
llvm-svn: 107692
2010-07-06 20:27:00 +00:00
Eli Friedman b6c9e103a1 Implement GetProgramFileSpec().
llvm-svn: 107502
2010-07-02 19:38:10 +00:00
Eli Friedman 5423ebff13 Add hacky, incomplete Linux host implementation; barely enough to allow
compiling lldb.  Someone else might try to improve it, though. :)

llvm-svn: 107501
2010-07-02 19:28:44 +00:00
Greg Clayton 7a47bd9f02 Move posix specific files into posix subdirectory so they can
be shared with linux.

Updated Xcode project.

llvm-svn: 105928
2010-06-14 04:30:13 +00:00
Eli Friedman a82475ab74 Fix includes.
llvm-svn: 105814
2010-06-11 04:54:56 +00:00
Eli Friedman 8d860d557f Fix TimeValue::Offset* to take uint64_t
llvm-svn: 105812
2010-06-11 04:50:35 +00:00
Greg Clayton 41f923275e Made lldb_private::ArchSpec more generic so that it can take a mach-o cpu
type and sub-type, or an ELF e_machine value. Also added a generic CPU type
to the arch spec class so we can have a single arch definition that the LLDB
core code can use. Previously a lot of places in the code were using the
mach-o definitions from a macosx header file. 

Switches over to using "llvm/Support/MachO.h" for the llvm::MachO::XXX for the
CPU types and sub types for mach-o ArchSpecs. Added "llvm/Support/ELF.h" so 
we can use the "llvm::ELF::XXX" defines for the ELF ArchSpecs.

Got rid of all CPU_TYPE_ and CPU_SUBTYPE_ defines that were previously being
used in LLDB.

llvm-svn: 105806
2010-06-11 03:25:34 +00:00
Chris Lattner 30fdc8d841 Initial checkin of lldb code from internal Apple repo.
llvm-svn: 105619
2010-06-08 16:52:24 +00:00