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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/utility.h

Issue 7740059: Add a timestamp to the log messages of NaCl's plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for fix. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/module_ppapi.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 // A collection of debugging related interfaces. 7 // A collection of debugging related interfaces.
8 8
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_
11 11
12 #include "native_client/src/include/nacl_macros.h" 12 #include "native_client/src/include/nacl_macros.h"
13 #include "native_client/src/include/portability.h" 13 #include "native_client/src/include/portability.h"
14 #include "native_client/src/shared/platform/nacl_threads.h" 14 #include "native_client/src/shared/platform/nacl_threads.h"
15 #include "native_client/src/shared/platform/nacl_time.h"
15 16
16 #define SRPC_PLUGIN_DEBUG 1 17 #define SRPC_PLUGIN_DEBUG 1
17 18
18 namespace plugin { 19 namespace plugin {
19 20
20 // Tests that a string is a valid JavaScript identifier. According to the 21 // Tests that a string is a valid JavaScript identifier. According to the
21 // ECMAScript spec, this should be done in terms of unicode character 22 // ECMAScript spec, this should be done in terms of unicode character
22 // categories. For now, we are simply limiting identifiers to the ASCII 23 // categories. For now, we are simply limiting identifiers to the ASCII
23 // subset of that spec. If successful, it returns the length of the 24 // subset of that spec. If successful, it returns the length of the
24 // identifier in the location pointed to by length (if it is not NULL). 25 // identifier in the location pointed to by length (if it is not NULL).
25 // TODO(sehr): add Unicode identifier support. 26 // TODO(sehr): add Unicode identifier support.
26 bool IsValidIdentifierString(const char* strval, uint32_t* length); 27 bool IsValidIdentifierString(const char* strval, uint32_t* length);
27 28
28 // Debugging print utility 29 // Debugging print utility
29 extern int gNaClPluginDebugPrintEnabled; 30 extern int gNaClPluginDebugPrintEnabled;
30 extern FILE* gNaClPluginLogFile; 31 extern FILE* gNaClPluginLogFile;
31 extern int NaClPluginPrintLog(const char *format, ...); 32 extern int NaClPluginPrintLog(const char *format, ...);
32 extern int NaClPluginDebugPrintCheckEnv(); 33 extern int NaClPluginDebugPrintCheckEnv();
33 extern FILE* NaClPluginLogFileEnv(); 34 extern FILE* NaClPluginLogFileEnv();
34 #if SRPC_PLUGIN_DEBUG 35 #if SRPC_PLUGIN_DEBUG
35 # define PLUGIN_PRINTF(args) do { \ 36 #define INIT_PLUGIN_LOGGING() do { \
36 if (-1 == ::plugin::gNaClPluginDebugPrintEnabled) { \ 37 if (-1 == ::plugin::gNaClPluginDebugPrintEnabled) { \
37 ::plugin::gNaClPluginDebugPrintEnabled = \ 38 ::plugin::gNaClPluginDebugPrintEnabled = \
38 ::plugin::NaClPluginDebugPrintCheckEnv(); \ 39 ::plugin::NaClPluginDebugPrintCheckEnv(); \
39 ::plugin::gNaClPluginLogFile = ::plugin::NaClPluginLogFileEnv();\ 40 ::plugin::gNaClPluginLogFile = ::plugin::NaClPluginLogFileEnv();\
40 } \ 41 } \
42 } while (0)
43
44 #define PLUGIN_PRINTF(args) do { \
45 INIT_PLUGIN_LOGGING(); \
41 if (0 != ::plugin::gNaClPluginDebugPrintEnabled) { \ 46 if (0 != ::plugin::gNaClPluginDebugPrintEnabled) { \
42 ::plugin::NaClPluginPrintLog("%08"NACL_PRIx32": ", \ 47 ::plugin::NaClPluginPrintLog("PLUGIN %"NACL_PRIu64": ", \
43 NaClThreadId()); \ 48 NaClGetTimeOfDayMicroseconds()); \
49 ::plugin::NaClPluginPrintLog args; \
50 } \
51 } while (0)
52
53 // MODULE_PRINTF is used in the module because PLUGIN_PRINTF uses a
54 // a timer that may not yet be initialized.
55 #define MODULE_PRINTF(args) do { \
56 INIT_PLUGIN_LOGGING(); \
57 if (0 != ::plugin::gNaClPluginDebugPrintEnabled) { \
58 ::plugin::NaClPluginPrintLog("MODULE: "); \
44 ::plugin::NaClPluginPrintLog args; \ 59 ::plugin::NaClPluginPrintLog args; \
45 } \ 60 } \
46 } while (0) 61 } while (0)
47 #else 62 #else
48 # define PLUGIN_PRINTF(args) do { if (0) { printf args; } } while (0) 63 # define PLUGIN_PRINTF(args) do { if (0) { printf args; } } while (0)
64 # define MODULE_PRINTF(args) do { if (0) { printf args; } } while (0)
49 /* allows DCE but compiler can still do format string checks */ 65 /* allows DCE but compiler can still do format string checks */
50 #endif 66 #endif
51 67
52 } // namespace plugin 68 } // namespace plugin
53 69
54 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ 70 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/module_ppapi.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698