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

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

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 #ifndef DEBUGGER_RSP_RSP_BLOB_UTILS_H_
5 #define DEBUGGER_RSP_RSP_BLOB_UTILS_H_
6
7 #include <assert.h>
8 #include <deque>
9 #include "debugger/base/debug_blob.h"
10
11 namespace rsp {
12 /// These functions are used to parse RSP packets.
13 /// http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Remote-Protocol
14
15 /// Removes bytes from the front of the |blob|, converts it to integer
16 /// Assumes hex test representation is in the blob.
17 /// @param blob[in,out] blob to perform operation on
18 /// @param result[out] destination for the popped integer
19 /// @return false if |blob| has no valid hex characters in the front,
20 /// example: PopIntFromFront("kaka", &v) -> false
21 template <class T>
22 bool PopIntFromFront(debug::Blob* blob, T* result) {
23 if (NULL == result)
24 return false;
25
26 // 2 chars per 1 encoded byte
27 size_t max_bytes_to_pop = sizeof(*result) * 2;
28 size_t i = 0;
29 for (; i < max_bytes_to_pop; i++) {
30 if (0 == blob->size())
31 break;
32
33 unsigned int dig = 0;
34 if (!debug::Blob::HexCharToInt(blob->Front(), &dig))
35 break; // Stop on first no-hex character.
36
37 blob->PopFront();
38 if (0 == i)
39 *result = dig;
40 else
41 *result = (*result << 4) + dig;
42 }
43 return (i > 0);
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
71 /// removes space characters from front and from back of the blob.
72 /// @param blob blob to perform operation on
73 void RemoveSpacesFromBothEnds(debug::Blob* blob);
74
75 /// removes space characters from front and from back of the blobs.
76 /// @param blobs blobs to perform operation on
77 void RemoveSpacesFromBothEnds(std::deque<debug::Blob>* blobs);
78
79 /// Writes formatted data to Blob.
80 /// @param blob blob to perform operation on
81 /// @param[in] fmt string that contains the text to be written to the Blob.
82 /// @return reference to |blob|
83 debug::Blob& Format(debug::Blob* blob, const char* fmt, ...);
84 } // namespace rsp
85
86 #endif // DEBUGGER_RSP_RSP_BLOB_UTILS_H_
87
OLDNEW
« no previous file with comments | « experimental/linux_debug_server/debugger/oop_hooks.cc ('k') | experimental/linux_debug_server/debugger/rsp/rsp_blob_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698