OLD | NEW |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 #include <deque> | 4 #include <deque> |
5 #include <map> | 5 #include <map> |
6 #include "debugger/base/debug_blob.h" | 6 #include "debugger/base/debug_blob.h" |
7 #include "debugger/rsp/rsp_common_replies.h" | 7 #include "debugger/rsp/rsp_common_replies.h" |
8 #include "debugger/rsp/rsp_control_packets.h" | 8 #include "debugger/rsp/rsp_control_packets.h" |
9 #include "debugger/rsp/rsp_info_packets.h" | 9 #include "debugger/rsp/rsp_info_packets.h" |
10 #include "debugger/rsp/rsp_packets.h" | 10 #include "debugger/rsp/rsp_packets.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 packs.push_back(new rsp::SetCurrentThreadCommand); | 82 packs.push_back(new rsp::SetCurrentThreadCommand); |
83 packs.push_back(new rsp::GetCurrentThreadCommand); | 83 packs.push_back(new rsp::GetCurrentThreadCommand); |
84 packs.push_back(new rsp::GetCurrentThreadReply); | 84 packs.push_back(new rsp::GetCurrentThreadReply); |
85 packs.push_back(new rsp::ContinueCommand); | 85 packs.push_back(new rsp::ContinueCommand); |
86 packs.push_back(new rsp::StepCommand); | 86 packs.push_back(new rsp::StepCommand); |
87 packs.push_back(new rsp::IsThreadAliveCommand); | 87 packs.push_back(new rsp::IsThreadAliveCommand); |
88 packs.push_back(new rsp::QXferFeaturesReadCommand); | 88 packs.push_back(new rsp::QXferFeaturesReadCommand); |
89 packs.push_back(new rsp::QXferReply); | 89 packs.push_back(new rsp::QXferReply); |
90 packs.push_back(new rsp::GetThreadInfoCommand); | 90 packs.push_back(new rsp::GetThreadInfoCommand); |
91 packs.push_back(new rsp::GetThreadInfoReply); | 91 packs.push_back(new rsp::GetThreadInfoReply); |
| 92 packs.push_back(new rsp::GetOffsetsCommand); |
| 93 packs.push_back(new rsp::GetOffsetsReply); |
92 | 94 |
93 std::map<int, int> type_ids; | 95 std::map<int, int> type_ids; |
94 for (size_t i = 0; i < packs.size(); i++) { | 96 for (size_t i = 0; i < packs.size(); i++) { |
95 rsp::TypingPacketVisitor vis; | 97 rsp::TypingPacketVisitor vis; |
96 rsp::Packet* packet = packs[i]; | 98 rsp::Packet* packet = packs[i]; |
97 packet->AcceptVisitor(&vis); | 99 packet->AcceptVisitor(&vis); |
98 | 100 |
99 bool found = type_ids.end() != type_ids.find(vis.type_); | 101 bool found = type_ids.end() != type_ids.find(vis.type_); |
100 EXPECT_FALSE(found); | 102 EXPECT_FALSE(found); |
101 | 103 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetCurrentThreadReply, "QC138c")); | 331 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetCurrentThreadReply, "QC138c")); |
330 EXPECT_TRUE(TestParseAndPrintout(new rsp::ContinueCommand, "c")); | 332 EXPECT_TRUE(TestParseAndPrintout(new rsp::ContinueCommand, "c")); |
331 EXPECT_TRUE(TestParseAndPrintout(new rsp::StepCommand, "s")); | 333 EXPECT_TRUE(TestParseAndPrintout(new rsp::StepCommand, "s")); |
332 EXPECT_TRUE(TestParseAndPrintout(new rsp::IsThreadAliveCommand, "T138c")); | 334 EXPECT_TRUE(TestParseAndPrintout(new rsp::IsThreadAliveCommand, "T138c")); |
333 EXPECT_TRUE(TestParseAndPrintout(new rsp::QXferFeaturesReadCommand, | 335 EXPECT_TRUE(TestParseAndPrintout(new rsp::QXferFeaturesReadCommand, |
334 "qXfer:features:read:target.xml:0,7ca")); | 336 "qXfer:features:read:target.xml:0,7ca")); |
335 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetThreadInfoCommand, | 337 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetThreadInfoCommand, |
336 "qfThreadInfo")); | 338 "qfThreadInfo")); |
337 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetThreadInfoCommand, | 339 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetThreadInfoCommand, |
338 "qsThreadInfo")); | 340 "qsThreadInfo")); |
| 341 |
| 342 EXPECT_TRUE(TestParseAndPrintout(new rsp::GetOffsetsCommand, |
| 343 "qOffsets")); |
339 } | 344 } |
340 | 345 |
341 TEST_F(RspPacketTest, WriteRegistersCommand) { | 346 TEST_F(RspPacketTest, WriteRegistersCommand) { |
342 rsp::Packet* obj = ParseMsg("G00a500000000000c0ffffff00000000d85123020"); | 347 rsp::Packet* obj = ParseMsg("G00a500000000000c0ffffff00000000d85123020"); |
343 ASSERT_NE(kNullPacketPtr, obj); | 348 ASSERT_NE(kNullPacketPtr, obj); |
344 | 349 |
345 rsp::WriteRegistersCommand* pack = | 350 rsp::WriteRegistersCommand* pack = |
346 rsp::packet_cast<rsp::WriteRegistersCommand>(obj); | 351 rsp::packet_cast<rsp::WriteRegistersCommand>(obj); |
347 ASSERT_NE(kNullPacketPtr, pack); | 352 ASSERT_NE(kNullPacketPtr, pack); |
348 | 353 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 ASSERT_NE(kNullPacketPtr, obj); | 455 ASSERT_NE(kNullPacketPtr, obj); |
451 EXPECT_TRUE(obj->eom()); | 456 EXPECT_TRUE(obj->eom()); |
452 EXPECT_EQ(1, obj->threads_ids().size()); | 457 EXPECT_EQ(1, obj->threads_ids().size()); |
453 EXPECT_EQ(0x138c, obj->threads_ids()[0]); | 458 EXPECT_EQ(0x138c, obj->threads_ids()[0]); |
454 | 459 |
455 debug::Blob blob; | 460 debug::Blob blob; |
456 obj->ToBlob(&blob); | 461 obj->ToBlob(&blob); |
457 EXPECT_STREQ(kMsg, blob.ToString().c_str()); | 462 EXPECT_STREQ(kMsg, blob.ToString().c_str()); |
458 delete obj; | 463 delete obj; |
459 } | 464 } |
| 465 |
| 466 TEST_F(RspPacketTest, GetOffsetsReply) { |
| 467 const char* kMsg = "Text=c00000000;Data=c00000001"; |
| 468 rsp::GetOffsetsReply* obj = |
| 469 rsp::packet_cast<rsp::GetOffsetsReply>( |
| 470 ParseMsg(kMsg, "qOffsets$Reply")); |
| 471 ASSERT_NE(kNullPacketPtr, obj); |
| 472 EXPECT_EQ(0xc00000000, obj->text_offset()); |
| 473 EXPECT_EQ(0xc00000001, obj->data_offset()); |
| 474 |
| 475 debug::Blob blob; |
| 476 obj->ToBlob(&blob); |
| 477 EXPECT_STREQ(kMsg, blob.ToString().c_str()); |
| 478 delete obj; |
| 479 } |
460 } // namespace | 480 } // namespace |
461 | 481 |
OLD | NEW |