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 #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 Loading... | |
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 /// leading zeroes are ignored | |
mmortensen
2011/07/21 17:36:44
Please add comments for this funciton with @param
garianov1
2011/07/21 17:50:36
Done.
| |
47 template <class T> | |
48 debug::Blob& PushIntToBack(T value, debug::Blob* blob) { | |
49 assert(NULL != blob); | |
50 debug::Blob tmp; | |
51 for (size_t i = 0; i < sizeof(value); i++) { | |
52 uint8_t x = (value & 0xFF); | |
53 tmp.PushFront(debug::Blob::GetHexDigit(x, 0)); | |
54 tmp.PushFront(debug::Blob::GetHexDigit(x, 1)); | |
55 if (sizeof(value) > 1) | |
56 value = value >> 8; | |
57 } | |
58 tmp.PopMatchingBytesFromFront(debug::Blob().FromString("0")); | |
59 if (0 == tmp.size()) | |
60 blob->PushBack('0'); | |
61 else | |
62 blob->Append(tmp); | |
63 return *blob; | |
64 } | |
65 | |
45 /// removes space characters from front and from back of the blob. | 66 /// removes space characters from front and from back of the blob. |
46 /// @param blob blob to perform operation on | 67 /// @param blob blob to perform operation on |
47 void RemoveSpacesFromBothEnds(debug::Blob* blob); | 68 void RemoveSpacesFromBothEnds(debug::Blob* blob); |
48 | 69 |
49 /// removes space characters from front and from back of the blobs. | 70 /// removes space characters from front and from back of the blobs. |
50 /// @param blobs blobs to perform operation on | 71 /// @param blobs blobs to perform operation on |
51 void RemoveSpacesFromBothEnds(std::deque<debug::Blob>* blobs); | 72 void RemoveSpacesFromBothEnds(std::deque<debug::Blob>* blobs); |
52 | 73 |
53 /// Writes formatted data to Blob. | 74 /// Writes formatted data to Blob. |
54 /// @param blob blob to perform operation on | 75 /// @param blob blob to perform operation on |
55 /// @param[in] fmt string that contains the text to be written to the Blob. | 76 /// @param[in] fmt string that contains the text to be written to the Blob. |
56 /// @return reference to |blob| | 77 /// @return reference to |blob| |
57 debug::Blob& Format(debug::Blob* blob, const char* fmt, ...); | 78 debug::Blob& Format(debug::Blob* blob, const char* fmt, ...); |
58 | 79 |
59 } // namespace rsp | 80 } // namespace rsp |
60 | 81 |
61 #endif // DEBUGGER_RSP_RSP_BLOB_UTILS_H_ | 82 #endif // DEBUGGER_RSP_RSP_BLOB_UTILS_H_ |
62 | 83 |
OLD | NEW |