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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116690 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index c9b5955..3da1d59 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -384,12 +384,28 @@
{
Error error;
#if defined (LAUNCH_WITH_LAUNCH_SERVICES)
- FileSpec app_file_spec (argv[0]);
- pid_t pid = Host::LaunchApplication (app_file_spec);
+ ArchSpec inferior_arch(module->GetArchitecture());
+
+ //FileSpec app_file_spec (argv[0]);
+ pid_t pid = Host::LaunchInNewTerminal (argv,
+ envp,
+ &inferior_arch,
+ true, // stop at entry
+ (launch_flags & eLaunchFlagDisableASLR) != 0);
+
+ // Let the app get launched and stopped...
+ sleep (1);
+
if (pid != LLDB_INVALID_PROCESS_ID)
- error = DoAttachToProcessWithID (pid);
+ {
+ FileSpec program(argv[0]);
+ error = DoAttachToProcessWithName (program.GetFilename().AsCString(), false);
+ //error = DoAttachToProcessWithID (pid);
+ }
else
- error.SetErrorString("failed");
+ {
+ error.SetErrorString("Host::LaunchApplication(() failed to launch process");
+ }
#else
// ::LogSetBitMask (GDBR_LOG_DEFAULT);
// ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD);
@@ -1683,31 +1699,19 @@
{
// The debugserver binary is in the LLDB.framework/Resources
// directory.
- FileSpec framework_file_spec (Host::GetModuleFileSpecForHostAddress ((void *)lldb_private::Initialize));
- const char *framework_dir = framework_file_spec.GetDirectory().AsCString();
- const char *lldb_framework = ::strstr (framework_dir, "/LLDB.framework");
-
- if (lldb_framework)
+ if (Host::GetLLDBPath (ePathTypeSupportExecutableDir, debugserver_file_spec))
{
- int len = lldb_framework - framework_dir + strlen ("/LLDB.framework");
- ::snprintf (debugserver_path,
- sizeof(debugserver_path),
- "%.*s/Resources/%s",
- len,
- framework_dir,
- DEBUGSERVER_BASENAME);
- debugserver_file_spec.SetFile (debugserver_path);
+ debugserver_file_spec.GetFilename().SetCString(DEBUGSERVER_BASENAME);
debugserver_exists = debugserver_file_spec.Exists();
- }
-
- if (debugserver_exists)
- {
- g_debugserver_file_spec = debugserver_file_spec;
- }
- else
- {
- g_debugserver_file_spec.Clear();
- debugserver_file_spec.Clear();
+ if (debugserver_exists)
+ {
+ g_debugserver_file_spec = debugserver_file_spec;
+ }
+ else
+ {
+ g_debugserver_file_spec.Clear();
+ debugserver_file_spec.Clear();
+ }
}
}
@@ -1731,9 +1735,9 @@
#if !defined (__arm__)
- // We don't need to do this for ARM, and we really shouldn't now that we
- // have multiple CPU subtypes and no posix_spawnattr call that allows us
- // to set which CPU subtype to launch...
+ // We don't need to do this for ARM, and we really shouldn't now
+ // that we have multiple CPU subtypes and no posix_spawnattr call
+ // that allows us to set which CPU subtype to launch...
if (inferior_arch.GetType() == eArchTypeMachO)
{
cpu_type_t cpu = inferior_arch.GetCPUType();
@@ -1781,10 +1785,11 @@
// Start args with "debugserver /file/path -r --"
debugserver_args.AppendArgument(debugserver_path);
debugserver_args.AppendArgument(debugserver_url);
- debugserver_args.AppendArgument("--native-regs"); // use native registers, not the GDB registers
- debugserver_args.AppendArgument("--setsid"); // make debugserver run in its own session so
- // signals generated by special terminal key
- // sequences (^C) don't affect debugserver
+ // use native registers, not the GDB registers
+ debugserver_args.AppendArgument("--native-regs");
+ // make debugserver run in its own session so signals generated by
+ // special terminal key sequences (^C) don't affect debugserver
+ debugserver_args.AppendArgument("--setsid");
if (disable_aslr)
debugserver_args.AppendArguments("--disable-aslr");