| File: | var/lib/jenkins/workspace/firefox-scan-build/tools/profiler/core/VTuneProfiler.cpp |
| Warning: | line 23, column 15 Value stored to 'testEvent' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
| 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | #ifdef XP_WIN |
| 8 | # undef UNICODE |
| 9 | # undef _UNICODE |
| 10 | #endif |
| 11 | |
| 12 | #include "VTuneProfiler.h" |
| 13 | #include "mozilla/Bootstrap.h" |
| 14 | #include <memory> |
| 15 | |
| 16 | VTuneProfiler* VTuneProfiler::mInstance = nullptr; |
| 17 | |
| 18 | void VTuneProfiler::Initialize() { |
| 19 | // This is just a 'dirty trick' to find out if the ittnotify DLL was found. |
| 20 | // If it wasn't this function always returns 0, otherwise it returns |
| 21 | // incrementing numbers, if the library was found this wastes 2 events but |
| 22 | // that should be okay. |
| 23 | __itt_event testEvent = |
Value stored to 'testEvent' during its initialization is never read | |
| 24 | __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0("Test event", strlen("Test event")); |
| 25 | testEvent = __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0("Test event 2", strlen("Test event 2")); |
| 26 | |
| 27 | if (testEvent) { |
| 28 | mInstance = new VTuneProfiler(); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | void VTuneProfiler::Shutdown() {} |
| 33 | |
| 34 | void VTuneProfiler::TraceInternal(const char* aName, TracingKind aKind) { |
| 35 | std::string str(aName); |
| 36 | |
| 37 | auto iter = mStrings.find(str); |
| 38 | |
| 39 | __itt_event event; |
| 40 | if (iter != mStrings.end()) { |
| 41 | event = iter->second; |
| 42 | } else { |
| 43 | event = __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0(aName, str.length()); |
| 44 | mStrings.insert({str, event}); |
| 45 | } |
| 46 | |
| 47 | if (aKind == TRACING_INTERVAL_START || aKind == TRACING_EVENT) { |
| 48 | // VTune will consider starts not matched with an end to be single point in |
| 49 | // time events. |
| 50 | __itt_event_start(!__itt_event_start_ptr__3_0) ? 0 : __itt_event_start_ptr__3_0(event); |
| 51 | } else { |
| 52 | __itt_event_end(!__itt_event_end_ptr__3_0) ? 0 : __itt_event_end_ptr__3_0(event); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void VTuneProfiler::RegisterThreadInternal(const char* aName) { |
| 57 | std::string str(aName); |
| 58 | |
| 59 | if (!str.compare("GeckoMain")) { |
| 60 | // Process main thread. |
| 61 | switch (XRE_GetProcessType()) { |
| 62 | case GeckoProcessType::GeckoProcessType_Default: |
| 63 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Main Process"); |
| 64 | break; |
| 65 | case GeckoProcessType::GeckoProcessType_Content: |
| 66 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Content Process"); |
| 67 | break; |
| 68 | case GeckoProcessType::GeckoProcessType_GMPlugin: |
| 69 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Plugin Process"); |
| 70 | break; |
| 71 | case GeckoProcessType::GeckoProcessType_GPU: |
| 72 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("GPU Process"); |
| 73 | break; |
| 74 | default: |
| 75 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Unknown Process"); |
| 76 | } |
| 77 | return; |
| 78 | } |
| 79 | __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0(aName); |
| 80 | } |