CUBRID Engine  latest
resource_tracker.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * resource_tracker.cpp - implementation to track resource usage (allocations, page fixes) and detect leaks
21  */
22 
23 #include "resource_tracker.hpp"
24 
25 #include "error_manager.h"
26 
27 namespace cubbase
28 {
29  resource_tracker_item::resource_tracker_item (const char *fn_arg, int l_arg, unsigned reuse)
30  : m_first_location (fn_arg, l_arg)
31  , m_reuse_count (reuse)
32  {
33  //
34  }
35 
36  std::ostream &
37  operator<< (std::ostream &os, const resource_tracker_item &item)
38  {
39  os << "amount=" << item.m_reuse_count << " | first_caller=" << item.m_first_location;
40  return os;
41  }
42 
44  // debugging
45  bool Restrack_has_error = false;
47 
48  bool
50  {
51  bool ret = Restrack_has_error;
52  Restrack_has_error = false;
53  return ret;
54  }
55 
56  void
58  {
59  Restrack_has_error = Restrack_has_error || error;
60  }
61 
62  void
64  {
65  Restrack_suppress_assert = suppress;
66  }
67 
68  bool
70  {
72  }
73 
74  void
75  restrack_log (const std::string &str)
76  {
77  _er_log_debug (ARG_FILE_LINE, str.c_str ());
78  }
79 
80 } // namespace cubbase
resource_tracker_item(const char *fn_arg, int l_arg, unsigned reuse)
void restrack_set_suppress_assert(bool suppress)
void restrack_log(const std::string &str)
bool Restrack_has_error
void restrack_set_error(bool error)
bool Restrack_suppress_assert
void _er_log_debug(const char *file_name, const int line_no, const char *fmt,...)
bool restrack_pop_error(void)
static void error(const char *msg)
Definition: gencat.c:331
#define ARG_FILE_LINE
Definition: error_manager.h:44
bool restrack_is_assert_suppressed(void)
std::ostream & operator<<(std::ostream &os, const fileline_location &fileline)