summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-10-19 17:03:58 +0000
committerGreg Clayton <gclayton@apple.com>2010-10-19 17:03:58 +0000
commitadd29982be9435be3ce7815e96d6dcb238207584 (patch)
tree5a717d7e9b5c1ebd4d1620878efa1b9ae19a8b17
parentd89b01e52196d527b31e24803b91ac805bf0b214 (diff)
downloadbcm5719-llvm-add29982be9435be3ce7815e96d6dcb238207584.tar.gz
bcm5719-llvm-add29982be9435be3ce7815e96d6dcb238207584.zip
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
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj1
-rw-r--r--lldb/source/Host/macosx/Host.mm90
-rw-r--r--lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj1
3 files changed, 90 insertions, 2 deletions
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index 4c898f70714..a0caa4a8d66 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -2490,7 +2490,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm
index 8dec00b4867..b9f6235c5f5 100644
--- a/lldb/source/Host/macosx/Host.mm
+++ b/lldb/source/Host/macosx/Host.mm
@@ -159,6 +159,8 @@ Host::LaunchApplication (const FileSpec &app_file_spec)
error = ::GetProcessPID(&psn, &pid);
return pid;
}
+#define LLDB_HOST_USE_APPLESCRIPT
+#if defined (LLDB_HOST_USE_APPLESCRIPT)
lldb::pid_t
Host::LaunchInNewTerminal
@@ -172,6 +174,93 @@ Host::LaunchInNewTerminal
{
if (!argv || !argv[0])
return LLDB_INVALID_PROCESS_ID;
+
+ std::string unix_socket_name;
+
+ char temp_file_path[PATH_MAX] = "/tmp/XXXXXX";
+ if (::mktemp (temp_file_path) == NULL)
+ return LLDB_INVALID_PROCESS_ID;
+
+ unix_socket_name.assign (temp_file_path);
+
+ StreamString command;
+
+ FileSpec darwin_debug_file_spec;
+ if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec))
+ return LLDB_INVALID_PROCESS_ID;
+ darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
+
+ if (!darwin_debug_file_spec.Exists())
+ return LLDB_INVALID_PROCESS_ID;
+
+ char launcher_path[PATH_MAX];
+ darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
+ command.Printf ("tell application \"Terminal\"\n do script \"'%s'", launcher_path);
+
+ command.Printf(" --unix-socket=%s", unix_socket_name.c_str());
+
+ if (arch_spec && arch_spec->IsValid())
+ {
+ command.Printf(" --arch=%s", arch_spec->AsCString());
+ }
+
+ if (disable_aslr)
+ {
+ command.PutCString(" --disable-aslr");
+ }
+
+ command.PutCString(" --");
+
+ if (argv)
+ {
+ for (size_t i=0; argv[i] != NULL; ++i)
+ {
+ command.Printf(" '%s'", argv[i]);
+ }
+ }
+ command.PutCString (" ; exit\"\nend tell\n");
+ const char *script_source = command.GetString().c_str();
+ NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]];
+
+ lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+
+ Error lldb_error;
+ // Sleep and wait a bit for debugserver to start to listen...
+ ConnectionFileDescriptor file_conn;
+ char connect_url[128];
+ ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str());
+
+ [applescript executeAndReturnError:nil];
+ if (file_conn.Connect(connect_url, &lldb_error) == eConnectionStatusSuccess)
+ {
+ char pid_str[256];
+ ::bzero (pid_str, sizeof(pid_str));
+ ConnectionStatus status;
+ const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL);
+ if (pid_str_len > 0)
+ {
+ pid = atoi (pid_str);
+ // Sleep for a bit to allow the process to exec and stop at the entry point...
+ sleep(1);
+ }
+ }
+ [applescript release];
+ return pid;
+}
+
+#else
+lldb::pid_t
+Host::LaunchInNewTerminal
+(
+ const char **argv,
+ const char **envp,
+ const ArchSpec *arch_spec,
+ bool stop_at_entry,
+ bool disable_aslr
+)
+{
+ if (!argv || !argv[0])
+ return LLDB_INVALID_PROCESS_ID;
OSStatus error = 0;
@@ -300,6 +389,7 @@ Host::LaunchInNewTerminal
}
return pid;
}
+#endif
bool
Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
diff --git a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
index 9cbe29e084b..6c5d9738175 100644
--- a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -369,7 +369,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
OpenPOWER on IntegriCloud