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

Unified Diff: base/strings/string_number_conversions_dup.cc

Issue 2595063002: debuggng for PR31361
Patch Set: build on android too Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_number_conversions_dup.cc
diff --git a/base/strings/string_number_conversions_dup.cc b/base/strings/string_number_conversions_dup.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0decb2fc73dff4e3afb6a46d5f3cff9a1093687e
--- /dev/null
+++ b/base/strings/string_number_conversions_dup.cc
@@ -0,0 +1,41 @@
+#include <string>
+#include <vector>
+#include <stdint.h>
+
+namespace hack {
+
+bool CharToDigit(char c, uint8_t* digit) {
+ if (c >= '0' && c <= '9') {
+ *digit = c - '0';
+ } else if (c >= 'a' && c < 'a' + 16 - 10) {
+ *digit = c - 'a' + 10;
+ } else if (c >= 'A' && c < 'A' + 16 - 10) {
+ *digit = c - 'A' + 10;
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output) {
+ size_t count = input.size();
+ if (count == 0 || (count % 2) != 0)
+ return false;
+ for (uintptr_t i = 0; i < count / 2; ++i) {
+ uint8_t msb = 0; // most significant 4 bits
+ uint8_t lsb = 0; // least significant 4 bits
+ if (!CharToDigit(input[i * 2], &msb) ||
+ !CharToDigit(input[i * 2 + 1], &lsb))
+ return false;
+ output->push_back((msb << 4) | lsb);
+ }
+ return true;
+}
+
+void f() {
+ // Make sure we have 1MB of code, so that the string accesses above have to
+ // use adrp instead of adr.
+ __asm__(".zero 1048576");
+}
+
+}
« no previous file with comments | « base/BUILD.gn ('k') | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698