[nemiver] Don't forget the CWD when restarting a session
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver] Don't forget the CWD when restarting a session
- Date: Wed, 13 Oct 2010 19:11:14 +0000 (UTC)
commit 22f71fced86495571a4331d7b4f0f59513d202a5
Author: Dodji Seketeli <dodji seketeli org>
Date: Wed Oct 13 20:35:13 2010 +0200
Don't forget the CWD when restarting a session
* src/dbgengine/nmv-gdb-engine.cc (GDBEnging::Priv::launch_gdb):
When the path to the program to launch is neither found nor
absolute, Look for it in the workding dir before looking it up in
PATH.
* src/persp/dbgperspective/nmv-dbg-perspective.cc
(DBGPerspective::execute_session): Restore the CWD from the
session.
(DBGPerspective::connect_to_remote_target): Take the CWD in
account when loading the local binary.
src/dbgengine/nmv-gdb-engine.cc | 14 ++++++++++++--
src/persp/dbgperspective/nmv-dbg-perspective.cc | 22 ++++++++++++++++------
2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index d7429ae..262201a 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -627,11 +627,21 @@ public:
argv.clear ();
UString prog_path;
- if (a_prog != "") {
+ if (!a_prog.empty ()) {
prog_path = a_prog;
if (!Glib::file_test (Glib::filename_from_utf8 (prog_path),
Glib::FILE_TEST_IS_REGULAR)) {
- if (!find_prog_in_path (prog_path, prog_path)) {
+ // So we haven't found the file. Let's look for it in
+ // the current working directory and in the PATH.
+ bool found = false;
+ if (!working_dir.empty ()) {
+ list<UString> where;
+ where.push_back (working_dir);
+ if (common::env::find_file (prog_path, where, prog_path))
+ found = true;
+ }
+
+ if (!found && !find_prog_in_path (prog_path, prog_path)) {
LOG_ERROR ("Could not find program '" << prog_path << "'");
return false;
}
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index cebaf21..d0bcc8d 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -5977,6 +5977,8 @@ DBGPerspective::execute_session (ISessMgr::Session &a_session)
close_opened_files ();
}
+ m_priv->prog_cwd = a_session.properties ()[PROGRAM_CWD];
+
IDebugger::Breakpoint breakpoint;
vector<IDebugger::Breakpoint> breakpoints;
for (list<ISessMgr::Breakpoint>::const_iterator it =
@@ -6337,10 +6339,6 @@ DBGPerspective::connect_to_remote_target ()
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
- if (m_priv->prog_cwd == "") {
- m_priv->prog_cwd = Glib::filename_to_utf8 (Glib::get_current_dir ());
- }
-
RemoteTargetDialog dialog (plugin_path ());
// try to pre-fill the remote target dialog with the relevant info
@@ -6378,9 +6376,15 @@ DBGPerspective::connect_to_remote_target (const UString &a_server_address,
THROW_IF_FAIL (debugger ());
save_current_session ();
+
+ if (m_priv->prog_cwd.empty ())
+ m_priv->prog_cwd = Glib::filename_to_utf8 (Glib::get_current_dir ());
+
LOG_DD ("executable path: '" << a_prog_path << "'");
vector<UString> args;
- if (debugger ()->load_program (a_prog_path , args, ".") == false) {
+
+ if (debugger ()->load_program (a_prog_path , args,
+ m_priv->prog_cwd) == false) {
UString message;
message.printf (_("Could not load program: %s"),
a_prog_path.c_str ());
@@ -6407,9 +6411,15 @@ DBGPerspective::connect_to_remote_target (const UString &a_serial_line,
THROW_IF_FAIL (debugger ());
save_current_session ();
+
+ if (m_priv->prog_cwd.empty ())
+ m_priv->prog_cwd = Glib::filename_to_utf8 (Glib::get_current_dir ());
+
LOG_DD ("executable path: '" << a_prog_path << "'");
+
vector<UString> args;
- if (debugger ()->load_program (a_prog_path , args, ".") == false) {
+ if (debugger ()->load_program (a_prog_path , args,
+ m_priv->prog_cwd) == false) {
UString message;
message.printf (_("Could not load program: %s"),
a_prog_path.c_str ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]