OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 #include "debugger/rsp/rsp_threads_packets.h" | |
5 | |
6 namespace rsp { | |
7 bool SetCurrentThreadCommand::FromBlob(const std::string& type, | |
8 debug::Blob* message) { | |
9 if ((message->size() > 0) && | |
10 ('-' == message->GetAt(0)) && | |
11 ('1' == message->GetAt(1))) { | |
12 thread_id_ = -1; // all threads | |
13 return true; | |
14 } | |
15 return PopIntFromFront(message, &thread_id_); | |
16 } | |
17 | |
18 void SetCurrentThreadCommand::ToBlob(debug::Blob* message) const { | |
19 if (FOR_READ == subtype_) | |
20 message->FromString("Hg"); | |
21 else | |
22 message->FromString("Hc"); | |
23 | |
24 if (0 == thread_id_) { | |
25 message->PushBack('0'); | |
26 } else if ((unsigned int)(-1) == thread_id_) { | |
27 message->PushBack('-'); | |
28 message->PushBack('1'); | |
29 } else { | |
30 debug::Blob tmp; | |
31 Format(&tmp, "%x", thread_id_); | |
32 message->Append(tmp); | |
33 } | |
34 } | |
35 | |
36 bool GetThreadInfoCommand::FromBlob(const std::string& type, | |
37 debug::Blob* message) { | |
38 get_more_ = ("qsThreadInfo" == type); | |
39 return true; | |
40 } | |
41 | |
42 void GetThreadInfoCommand::ToBlob(debug::Blob* message) const { | |
43 if (get_more_) | |
44 message->FromString("qsThreadInfo"); | |
45 else | |
46 message->FromString("qfThreadInfo"); | |
47 } | |
48 | |
49 bool GetThreadInfoReply::FromBlob(const std::string& type, | |
50 debug::Blob* message) { | |
51 if (message->size() < 1) | |
52 return false; | |
53 char cmd = message->PopFront(); | |
54 eom_ = ('l' == cmd); | |
55 | |
56 std::deque<debug::Blob> tokens; | |
57 message->Split(debug::Blob().FromString(","), &tokens); | |
58 | |
59 for (size_t i = 0; i < tokens.size(); i++) { | |
60 uint32_t id = 0; | |
61 if (!PopIntFromFront(&tokens[i], &id)) | |
62 return false; | |
63 threads_ids_.push_back(id); | |
64 } | |
65 return true; | |
66 } | |
67 | |
68 void GetThreadInfoReply::ToBlob(debug::Blob* message) const { | |
69 if (eom_ || (0 == threads_ids_.size())) | |
70 message->FromString("l"); | |
71 else | |
72 message->FromString("m"); | |
73 size_t num = threads_ids_.size(); | |
74 for (size_t i = 0; i < num; i++) { | |
75 debug::Blob tmp; | |
76 Format(&tmp, "%x", threads_ids_[i]); | |
77 message->Append(tmp); | |
78 if ((i + 1) != num) | |
79 message->PushBack(','); | |
80 } | |
81 } | |
82 } // namespace rsp | |
83 | |
OLD | NEW |