nemiver r944 - in trunk: . src/dbgengine tests
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r944 - in trunk: . src/dbgengine tests
- Date: Thu, 13 Nov 2008 13:13:21 +0000 (UTC)
Author: dodji
Date: Thu Nov 13 13:13:21 2008
New Revision: 944
URL: http://svn.gnome.org/viewvc/nemiver?rev=944&view=rev
Log:
560377 - support new running async output record
Modified:
trunk/ChangeLog
trunk/src/dbgengine/nmv-gdbmi-parser.cc
trunk/src/dbgengine/nmv-gdbmi-parser.h
trunk/tests/test-gdbmi.cc
Modified: trunk/src/dbgengine/nmv-gdbmi-parser.cc
==============================================================================
--- trunk/src/dbgengine/nmv-gdbmi-parser.cc (original)
+++ trunk/src/dbgengine/nmv-gdbmi-parser.cc Thu Nov 13 13:13:21 2008
@@ -32,12 +32,21 @@
static const UString GDBMI_OUTPUT_DOMAIN = "gdbmi-output-domain";
#define LOG_PARSING_ERROR(a_buf, a_from) \
-{ \
+do { \
Glib::ustring str_01 (a_buf, (a_from), a_buf.size () - (a_from));\
LOG_ERROR ("parsing failed for buf: >>>" \
<< a_buf << "<<<" \
<< " cur index was: " << (int)(a_from)); \
-}
+} while (0)
+
+#define LOG_PARSING_ERROR_MSG(a_buf, a_from, msg) \
+do { \
+Glib::ustring str_01 (a_buf, (a_from), a_buf.size () - (a_from));\
+LOG_ERROR ("parsing failed for buf: >>>" \
+ << a_buf << "<<<" \
+ << " cur index was: " << (int)(a_from) \
+ << ", reason: " << msg); \
+} while (0)
#define CHECK_END(a_input, a_current, a_end) \
if ((a_current) >= (a_end)) {\
@@ -89,6 +98,8 @@
const char* PREFIX_CHANGED_REGISTERS = "changed-registers=";
const char* PREFIX_REGISTER_VALUES = "register-values=";
const char* PREFIX_MEMORY_VALUES = "addr=";
+const char* PREFIX_RUNNING_ASYNC_OUTPUT = "*running,";
+const char* PREFIX_STOPPED_ASYNC_OUTPUT = "*stopped,";
bool parse_c_string_body (const UString &a_input,
UString::size_type a_from,
@@ -2656,7 +2667,8 @@
if (cur >= end) {return false;}
- if (a_input.compare (cur, 9,"*stopped,")) {
+ if (a_input.raw ().compare (cur, strlen (PREFIX_STOPPED_ASYNC_OUTPUT),
+ PREFIX_STOPPED_ASYNC_OUTPUT)) {
LOG_PARSING_ERROR (a_input, cur);
return false;
}
@@ -2667,7 +2679,7 @@
bool got_frame (false);
IDebugger::Frame frame;
while (true) {
- if (!a_input.compare (cur, strlen (PREFIX_FRAME), PREFIX_FRAME)) {
+ if (!a_input.raw ().compare (cur, strlen (PREFIX_FRAME), PREFIX_FRAME)) {
if (!parse_frame (a_input, cur, cur, frame)) {
LOG_PARSING_ERROR (a_input, cur);
return false;
@@ -2701,6 +2713,48 @@
return true;
}
+/// parse GDBMI async output that says that the inferior process
+/// is running.
+/// the string looks like:
+/// *running,thread-id="<thread-id>"
+/// Note that <thread-id> is either a number, or the string 'all'.
+bool
+parse_running_async_output (const UString &a_input,
+ UString::size_type a_from,
+ UString::size_type &a_to,
+ int &a_thread_id)
+{
+ LOG_FUNCTION_SCOPE_NORMAL_D (GDBMI_PARSING_DOMAIN);
+
+ UString::size_type cur=a_from, end=a_input.size ();
+
+ if (cur >= end) {return false;}
+
+ if (a_input.raw (). compare (cur, strlen (PREFIX_RUNNING_ASYNC_OUTPUT),
+ PREFIX_RUNNING_ASYNC_OUTPUT)) {
+ LOG_PARSING_ERROR_MSG (a_input, cur, "was expecting : '*running,'");
+ return false;
+ }
+ cur += 9; if (cur >= end) {return false;}
+
+ UString name, value;
+ if (!parse_attribute (a_input, cur, cur, name, value)) {
+ LOG_PARSING_ERROR_MSG (a_input, cur, "was expecting an attribute");
+ return false;
+ }
+ if (name != "thread-id") {
+ LOG_PARSING_ERROR_MSG (a_input, cur, "was expecting attribute 'thread-id'");
+ return false;
+ }
+ if (value == "all")
+ a_thread_id = -1;
+ else
+ a_thread_id = atoi (value.c_str ());
+
+ a_to = cur;
+ return true;
+}
+
IDebugger::StopReason
str_to_stopped_reason (const UString &a_str)
{
@@ -2769,12 +2823,15 @@
++cur;//consume the '\n' character
}
- if (!a_input.raw ().compare (cur, 9,"*stopped,")) {
+ if (!a_input.raw ().compare (cur, strlen (PREFIX_STOPPED_ASYNC_OUTPUT),
+ PREFIX_STOPPED_ASYNC_OUTPUT)) {
map<UString, UString> attrs;
bool got_frame (false);
IDebugger::Frame frame;
if (!parse_stopped_async_output (a_input, cur, cur,
got_frame, frame, attrs)) {
+ LOG_PARSING_ERROR_MSG (a_input, cur,
+ "could not parse the expected stopped async output");
return false;
}
record.is_stopped (true);
@@ -2790,8 +2847,23 @@
record.thread_id (atoi (attrs["thread-id"].c_str ()));
record.signal_type (attrs["signal-name"]);
record.signal_meaning (attrs["signal-meaning"]);
+ goto end;
+ }
+
+ if (!a_input.raw ().compare (cur, strlen (PREFIX_RUNNING_ASYNC_OUTPUT),
+ PREFIX_RUNNING_ASYNC_OUTPUT)) {
+ int thread_id;
+ if (!parse_running_async_output (a_input, cur, cur, thread_id)) {
+ LOG_PARSING_ERROR_MSG (a_input, cur,
+ "could not parse the expected running async output");
+ return false;
+ }
+ record.thread_id (thread_id);
+ goto end;
}
+end:
+
while (cur < end && isspace (a_input.raw ()[cur])) {++cur;}
a_to = cur;
a_record = record;
Modified: trunk/src/dbgengine/nmv-gdbmi-parser.h
==============================================================================
--- trunk/src/dbgengine/nmv-gdbmi-parser.h (original)
+++ trunk/src/dbgengine/nmv-gdbmi-parser.h Thu Nov 13 13:13:21 2008
@@ -380,6 +380,16 @@
IDebugger::Frame &a_frame,
map<UString, UString> &a_attrs);
+/// parse GDBMI async output that says that the inferior process
+/// is running.
+/// the string looks like:
+/// *running,thread-id="<thread-id>"
+/// Note that <thread-id> is either a number, or the string 'all'.
+bool parse_running_async_output (const UString &a_input,
+ UString::size_type a_from,
+ UString::size_type &a_to,
+ int &a_thread_id);
+
bool parse_out_of_band_record (const UString &a_input,
UString::size_type a_from,
UString::size_type &a_to,
Modified: trunk/tests/test-gdbmi.cc
==============================================================================
--- trunk/tests/test-gdbmi.cc (original)
+++ trunk/tests/test-gdbmi.cc Thu Nov 13 13:13:21 2008
@@ -20,6 +20,11 @@
static const char* gv_stopped_async_output1 =
"*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"1\",frame={addr=\"0x08048d38\",func=\"main\",args=[],file=\"fooprog.cc\",fullname=\"/opt/dodji/git/nemiver.git/tests/fooprog.cc\",line=\"80\"}\n";
+static const char *gv_running_async_output0 =
+"*running,thread-id=\"all\"\n";
+
+static const char *gv_running_async_output1 =
+"*running,thread-id=\"1\"\n";
static const char *gv_output_record0 =
"&\"Failed to read a valid object file image from memory.\\n\"\n"
@@ -29,6 +34,14 @@
"*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"1\",frame={addr=\"0x08048d38\",func=\"main\",args=[],file=\"fooprog.cc\",fullname=\"/opt/dodji/git/nemiver.git/tests/fooprog.cc\",line=\"80\"}\n"
"(gdb)";
+static const char *gv_output_record1 =
+"&\"Failed to read a valid object file image from memory.\\n\"\n"
+"~\"[Thread debugging using libthread_db enabled]\\n\"\n"
+"~\"[New Thread 0xb7892720 (LWP 20182)]\\n\"\n"
+"=thread-created,id=1\n"
+"*running,thread-id=\"1\"n"
+"(gdb)";
+
//the partial result of a gdbmi command: -stack-list-argument 1 command
//this command is used to implement IDebugger::list_frames_arguments()
static const char* gv_stack_arguments0 =
@@ -174,6 +187,25 @@
}
void
+test_running_async_output ()
+{
+ bool is_ok=false;
+ UString::size_type to=0 ;
+ int thread_id=0;
+
+ is_ok = parse_running_async_output (gv_running_async_output0, 0, to,
+ thread_id) ;
+ BOOST_REQUIRE (is_ok) ;
+ BOOST_REQUIRE (thread_id == -1) ;
+
+ to=0;
+ is_ok = parse_running_async_output (gv_running_async_output1, 0, to,
+ thread_id) ;
+ BOOST_REQUIRE (is_ok) ;
+ BOOST_REQUIRE (thread_id == 1) ;
+}
+
+void
test_output_record ()
{
bool is_ok=false;
@@ -182,6 +214,9 @@
is_ok = parse_output_record (gv_output_record0, 0, to, output);
BOOST_REQUIRE (is_ok) ;
+
+ is_ok = parse_output_record (gv_output_record1, 0, to, output);
+ BOOST_REQUIRE (is_ok) ;
}
void
@@ -533,6 +568,7 @@
suite->add (BOOST_TEST_CASE (&test_str2)) ;
suite->add (BOOST_TEST_CASE (&test_attr0)) ;
suite->add (BOOST_TEST_CASE (&test_stoppped_async_output)) ;
+ suite->add (BOOST_TEST_CASE (&test_running_async_output)) ;
suite->add (BOOST_TEST_CASE (&test_output_record)) ;
suite->add (BOOST_TEST_CASE (&test_stack_arguments0)) ;
suite->add (BOOST_TEST_CASE (&test_stack_arguments1)) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]