summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2016-05-31 18:32:20 +0000
committerTodd Fiala <todd.fiala@gmail.com>2016-05-31 18:32:20 +0000
commit7aa4d977eaf3bf8122263227a6af3f5bd32390fd (patch)
treed0493175ab1b57120ff626eb07e4dafa39fd3778
parent4d29099f7f30cb6d16962346741be72f6ab89b1e (diff)
downloadbcm5719-llvm-7aa4d977eaf3bf8122263227a6af3f5bd32390fd.tar.gz
bcm5719-llvm-7aa4d977eaf3bf8122263227a6af3f5bd32390fd.zip
Implement ProcessInfo::Dump(), log gdb-remote stub launch
This change implements dumping the executable, triple, args and environment when using ProcessInfo::Dump(). It also tweaks the way Args::Dump() works so that it prints a configurable label rather than argv[{index}]={value}. By default it behaves the same, but if the Dump() method with the additional arg is provided, it can be overridden. The environment variables dumped as part of ProcessInfo::Dump() make use of that. lldb-server has been modified to dump the gdb-remote stub's ProcessInfo before launching if the "gdb-remote process" channel is logged. llvm-svn: 271312
-rw-r--r--lldb/include/lldb/Interpreter/Args.h10
-rw-r--r--lldb/source/Interpreter/Args.cpp13
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp11
-rw-r--r--lldb/source/Target/ProcessInfo.cpp17
4 files changed, 42 insertions, 9 deletions
diff --git a/lldb/include/lldb/Interpreter/Args.h b/lldb/include/lldb/Interpreter/Args.h
index c55b2f63173..bca53333bc0 100644
--- a/lldb/include/lldb/Interpreter/Args.h
+++ b/lldb/include/lldb/Interpreter/Args.h
@@ -91,14 +91,20 @@ public:
~Args();
//------------------------------------------------------------------
- /// Dump all arguments to the stream \a s.
+ /// Dump all entries to the stream \a s using label \a label_name.
+ ///
+ /// If label_name is nullptr, the dump operation is skipped.
///
/// @param[in] s
/// The stream to which to dump all arguments in the argument
/// vector.
+ /// @param[in] label_name
+ /// The label_name to use as the label printed for each
+ /// entry of the args like so:
+ /// {label_name}[{index}]={value}
//------------------------------------------------------------------
void
- Dump (Stream *s);
+ Dump (Stream &s, const char *label_name = "argv") const;
//------------------------------------------------------------------
/// Sets the command string contained by this object.
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index bd8d5569be4..39426cb17cd 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -83,19 +83,22 @@ Args::~Args ()
}
void
-Args::Dump (Stream *s)
+Args::Dump (Stream &s, const char *label_name) const
{
+ if (!label_name)
+ return;
+
const size_t argc = m_argv.size();
for (size_t i=0; i<argc; ++i)
{
- s->Indent();
+ s.Indent();
const char *arg_cstr = m_argv[i];
if (arg_cstr)
- s->Printf("argv[%zi]=\"%s\"\n", i, arg_cstr);
+ s.Printf("%s[%zi]=\"%s\"\n", label_name, i, arg_cstr);
else
- s->Printf("argv[%zi]=NULL\n", i);
+ s.Printf("%s[%zi]=NULL\n", label_name, i);
}
- s->EOL();
+ s.EOL();
}
bool
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 4689e0bc299..f164b1411be 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1120,7 +1120,7 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url,
{
Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
if (log)
- log->Printf ("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16, __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
+ log->Printf ("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")", __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
Error error;
// If we locate debugserver, keep that located version around
@@ -1352,7 +1352,14 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url,
launch_info.AppendSuppressFileAction (STDIN_FILENO, true, false);
launch_info.AppendSuppressFileAction (STDOUT_FILENO, false, true);
launch_info.AppendSuppressFileAction (STDERR_FILENO, false, true);
-
+
+ if (log)
+ {
+ StreamString string_stream;
+ Platform *const platform = nullptr;
+ launch_info.Dump(string_stream, platform);
+ log->Printf("launch info for gdb-remote stub:\n%s", string_stream.GetString().c_str());
+ }
error = Host::LaunchProcess(launch_info);
if (error.Success() &&
diff --git a/lldb/source/Target/ProcessInfo.cpp b/lldb/source/Target/ProcessInfo.cpp
index 1adb93333fc..214db9ed3d4 100644
--- a/lldb/source/Target/ProcessInfo.cpp
+++ b/lldb/source/Target/ProcessInfo.cpp
@@ -15,6 +15,8 @@
// Project includes
#include "lldb/Target/ProcessInfo.h"
+#include "lldb/Core/Stream.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -65,6 +67,21 @@ ProcessInfo::GetNameLength() const
}
void
+ProcessInfo::Dump (Stream &s, Platform *platform) const
+{
+ s << "Executable: " << GetName() << "\n";
+ s << "Triple: ";
+ m_arch.DumpTriple(s);
+ s << "\n";
+
+ s << "Arguments:\n";
+ m_arguments.Dump(s);
+
+ s << "Environment:\n";
+ m_environment.Dump(s, "env");
+}
+
+void
ProcessInfo::SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg)
{
if (exe_file)
OpenPOWER on IntegriCloud