Commit d2189b07 authored by Marco Amagliani's avatar Marco Amagliani
Browse files

DEB_module has become dummy in order to avoid to have static variables. This...

DEB_module has become dummy in order to avoid to have static variables. This is especially bad if a file is included in another file. In such a case it was possible to have static variables defined twaice in the same compilation unit.
There is also some code cleaning to remove mistakes (like test if this == 0) and to remove files that are no more used.

[git-p4: depot-paths = "//ReForm/ReForm/main/Base/": change = 13135]
parent 1513d605
set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/DebOut.hh
${CMAKE_CURRENT_SOURCE_DIR}/DebShow.hh
${CMAKE_CURRENT_SOURCE_DIR}/DebTime.hh
${CMAKE_CURRENT_SOURCE_DIR}/DebUtils.hh
PARENT_SCOPE
......@@ -8,6 +7,5 @@ set(my_headers
set(my_sources
${CMAKE_CURRENT_SOURCE_DIR}/DebStream.cc
${CMAKE_CURRENT_SOURCE_DIR}/DebShow.cc
PARENT_SCOPE
)
......@@ -8,15 +8,14 @@
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef REFORM_DEBOUT_HH_INCLUDED
#define REFORM_DEBOUT_HH_INCLUDED
#ifndef BASE_DEBOUT_HH_INCLUDED
#define BASE_DEBOUT_HH_INCLUDED
// DEB_ON is defined, or not, in CMakeLists.txt for primary project
#ifndef DEB_ON
#define DEB_module(SS)
#define DEB_enter_func
#define DEB_enter_header_func
#define DEB_only(CC)
#define DEB_out(LL, AA) {}
#define DEB_out_if(CC, LL, AA) {}
......@@ -34,15 +33,12 @@
#include <string>
#include <vector>
#define DEB_module(MODULE) static const char* FILE_MODULE_NAME = MODULE;
#define DEB_module(MODULE);
/* TODO: This should use an atomic thread safe static int
*/
#define DEB_enter_func static int deb_enter_count = 0; \
Debug::Enter deb(__FUNCTION__, deb_enter_count++, FILE_MODULE_NAME);
#define DEB_enter_header_func static int deb_enter_count = 0; \
Debug::Enter deb(__FUNCTION__, deb_enter_count++, "header");
Debug::Enter deb(__FILE__, __FUNCTION__, deb_enter_count++);
#define DEB_only(CC) CC
......@@ -110,9 +106,10 @@ public:
determining whether a given DEB_out should include or omit
a call stack or exit trace. */
int deb_lines_; /*!< Number of call stack indents including this call. */
const char* module_; /*!< Module name for this DEB_enter. */
const char* flnm_; /*!< File name for this DEB_enter. */
const char* module_; /*!< Module name for this DEB_enter. Not used. */
Enter(const char* const _funcname, const int _count, const char* const _module);
Enter(const char* const _flnm, const char* const _funcname, const int _count);
~Enter();
Stream& stream(const int _warn = 0, const bool _print = true);
int permission(const int _lev, const int _warn = 0);
......@@ -142,9 +139,6 @@ public:
HTML = 0x02,
RETAIN = 0x04,
KEEP_OPEN = 0x08
#ifdef DEB_SHOW_ON
, PRIMARY = 0x10
#endif
};
private:
......@@ -223,6 +217,6 @@ Stream& operator<<(Stream& _ds, const std::pair<T0, T1>& _pair)
}//namespace
#endif // DEB_out_INCLUDED
#endif // DEB_ON
#endif//REFORM_DEBOUT_HH_INCLUDED
#endif // BASE_DEBOUT_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#include "DebShow.hh"
#ifdef DEB_SHOW_ON
// [ code absent ]
#endif // DEB_SHOW_ON
\ No newline at end of file
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#pragma once
#ifndef I_DEB_SHOW_HXX
#define I_DEB_SHOW_HXX
// Undefined to inhibit DEB_show code footprint
//#define DEB_SHOW_ON 1
#ifdef DEB_SHOW_ON
// [ code absent ]
#endif // DEB_SHOW_ON
#endif // I_DEB_SHOW_HXX
......@@ -211,8 +211,6 @@ public:
bool get_indent(std::string& _str, File* _dfile, const bool is_html);
}; // endclass CallStack
class File
{
private:
......@@ -327,7 +325,6 @@ public:
current_.append(str);
}
void line_break(bool _with_indent = false)
{
if (is_html()) current_.append("<br>"); // Don't bother with matching </br>
......@@ -335,7 +332,6 @@ public:
if (_with_indent) indent(false);
else at_line_start_ = true;
}
void set_level(int _lev)
......@@ -348,7 +344,6 @@ public:
current_.append(_s);
}
void print(const char _c)
{
if (_c == '\n')
......@@ -386,7 +381,6 @@ public:
current_.append(&_c, 1);
}
void print_to_ostream(const char* const _s, std::ostream& os)
{
os << _s;
......@@ -581,11 +575,6 @@ public:
}
add_time(str);
str.append("[ Build: " __TIME__ " " __DATE__ "] ");
#ifdef DEB_SHOW_ON
// Add link in deb_out.htm to deb_show.htm
if (is_html())
str.append(" :: <A HREF=\"ReForm_deb_show.htm\">ReForm_deb_show.htm</A><BR>\n");
#endif
if (is_html()) str.append("<BR>");
str.append("\n");
}
......@@ -684,17 +673,13 @@ public:
void set_module_level(const char* const _module, const int _lev)
{
if (this)
{
std::pair<module_map_itr, bool> ins = module_map_.insert(
std::pair<std::string, module_stats>(_module, module_stats(_lev)));
if (!ins.second) ins.first->second.lev_ = _lev;
}
std::pair<module_map_itr, bool> ins = module_map_.insert(
std::pair<std::string, module_stats>(_module, module_stats(_lev)));
if (!ins.second) ins.first->second.lev_ = _lev;
}
int module_level(const char* const _module) const
{
if (!this) return -1;
const_module_map_itr it = module_map_.find(std::string(_module));
if (it == module_map_.end()) return lev_;
return it->second.lev_;
......@@ -702,13 +687,9 @@ public:
void set_module_color(const char* const _module, const int _col)
{
if (this)
{
std::pair<module_map_itr, bool> ins = module_map_.insert(
std::pair<std::string, module_stats>(_module, module_stats(lev_)));
ins.first->second.col_ = _col;
}
std::pair<module_map_itr, bool> ins = module_map_.insert(
std::pair<std::string, module_stats>(_module, module_stats(lev_)));
ins.first->second.col_ = _col;
}
int get_module_color(const char* const _module) const
......@@ -768,37 +749,18 @@ public:
}
~File()
{
// The closing of the primary DEB_out file is a good place to flush and close
// any subsidary DEB files
#ifdef DEB_SHOW_ON
if (type_ & Stream::PRIMARY)
{
DebShow::DebShowStream os;
os << file_name_ << " closing";
DebShow::DEB_show_close(os.string_out());
}
#endif
}
}; // endclass File
// =====================================
// Enter member funcs
// =====================================
Enter::Enter(const char* const _funcname, const int _count, const char* const _module)
Enter::Enter(const char* const _flnm, const char* const _funcname, const int _count) :
flnm_(_flnm), deb_outs_(0), deb_lines_(0), count_(_count), module_("")
{
// TODO: this might have to be atomic
static int id_cnt = 0;
module_ = _module;
deb_outs_ = 0;
deb_lines_ = 0;
id_ = ++id_cnt;
count_ = _count;
stream(0, false).dfile()->call_stack().add(_funcname, this);
}
......@@ -901,7 +863,7 @@ void FunctionCallSequence::get_indent(std::string& _str, File* _dfile, bool _is_
}
else _str.append("&lt;");
_str.append(deb->module_, 1);
_str.append(deb->flnm_, 1);
if (_dfile->link_to(_str, deb->id_, "exit", cstk, true))
{
......@@ -998,14 +960,7 @@ Stream& Stream::get_global(int _warn)
{
_warn;
// TODO: Replace with a Singleton?? ThreadArray??
#ifdef DEB_SHOW_ON
static Stream g_ds__(
"../../../../test/logs/reform_deb_out.htm",
(StreamType)(APPEND | PRIMARY) );
#else // DEB_SHOW_ON
static Stream g_ds__("reform_deb_out.txt");
#endif // DEB_SHOW_ON
static Stream g_ds__("reform_deb_out.txt");
return g_ds__;
}
......@@ -1080,7 +1035,6 @@ const char* Controller::double_format()
return Stream::get_global().dfile()->double_format();
}
}//namespace Debug
......
......@@ -8,8 +8,8 @@
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef REFORM_DEBUTILS_HH_INCLUDED
#define REFORM_DEBUTILS_HH_INCLUDED
#ifndef BASE_DEBUTILS_HH_INCLUDED
#define BASE_DEBUTILS_HH_INCLUDED
#include <Base/Debug/DebOut.hh>
......@@ -63,4 +63,4 @@ private:
#endif
#endif//REFORM_DEBUTILS_HH_INCLUDED
#endif // BASE_DEBUTILS_HH_INCLUDED
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment