[nemiver/count-point: 5/14] Continuing excecution at a countpoint done by GDB
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/count-point: 5/14] Continuing excecution at a countpoint done by GDB
- Date: Sun, 10 Oct 2010 16:36:33 +0000 (UTC)
commit 0b3f170633fd51fc608a37df2297ca6a988d1827
Author: Dodji Seketeli <dodji seketeli org>
Date: Sat Oct 9 14:04:22 2010 +0200
Continuing excecution at a countpoint done by GDB
* src/dbgengine/nmv-gdb-engine.h
(GDBEngine::maybe_handle_countpoint): Remove.
* src/dbgengine/nmv-gdb-engine.cc
(GDBEngine::enable_countpoint): Associate a continue command to
the breakpoint when asked to turn it into a countpoint. When the
countpoint is hit GDB should now continue directly without
triggering a state change in Nemiver. This should be a lot faster
than notifying Nemiver of each stop and then Nemiver telling GDB
to continue.
(GDBEngine::on_stopped_signal): Don't tell GDB to continue when
it's stopped at a countpoint. This is now handled by GDB itself
thanks to GDBEngine::enable_countpoint.
(GDBEngine::maybe_handle_countpoint): Remove.
(OnCommandDoneHandler::flag_breakpoint_as_countpoint): New
function.
(OnCommandDoneHandler::can_handle): Once the "enable-countpoint"
or "disable-countpoint" command is sent to GDB for a given
breakpoint, flag the Nemiver-side breakpoint as being a
countpoint. GDB doesn't make any distinction otherwise. Emit
IDebugger::breakpoints_set_signal. This is not semantically
correct. Ideally we'd need to have a signal "breakpoint changed"
or something along that line. I guess it will take a "Breakpoint
signals reorganisation" patchset to address this.
(OnBreakpointHandler::do_handle): Instead of just flagging
a Nemiver-side breakpoint as a countpoint, call
IDebugger::enable_countpoint on that that should do the right
thing.
src/dbgengine/nmv-gdb-engine.cc | 94 +++++++++++++++++++++++----------------
src/dbgengine/nmv-gdb-engine.h | 2 -
2 files changed, 55 insertions(+), 41 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index f776b28..b402cfc 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -1210,15 +1210,17 @@ struct OnBreakpointHandler: OutputHandler {
bool has_breaks = false;
//if breakpoint where set, put them in cache !
if (has_breakpoints_set (a_in)) {
+ LOG_DD ("adding BPs to cache");
+ m_engine->append_breakpoints_to_cache
+ (a_in.output ().result_record ().breakpoints ());
if (a_in.command ().name () == "set-countpoint") {
THROW_IF_FAIL (a_in.output ().result_record ().
breakpoints ().size () == 1);
- a_in.output ().result_record ().
- breakpoints ().begin ()->second.type
- (IDebugger::Breakpoint::COUNTPOINT_TYPE);
+ m_engine->enable_countpoint
+ (a_in.output ().result_record ().
+ breakpoints ().begin ()->second.number (),
+ true);
}
- m_engine->append_breakpoints_to_cache
- (a_in.output ().result_record ().breakpoints ());
has_breaks = true;
}
@@ -1465,6 +1467,27 @@ struct OnCommandDoneHandler : OutputHandler {
m_engine (a_engine)
{}
+ bool flag_breakpoint_as_countpoint (int a_break_num,
+ bool a_yes)
+ {
+ typedef map<int, IDebugger::Breakpoint> BPMap;
+ BPMap &bp_cache = m_engine->get_cached_breakpoints ();
+ BPMap::const_iterator nil = bp_cache.end ();
+
+ BPMap::iterator it = bp_cache.find (a_break_num);
+ if (it == nil)
+ return false;
+
+ if (a_yes && it->second.type ()
+ == IDebugger::Breakpoint::STANDARD_BREAKPOINT_TYPE)
+ it->second.type (IDebugger::Breakpoint::COUNTPOINT_TYPE);
+ else
+ it->second.type
+ (IDebugger::Breakpoint::STANDARD_BREAKPOINT_TYPE);
+
+ return true;
+ }
+
bool can_handle (CommandAndOutput &a_in)
{
if (a_in.output ().has_result_record () &&
@@ -1485,6 +1508,19 @@ struct OnCommandDoneHandler : OutputHandler {
if (a_in.command ().name () == "select-frame") {
m_engine->set_current_frame_level (a_in.command ().tag2 ());
}
+ if (a_in.command ().name () == "enable-countpoint"
+ || a_in.command ().name () == "disable-countpoint") {
+ if (a_in.command ().name () == "enable-countpoint") {
+ IDebugger::Breakpoint bp;
+ flag_breakpoint_as_countpoint (a_in.command ().tag2 (), true);
+ } else if (a_in.command ().name () == "disable-countpoint") {
+ flag_breakpoint_as_countpoint (a_in.command ().tag2 (), false);
+ }
+
+ m_engine->breakpoints_set_signal ().emit
+ (m_engine->get_cached_breakpoints (),
+ a_in.command ().cookie ());
+ }
m_engine->command_done_signal ().emit (a_in.command ().name (),
a_in.command ().cookie ());
@@ -3275,28 +3311,6 @@ GDBEngine::on_got_target_info_signal (int a_pid, const UString &a_exe_path)
NEMIVER_CATCH_NOX
}
-/// If the given breakpoint is a countpoint, continue the execution of
-/// the inferior. This is a subroutine of GDBEngine::on_stopped_signal.
-/// \param a_reason the reason why the inferior stopped its execution.
-/// \param a_breakpoint_num the number of the breakpoint to consider.
-void
-GDBEngine::maybe_handle_countpoint (IDebugger::StopReason a_reason,
- int a_breakpoint_num)
-{
- if (a_reason != IDebugger::BREAKPOINT_HIT)
- return;
-
- map<int, IDebugger::Breakpoint>::const_iterator it, nil =
- get_cached_breakpoints ().end ();
- it = get_cached_breakpoints ().find (a_breakpoint_num);
- THROW_IF_FAIL (it != nil);
-
- if (it->second.type () != IDebugger::Breakpoint::COUNTPOINT_TYPE)
- return;
-
- do_continue ("");
-}
-
void
GDBEngine::on_stopped_signal (IDebugger::StopReason a_reason,
bool a_has_frame,
@@ -3321,10 +3335,6 @@ GDBEngine::on_stopped_signal (IDebugger::StopReason a_reason,
m_priv->is_attached = true;
- // If we stopped on a breakpoint marked as a countpoint, let's
- // continue the execution.
- maybe_handle_countpoint (a_reason, a_bkpt_num);
-
NEMIVER_CATCH_NOX
}
@@ -3780,17 +3790,23 @@ GDBEngine::enable_countpoint (gint a_break_num,
BPMap &bp_cache = get_cached_breakpoints ();
BPMap::const_iterator nil = bp_cache.end ();
- BPMap::iterator it = bp_cache.find (a_break_num);
- if (it == nil)
+ if (bp_cache.find (a_break_num) == nil)
return;
- if (a_yes && it->second.type ()
- == IDebugger::Breakpoint::STANDARD_BREAKPOINT_TYPE)
- it->second.type (IDebugger::Breakpoint::COUNTPOINT_TYPE);
- else
- it->second.type (IDebugger::Breakpoint::STANDARD_BREAKPOINT_TYPE);
+ std::ostringstream command_str;
+ UString command_name;
- breakpoints_set_signal ().emit (get_cached_breakpoints (), a_cookie);
+ if (a_yes) {
+ command_str << "-break-commands " << a_break_num << " \"continue\"";
+ command_name = "enable-countpoint";
+ } else {
+ command_str << "-break-commands " << a_break_num << " \"\"";
+ command_name = "disable-countpoint";
+ }
+ Command command (command_name, command_str.str (), a_cookie);
+ command.tag2 (a_break_num);
+ queue_command (command);
+}
}
void
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 6202d2e..e92ed6d 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -224,8 +224,6 @@ public:
//for internal use
void init ();
- void maybe_handle_countpoint (IDebugger::StopReason a_reason,
- int a_breakpoint_num);
// to be called by client code
void do_init (IConfMgrSafePtr a_conf_mgr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]