| LEFT | RIGHT |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #pragma once | 18 #pragma once |
| 19 | 19 |
| 20 #include <emscripten.h> | 20 #include "library.h" |
| 21 #include <emscripten/trace.h> | |
| 22 | 21 |
| 23 #if defined(assert) | 22 #if defined(assert) |
| 24 #undef assert | 23 #undef assert |
| 25 #endif | 24 #endif |
| 26 | 25 |
| 27 class String; | 26 class String; |
| 28 | |
| 29 extern "C" | |
| 30 { | |
| 31 void LogString(const String& str); | |
| 32 void LogInteger(int i); | |
| 33 void LogPointer(const void* ptr); | |
| 34 void LogError(const String& str); | |
| 35 } | |
| 36 | 27 |
| 37 struct console_type | 28 struct console_type |
| 38 { | 29 { |
| 39 static void log(const String& str) | 30 static void log(const String& str) |
| 40 { | 31 { |
| 41 LogString(str); | 32 LogString(str); |
| 42 } | 33 } |
| 43 | 34 |
| 44 static void log(int i) | 35 static void log(int i) |
| 45 { | 36 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 #if defined(DEBUG) | 53 #if defined(DEBUG) |
| 63 inline void assert(bool condition, const String& str) | 54 inline void assert(bool condition, const String& str) |
| 64 { | 55 { |
| 65 if (!condition) | 56 if (!condition) |
| 66 console.error(str); | 57 console.error(str); |
| 67 } | 58 } |
| 68 #else | 59 #else |
| 69 #define assert(condition, str) | 60 #define assert(condition, str) |
| 70 #endif | 61 #endif |
| 71 | 62 |
| 63 #if defined(__EMSCRIPTEN_TRACING__) |
| 64 #include <emscripten/trace.h> |
| 65 |
| 66 inline void init_tracing() |
| 67 { |
| 68 emscripten_trace_configure("http://127.0.0.1:5000/", "MyApplication"); |
| 69 } |
| 70 |
| 71 inline void shutdown_tracing() |
| 72 { |
| 73 emscripten_trace_close(); |
| 74 } |
| 75 |
| 72 inline void annotate_address(void* address, const char* name) | 76 inline void annotate_address(void* address, const char* name) |
| 73 { | 77 { |
| 74 #if defined(__EMSCRIPTEN_TRACING__) | |
| 75 emscripten_trace_annotate_address_type(address, name); | 78 emscripten_trace_annotate_address_type(address, name); |
| 76 #endif | |
| 77 } | 79 } |
| 78 | 80 |
| 79 inline void enter_context(const char* context) | 81 inline void enter_context(const char* context) |
| 80 { | 82 { |
| 81 #if defined(__EMSCRIPTEN_TRACING__) | |
| 82 emscripten_trace_enter_context(context); | 83 emscripten_trace_enter_context(context); |
| 83 #endif | |
| 84 } | 84 } |
| 85 | 85 |
| 86 inline void exit_context() | 86 inline void exit_context() |
| 87 { | 87 { |
| 88 #if defined(__EMSCRIPTEN_TRACING__) | |
| 89 emscripten_trace_exit_context(); | 88 emscripten_trace_exit_context(); |
| 90 #endif | |
| 91 } | 89 } |
| 90 |
| 91 #else // defined(__EMSCRIPTEN_TRACING__) |
| 92 |
| 93 inline void init_tracing() |
| 94 { |
| 95 } |
| 96 |
| 97 inline void shutdown_tracing() |
| 98 { |
| 99 } |
| 100 |
| 101 inline void annotate_address(void* address, const char* name) |
| 102 { |
| 103 } |
| 104 |
| 105 inline void enter_context(const char* context) |
| 106 { |
| 107 } |
| 108 |
| 109 inline void exit_context() |
| 110 { |
| 111 } |
| 112 |
| 113 #endif // defined(__EMSCRIPTEN_TRACING__) |
| LEFT | RIGHT |