Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Side by Side Diff: experimental/linux_debug_server/debugger/rsp/rsp_common_replies.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_common_replies.h"
5
6 namespace rsp {
7 StopReply::StopReply()
8 : stop_reason_(STILL_RUNNING),
9 signal_number_(0),
10 exit_code_(0),
11 pid_(0) {
12 }
13
14 StopReply :: StopReply(StopReason stop_reason)
15 : stop_reason_(stop_reason),
16 signal_number_(0),
17 exit_code_(0),
18 pid_(0) {
19 }
20
21 bool StopReply::FromBlob(const std::string& type, debug::Blob* message) {
22 if ("S" == type) {
23 stop_reason_ = SIGNALED;
24 return PopIntFromFront(message, &signal_number_);
25 } else if ("W" == type) {
26 stop_reason_ = StopReply::EXITED;
27 if (!PopIntFromFront(message, &exit_code_))
28 return false;
29 } else if ("X" == type) {
30 stop_reason_ = StopReply::TERMINATED;
31 if (!PopIntFromFront(message, &signal_number_))
32 return false;
33 } else if ("O" == type) {
34 stop_reason_ = StopReply::STILL_RUNNING;
35 return true;
36 } else {
37 return false;
38 }
39 if (("W" == type) || ("X" == type)) {
40 message->PopMatchingBytesFromFront(debug::Blob().FromString(";"));
41 std::deque<debug::Blob> tokens;
42 message->Split(debug::Blob().FromString(":"), &tokens);
43 if ((tokens.size() >= 2) &&
44 (tokens[0] == debug::Blob().FromString("process"))) {
45 std::string s = tokens[1].ToString();
46 return PopIntFromFront(&tokens[1], &pid_);
47 }
48 }
49 return false;
50 }
51
52 void StopReply::ToBlob(debug::Blob* message) const {
53 message->Clear();
54 switch (stop_reason_) {
55 case SIGNALED: {
56 Format(message, "S%0.2x", signal_number_);
57 break;
58 }
59 case TERMINATED: {
60 Format(message, "X%0.2x;process:%x", signal_number_, pid_);
61 break;
62 }
63 case EXITED: {
64 Format(message, "W%0.2x;process:%x", exit_code_, pid_);
65 break;
66 }
67 case STILL_RUNNING: {
68 message->FromString("O");
69 break;
70 }
71 }
72 }
73
74 bool BlobReply::FromBlob(const std::string& type, debug::Blob* message) {
75 return data_.FromHexString(message->ToString());
76 }
77
78 void BlobReply::ToBlob(debug::Blob* message) const {
79 message->FromString(data_.ToHexString());
80 }
81 } // namespace rsp
82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698