Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginDebug.cpp

Issue 29332020: Noissue - Add tracing function 'ToHexLiteral()' (Closed)
Patch Set: Created Dec. 6, 2015, 6:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30); 249 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30);
250 } 250 }
251 251
252 CString blocking; 252 CString blocking;
253 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L" -" : ToCString(domain), srcTrunc); 253 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L" -" : ToCString(domain), srcTrunc);
254 254
255 DebugResultLegacy(blocking); 255 DebugResultLegacy(blocking);
256 } 256 }
257 257
258 #endif // ENABLE_DEBUG_RESULT_IGNORED 258 #endif // ENABLE_DEBUG_RESULT_IGNORED
259
260 namespace
261 {
262 /*
263 * To convert a pointer to a hexadecimal number, we need an integral type that has the same size as that of the pointer.
264 */
265 #if defined(_WIN64)
266 typedef long long voidIntegral;
sergei 2015/12/07 11:04:02 what about uint64_t and uint32_t instead of `long
Eric 2015/12/07 13:06:57 Done. Do not, however, ask me to remove the 'stat
267 static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN64: sizeof(long long) is not the same as sizeof(void*)");
268 #elif defined(_WIN32)
269 typedef long voidIntegral;
270 static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN32: sizeof(long) is not the same as sizeof(void*)");
271 #else
272 #error Must compile with either _WIN32 or _WIN64
273 #endif
274 }
275
276 std::wstring ToHexLiteral(void const* p)
277 {
278 std::wstringstream ss;
279 ss << L"0x";
280 ss.width(sizeof(p) * 2);
281 ss.fill(L'0');
282 ss << std::hex << reinterpret_cast<voidIntegral>(p);
283 return ss.str();
sergei 2015/12/07 11:04:02 Do we really need it so complicated? It seems `bas
Oleksandr 2015/12/07 12:00:50 Alternatively there's also StringCbPrintf (aka spr
Eric 2015/12/07 13:06:57 I doesn't do the same thing. The formatting is dif
Eric 2015/12/07 13:06:57 It doesn't save code to use a C-style function tha
Eric 2015/12/15 16:31:16 Actual tracing in new review: https://codereview.a
284 }
OLDNEW
« no previous file with comments | « src/plugin/PluginDebug.h ('k') | test/plugin/DebugTest.cpp » ('j') | test/plugin/DebugTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld