libfoedus-core
FOEDUS Core Library
debugging_supports.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_DEBUGGING_DEBUGGING_SUPPORTS_HPP_
19 #define FOEDUS_DEBUGGING_DEBUGGING_SUPPORTS_HPP_
20 
21 #include <string>
22 #include <vector>
23 
24 #include "foedus/cxx11.hpp"
25 #include "foedus/fwd.hpp"
26 #include "foedus/initializable.hpp"
28 
29 namespace foedus {
30 namespace debugging {
36  public:
37  struct PapiCounters {
39  long long int counters_[128]; // NOLINT[runtime/int](PAPI requirement)
40  };
41 
43  explicit DebuggingSupports(Engine* engine) : engine_(engine) {}
46 
48  void set_debug_log_to_stderr(bool value);
50  void set_debug_log_stderr_threshold(DebuggingOptions::DebugLogLevel level);
52  void set_debug_log_min_threshold(DebuggingOptions::DebugLogLevel level);
54  void set_verbose_log_level(int verbose);
56  void set_verbose_module(const std::string &module, int verbose);
57 
75  ErrorStack start_profile(const std::string& output_file);
77  void stop_profile();
78 
80  void start_papi_counters();
82  void stop_papi_counters();
83 
88  const PapiCounters& get_papi_counters() const { return papi_counters_; }
93  static std::vector<std::string> describe_papi_counters(const PapiCounters& counters);
94 
95  private:
100  void initialize_glog();
105  void uninitialize_glog();
106 
107  Engine* const engine_;
108 
109  bool papi_enabled_;
110  PapiCounters papi_counters_;
111 };
112 } // namespace debugging
113 } // namespace foedus
114 #endif // FOEDUS_DEBUGGING_DEBUGGING_SUPPORTS_HPP_
void set_debug_log_to_stderr(bool value)
Whether to write debug logs to stderr rather than log file.
void start_papi_counters()
Start collecting performance counters via PAPI if it's available.
long long int counters_[128]
wanna use int64_t, but to align with PAPI...
ErrorStack start_profile(const std::string &output_file)
Start running a CPU profiler (gperftools/PAPI).
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Forward declarations of classes in root package.
STL namespace.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Typical implementation of Initializable as a skeleton base class.
void set_debug_log_min_threshold(DebuggingOptions::DebugLogLevel level)
Debug logs below this level will be completely ignored.
static std::vector< std::string > describe_papi_counters(const PapiCounters &counters)
Returns a human-readable explanation of PAPI counters.
void set_debug_log_stderr_threshold(DebuggingOptions::DebugLogLevel level)
Debug logs at or above this level will be copied to stderr.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
void stop_profile()
Stop CPU profiling.
void set_verbose_module(const std::string &module, int verbose)
Per-module verbose level.
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
Definition: cxx11.hpp:134
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
void stop_papi_counters()
Stop collecting performance counters via PAPI.
void set_verbose_log_level(int verbose)
Verbose debug logs (VLOG(m)) at or less than this number will be shown.
const PapiCounters & get_papi_counters() const
Returns the profiled PAPI counters.
APIs to support debugging functionalities.
Set of options for debugging support.