[nemiver/console] Change of the break command to make it easier to read
- From: Fabien Parent <fparent src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/console] Change of the break command to make it easier to read
- Date: Sat, 3 Mar 2012 09:52:08 +0000 (UTC)
commit 09705aa6dcee0b47af53905cb8263b158471e7a2
Author: Fabien Parent <parent f gmail com>
Date: Sat Mar 3 10:38:27 2012 +0100
Change of the break command to make it easier to read
src/dbgengine/nmv-dbg-console.cc | 116 +++++++++++++++++++++++++-------------
1 files changed, 77 insertions(+), 39 deletions(-)
---
diff --git a/src/dbgengine/nmv-dbg-console.cc b/src/dbgengine/nmv-dbg-console.cc
index 3268262..3fc0791 100644
--- a/src/dbgengine/nmv-dbg-console.cc
+++ b/src/dbgengine/nmv-dbg-console.cc
@@ -413,62 +413,100 @@ struct CommandBreak : public Console::SynchronousCommand {
}
void
- execute (const std::vector<UString> &a_argv, Console::Stream &a_stream)
+ break_at_current_line (Console::Stream &a_stream)
{
IDebugger::Frame &frame = dbg_data.current_frame;
IDebugger &debugger = dbg_data.debugger;
+ if (!frame.file_full_name ().empty ()) {
+ debugger.set_breakpoint (frame.file_full_name (), frame.line ());
+ } else {
+ a_stream << "Cannot set a breakpoint at this position.\n";
+ }
+ }
+
+ void
+ break_at_line (const std::vector<UString> &a_argv,
+ Console::Stream &a_stream)
+ {
+ IDebugger &debugger = dbg_data.debugger;
+
+ if (!dbg_data.current_file_path.empty ()) {
+ debugger.set_breakpoint (dbg_data.current_file_path,
+ str_utils::from_string<int> (a_argv[0]));
+ } else {
+ a_stream << "Cannot set a breakpoint at this position.\n";
+ }
+ }
+
+ void
+ break_at_offset (const std::vector<UString> &a_argv,
+ Console::Stream &a_stream)
+ {
+ IDebugger::Frame &frame = dbg_data.current_frame;
+ IDebugger &debugger = dbg_data.debugger;
+
+ if (frame.file_full_name ().empty ()) {
+ a_stream << "Cannot set a breakpoint at this position.\n";
+ return;
+ }
+
+ std::string offset (a_argv[0].substr (1));
+ if (!str_utils::string_is_decimal_number (offset)) {
+ a_stream << "Invalid offset: " << offset << ".\n";
+ return;
+ }
+
+ int line = frame.line ();
+ if (a_argv[0][0] == '+') {
+ line += str_utils::from_string<int> (offset);
+ } else {
+ line -= str_utils::from_string<int> (offset);
+ }
+
+ debugger.set_breakpoint (frame.file_full_name (), line);
+ }
+
+ void
+ break_at_address (const std::vector<UString> &a_argv,
+ Console::Stream &a_stream)
+ {
+ IDebugger &debugger = dbg_data.debugger;
+
+ std::string addr (a_argv[0].substr (1));
+ if (str_utils::string_is_hexa_number (addr)) {
+ Address address (addr);
+ debugger.set_breakpoint (address);
+ } else {
+ a_stream << "Invalid address: " << addr << ".\n";
+ }
+ }
+
+ void
+ execute (const std::vector<UString> &a_argv, Console::Stream &a_stream)
+ {
+ IDebugger &debugger = dbg_data.debugger;
+
if (a_argv.size () > 1) {
a_stream << "Too much parameters.\n";
return;
- } else if (a_argv.size () == 0) {
- if (!frame.file_full_name ().empty ()) {
- debugger.set_breakpoint
- (frame.file_full_name (), frame.line ());
- } else {
- a_stream << "Cannot set a breakpoint at this position.\n";
- }
+ }
+
+ if (a_argv.size () == 0) {
+ break_at_current_line (a_stream);
return;
}
const char first_param_char = a_argv[0][0];
if (str_utils::string_is_number (a_argv[0])) {
- if (!dbg_data.current_file_path.empty ()) {
- debugger.set_breakpoint
- (dbg_data.current_file_path,
- str_utils::from_string<int> (a_argv[0]));
- } else {
- a_stream << "Cannot set a breakpoint at this position.\n";
- }
+ break_at_line (a_argv, a_stream);
} else if ((first_param_char >= 'a' && first_param_char <= 'z')
|| first_param_char == '_') {
debugger.set_breakpoint (a_argv[0]);
} else if (first_param_char == '*') {
- std::string addr (a_argv[0].substr (1));
- if (str_utils::string_is_hexa_number (addr)) {
- Address address (addr);
- debugger.set_breakpoint (address);
- } else {
- a_stream << "Invalid address: " << addr << ".\n";
- }
+ break_at_address (a_argv, a_stream);
} else if (first_param_char == '+' || first_param_char == '-') {
- std::string offset (a_argv[0].substr (1));
- if (str_utils::string_is_decimal_number (offset)) {
- int line = frame.line ();
- if (first_param_char == '+') {
- line += str_utils::from_string<int> (offset);
- } else {
- line -= str_utils::from_string<int> (offset);
- }
-
- if (!frame.file_full_name ().empty ()) {
- debugger.set_breakpoint (frame.file_full_name (), line);
- } else {
- a_stream << "Cannot set a breakpoint at this position.\n";
- }
- } else {
- a_stream << "Invalid offset: " << offset << ".\n";
- }
+ break_at_offset (a_argv, a_stream);
} else {
a_stream << "Invalid argument: " << a_argv[0] << ".\n";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]