[PATCH] 698371 Run command is available even after detaching
- From: Dodji Seketeli <dodji seketeli org>
- To: Nemiver Development <nemiver-list gnome org>
- Subject: [PATCH] 698371 Run command is available even after detaching
- Date: Sun, 13 Oct 2013 13:49:38 +0200
Hello,
In this apparently seamless bug[1], Nemiver wouldn't properly update the
sensitivity of the File -> Detach menu item, leaving it clickable even
after Nemiver was detached from the target.
[1]: https://bugzilla.gnome.org/show_bug.cgi?id=698371
Fixed thus, tested and applied to master.
* src/dbgengine/nmv-gdb-engine.h (GDBengine::reset_command_queue):
New entry point.
* src/dbgengine/nmv-gdb-engine.cc
(GDBEngine::reset_command_queue): Implement this new entry point.
(GDBEngine::load_program): Use this new reset_command_queue entry
point.
(GDBEngine::detach_from_target): Normally, the inferior must be
stopped before accepting commands; soo to accept the "detach"
command, the target must be stopped too. Thus, if the target is
not stopped, let's stop it first by sending it a SIGINT signal,
end schedule the detach command to be sent to GDB right after
that.
(OnDetachHandler::do_handle): Reset command queue upon detach.
* src/persp/dbgperspective/nmv-dbg-perspective.cc
(DBGPerspective::init_actions): Remove the
s_target_not_started_action_entries. Move the RunMenuItemAction
into the s_debugger_ready_action_entries object. Remove
m_priv->target_not_started_action_group.
(DBGPerspective::on_engine_died_signal)
(DBGPerspective::update_action_group_sensitivity): Adjust for
removing the target_not_started_action_group action group.
(DBGPerspective::on_debugger_detached_from_target_signal): Closed
opened file only upon detach from target. Adjust for removing the
target_not_started_action_group action group.
---
src/dbgengine/nmv-gdb-engine.cc | 39 +++++++++++++++++++-
src/dbgengine/nmv-gdb-engine.h | 2 ++
src/persp/dbgperspective/nmv-dbg-perspective.cc | 48 +++++++------------------
3 files changed, 52 insertions(+), 37 deletions(-)
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 008e85a..201f3fe 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -1407,6 +1407,24 @@ struct OnDetachHandler : OutputHandler {
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
THROW_IF_FAIL (m_engine);
+ /// So at this point we've been detached from the target. To
+ /// perform that detachment, we might have first sent a SIGINT
+ /// to the target (making it to stop) and then, in a second
+ /// step, sent the detach command. One must understand that
+ /// upon the stop (incurred by the SIGINT) many commands are
+ /// scheduled by the Nemiver front end to get the context of
+ /// the stop; The thing is, we don't need these commands and
+ /// they might even cause havoc b/c they might be sent to the
+ /// target after this point -- but we are not connected to the
+ /// target anymore! So let's just drop these commands.
+ ///
+ /// FIXME: So this is a hack, btw. I think the proper way to
+ /// do this is to define a new kind of StopReason, like
+ /// SIGNAL_RECEIVED_BEFORE_COMMAND. That way, handling code
+ /// called by the IDebugger::stopped_signal knows that we are
+ /// getting stopped just to be able to issue a command to
+ /// GDB; it can thus avoid querying context from IDebugger.
+ m_engine->reset_command_queue();
m_engine->detached_from_target_signal ().emit ();
m_engine->set_state (IDebugger::NOT_STARTED);
}
@@ -3209,7 +3227,7 @@ GDBEngine::load_program (const UString &a_prog,
// queue might be stuck. Let's restart it.
if (a_force) {
LOG_DD ("Reset command queue");
- m_priv->reset_command_queue ();
+ reset_command_queue ();
}
if (m_priv->launch_gdb_and_set_args (a_working_dir,
@@ -3343,6 +3361,14 @@ GDBEngine::detach_from_target (const UString &a_cookie)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
+ if (is_attached_to_target ()
+ && get_state () == IDebugger::RUNNING)
+ {
+ LOG_DD ("Requesting GDB to stop ...");
+ stop_target ();
+ LOG_DD ("DONE");
+ }
+
queue_command (Command ("detach-from-target", "-target-detach", a_cookie));
}
@@ -3474,6 +3500,17 @@ GDBEngine::get_mi_thread_and_frame_location (UString &a_str) const
LOG_DD ("a_str: " << a_str);
}
+/// Clear the comamnd queue. That means that all the commands that
+/// got queued for submission to GDB will be erased. Do not use this
+/// function. Ever. Unless you know what you are doing.
+void
+GDBEngine::reset_command_queue ()
+{
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ m_priv->reset_command_queue();
+}
+
void
GDBEngine::get_mi_thread_location (UString &a_str) const
{
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 2c5d97e..e79fe7f 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -359,6 +359,8 @@ public:
void get_mi_thread_and_frame_location (UString &a_str) const;
+ void reset_command_queue ();
+
void step_over (const UString &a_cookie);
void step_in (const UString &a_cookie);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index b92cd9d..5ad3ff0 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -892,7 +892,6 @@ struct DBGPerspective::Priv {
SafePtr<Gtk::HPaned> context_paned;
Glib::RefPtr<Gtk::ActionGroup> default_action_group;
- Glib::RefPtr<Gtk::ActionGroup> target_not_started_action_group;
Glib::RefPtr<Gtk::ActionGroup> inferior_loaded_action_group;
Glib::RefPtr<Gtk::ActionGroup> detach_action_group;
Glib::RefPtr<Gtk::ActionGroup> opened_file_action_group;
@@ -2332,6 +2331,8 @@ DBGPerspective::on_debugger_detached_from_target_signal ()
NEMIVER_TRY;
+ if (get_num_notebook_pages ())
+ close_opened_files ();
clear_status_notebook (true);
workbench ().set_title_extension ("");
//****************************
@@ -2343,7 +2344,6 @@ DBGPerspective::on_debugger_detached_from_target_signal ()
m_priv->debugger_ready_action_group->set_sensitive (false);
m_priv->debugger_busy_action_group->set_sensitive (false);
m_priv->inferior_loaded_action_group->set_sensitive (false);
- m_priv->target_not_started_action_group->set_sensitive (true);
NEMIVER_CATCH
}
@@ -2532,7 +2532,6 @@ DBGPerspective::on_engine_died_signal ()
m_priv->debugger_engine_alive = false;
- m_priv->target_not_started_action_group->set_sensitive (true);
m_priv->debugger_ready_action_group->set_sensitive (false);
m_priv->debugger_busy_action_group->set_sensitive (false);
m_priv->inferior_loaded_action_group->set_sensitive (false);
@@ -2997,7 +2996,6 @@ DBGPerspective::update_action_group_sensitivity (IDebugger::State a_state)
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (m_priv->debugger_ready_action_group);
- THROW_IF_FAIL (m_priv->target_not_started_action_group);
THROW_IF_FAIL (m_priv->debugger_busy_action_group);
THROW_IF_FAIL (m_priv->throbber);
@@ -3007,7 +3005,6 @@ DBGPerspective::update_action_group_sensitivity (IDebugger::State a_state)
workbench ().get_root_window ().get_window ()->set_cursor ();
m_priv->default_action_group->set_sensitive (true);
m_priv->detach_action_group->set_sensitive (false);
- m_priv->target_not_started_action_group->set_sensitive (true);
m_priv->inferior_loaded_action_group->set_sensitive (false);
m_priv->debugger_busy_action_group->set_sensitive (false);
m_priv->debugger_ready_action_group->set_sensitive (false);
@@ -3018,7 +3015,6 @@ DBGPerspective::update_action_group_sensitivity (IDebugger::State a_state)
// reset to default cursor
workbench ().get_root_window ().get_window ()->set_cursor ();
m_priv->detach_action_group->set_sensitive (false);
- m_priv->target_not_started_action_group->set_sensitive (true);
m_priv->inferior_loaded_action_group->set_sensitive (true);
m_priv->debugger_busy_action_group->set_sensitive (false);
m_priv->debugger_ready_action_group->set_sensitive (false);
@@ -3028,13 +3024,11 @@ DBGPerspective::update_action_group_sensitivity (IDebugger::State a_state)
// reset to default cursor
workbench ().get_root_window ().get_window ()->set_cursor ();
m_priv->detach_action_group->set_sensitive (true);
- m_priv->target_not_started_action_group->set_sensitive (true);
m_priv->inferior_loaded_action_group->set_sensitive (true);
m_priv->debugger_ready_action_group->set_sensitive (true);
m_priv->debugger_busy_action_group->set_sensitive (false);
} else if (a_state == IDebugger::RUNNING){
m_priv->detach_action_group->set_sensitive (true);
- m_priv->target_not_started_action_group->set_sensitive (false);
m_priv->inferior_loaded_action_group->set_sensitive (false);
m_priv->debugger_ready_action_group->set_sensitive (false);
m_priv->debugger_busy_action_group->set_sensitive (true);
@@ -3042,7 +3036,6 @@ DBGPerspective::update_action_group_sensitivity (IDebugger::State a_state)
m_priv->throbber->stop ();
// reset to default cursor
workbench ().get_root_window ().get_window ()->set_cursor ();
- m_priv->target_not_started_action_group->set_sensitive (true);
m_priv->inferior_loaded_action_group->set_sensitive (true);
m_priv->debugger_ready_action_group->set_sensitive (false);
m_priv->debugger_busy_action_group->set_sensitive (false);
@@ -3168,19 +3161,6 @@ DBGPerspective::init_actions ()
Gtk::StockID nil_stock_id ("");
sigc::slot<void> nil_slot;
- static ui_utils::ActionEntry s_target_not_started_action_entries [] = {
- {
- "RunMenuItemAction",
- Gtk::Stock::REFRESH,
- _("_Run or Restart"),
- _("Run or Restart the target"),
- sigc::mem_fun (*this, &DBGPerspective::on_run_action),
- ActionEntry::DEFAULT,
- "<shift>F5",
- true
- }
- };
-
static ui_utils::ActionEntry s_detach_action_entries [] = {
{
"DetachFromProgramMenuItemAction",
@@ -3354,6 +3334,16 @@ DBGPerspective::init_actions ()
false
},
{
+ "RunMenuItemAction",
+ Gtk::Stock::REFRESH,
+ _("_Run or Restart"),
+ _("Run or Restart the target"),
+ sigc::mem_fun (*this, &DBGPerspective::on_run_action),
+ ActionEntry::DEFAULT,
+ "<shift>F5",
+ true
+ },
+ {
"ContinueMenuItemAction",
Gtk::Stock::EXECUTE,
_("_Continue"),
@@ -3721,10 +3711,6 @@ DBGPerspective::init_actions ()
Gtk::ActionGroup::create ("inferior-loaded-action-group");
m_priv->inferior_loaded_action_group->set_sensitive (false);
- m_priv->target_not_started_action_group =
- Gtk::ActionGroup::create ("target-not-started-action-group");
- m_priv->target_not_started_action_group->set_sensitive (false);
-
m_priv->debugger_ready_action_group =
Gtk::ActionGroup::create ("debugger-ready-action-group");
m_priv->debugger_ready_action_group->set_sensitive (false);
@@ -3754,11 +3740,6 @@ DBGPerspective::init_actions ()
m_priv->inferior_loaded_action_group);
ui_utils::add_action_entries_to_action_group
- (s_target_not_started_action_entries,
- G_N_ELEMENTS (s_target_not_started_action_entries),
- m_priv->target_not_started_action_group);
-
- ui_utils::add_action_entries_to_action_group
(s_debugger_ready_action_entries,
G_N_ELEMENTS (s_debugger_ready_action_entries),
m_priv->debugger_ready_action_group);
@@ -3783,8 +3764,6 @@ DBGPerspective::init_actions ()
workbench ().get_ui_manager ()->insert_action_group
(m_priv->inferior_loaded_action_group);
workbench ().get_ui_manager ()->insert_action_group
- (m_priv->target_not_started_action_group);
- workbench ().get_ui_manager ()->insert_action_group
(m_priv->debugger_busy_action_group);
workbench ().get_ui_manager ()->insert_action_group
(m_priv->debugger_ready_action_group);
@@ -6516,9 +6495,6 @@ DBGPerspective::detach_from_program ()
debugger ()->disconnect_from_remote_target ();
else
debugger ()->detach_from_target ();
-
- close_opened_files ();
- clear_status_notebook (false);
}
void
--
Dodji
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]