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

Side by Side Diff: debugger/rsp/rsp_blob_utils.h

Issue 7466014: Add rsp::GetOffsets command + reply (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | debugger/rsp/rsp_blob_utils_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef DEBUGGER_RSP_RSP_BLOB_UTILS_H_ 4 #ifndef DEBUGGER_RSP_RSP_BLOB_UTILS_H_
5 #define DEBUGGER_RSP_RSP_BLOB_UTILS_H_ 5 #define DEBUGGER_RSP_RSP_BLOB_UTILS_H_
6 6
7 #include <assert.h>
7 #include <deque> 8 #include <deque>
8 #include "debugger/base/debug_blob.h" 9 #include "debugger/base/debug_blob.h"
9 10
10 namespace rsp { 11 namespace rsp {
11 /// These functions are used to parse RSP packets. 12 /// These functions are used to parse RSP packets.
12 /// http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Remote-Protocol 13 /// http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Remote-Protocol
13 14
14 /// Removes bytes from the front of the |blob|, converts it to integer 15 /// Removes bytes from the front of the |blob|, converts it to integer
15 /// Assumes hex test representation is in the blob. 16 /// Assumes hex test representation is in the blob.
16 /// @param blob[in,out] blob to perform operation on 17 /// @param blob[in,out] blob to perform operation on
(...skipping 18 matching lines...) Expand all
35 36
36 blob->PopFront(); 37 blob->PopFront();
37 if (0 == i) 38 if (0 == i)
38 *result = dig; 39 *result = dig;
39 else 40 else
40 *result = (*result << 4) + dig; 41 *result = (*result << 4) + dig;
41 } 42 }
42 return (i > 0); 43 return (i > 0);
43 } 44 }
44 45
46 /// Appends hex representation of |value| to the |blob|,
47 /// with no leading zeroes. Example:
48 /// 0x123 -> {'1', '2', '3'}
49 /// @param[in] value integer to be appended
50 /// @param[out] blob pointer to the destination blob.
51 /// @return reference to |blob|.
52 template <class T>
53 debug::Blob& PushIntToBack(T value, debug::Blob* blob) {
54 assert(NULL != blob);
55 debug::Blob tmp;
56 for (size_t i = 0; i < sizeof(value); i++) {
57 uint8_t x = (value & 0xFF);
58 tmp.PushFront(debug::Blob::GetHexDigit(x, 0));
59 tmp.PushFront(debug::Blob::GetHexDigit(x, 1));
60 if (sizeof(value) > 1)
61 value = value >> 8;
62 }
63 tmp.PopMatchingBytesFromFront(debug::Blob().FromString("0"));
64 if (0 == tmp.size())
65 blob->PushBack('0');
66 else
67 blob->Append(tmp);
68 return *blob;
69 }
70
45 /// removes space characters from front and from back of the blob. 71 /// removes space characters from front and from back of the blob.
46 /// @param blob blob to perform operation on 72 /// @param blob blob to perform operation on
47 void RemoveSpacesFromBothEnds(debug::Blob* blob); 73 void RemoveSpacesFromBothEnds(debug::Blob* blob);
48 74
49 /// removes space characters from front and from back of the blobs. 75 /// removes space characters from front and from back of the blobs.
50 /// @param blobs blobs to perform operation on 76 /// @param blobs blobs to perform operation on
51 void RemoveSpacesFromBothEnds(std::deque<debug::Blob>* blobs); 77 void RemoveSpacesFromBothEnds(std::deque<debug::Blob>* blobs);
52 78
53 /// Writes formatted data to Blob. 79 /// Writes formatted data to Blob.
54 /// @param blob blob to perform operation on 80 /// @param blob blob to perform operation on
55 /// @param[in] fmt string that contains the text to be written to the Blob. 81 /// @param[in] fmt string that contains the text to be written to the Blob.
56 /// @return reference to |blob| 82 /// @return reference to |blob|
57 debug::Blob& Format(debug::Blob* blob, const char* fmt, ...); 83 debug::Blob& Format(debug::Blob* blob, const char* fmt, ...);
58 84
59 } // namespace rsp 85 } // namespace rsp
60 86
61 #endif // DEBUGGER_RSP_RSP_BLOB_UTILS_H_ 87 #endif // DEBUGGER_RSP_RSP_BLOB_UTILS_H_
62 88
OLDNEW
« no previous file with comments | « no previous file | debugger/rsp/rsp_blob_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698