Commit 0564a0a6 authored by Ian Bell's avatar Ian Bell

DEB_out. Changed module name for CrossField folder from CFLD to FELD so as to...

DEB_out. Changed module name for CrossField folder from CFLD to FELD so as to better distinguish from Curvature folder CURV module name.

Some minor tidies and corrections to IGM DEB_out. Wider indenting in .txt DEB_out.

Added navigable hover-texted summary call-stack indent texts and module colour coded text to .htm DEB_out.

[git-p4: depot-paths = "//ReForm/ReForm/main/Base/": change = 10476]
parent 0cb6072c
......@@ -18,14 +18,14 @@
#define DEB_module(SS)
#define DEB_enter_func
#define DEB_only( CC )
#define DEB_out(LL, AA )
#define DEB_out_if( CC, LL, AA )
#define DEB_warning( LL, AA )
#define DEB_warning_if( CC, LL, AA )
#define DEB_mesh_if( CC, LL, FF, MM )
#define DEB_out(LL, AA ) {}
#define DEB_out_if( CC, LL, AA ) {}
#define DEB_warning( LL, AA ) {}
#define DEB_warning_if( CC, LL, AA ) {}
#define DEB_mesh_if( CC, LL, FF, MM ) {}
#define DEB_error(AA)
#define DEB_error_if(CC, AA)
#define DEB_error(AA) {}
#define DEB_error_if(CC, AA) {}
#else // DEB_ON
......@@ -98,9 +98,11 @@ public:
{
public:
int id_;
int count_;
int deb_outs_; /*!< Number of DEB_outs encountered within this function
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. */
DebEnter(const char * const _funcname, const int _count,const char * const _module);
......
......@@ -33,21 +33,21 @@ namespace ReForm
class FunctionCallSequence
{
std::string func_name_;
std::vector<int> counts_; // These may not be sequential when multithreaded.
std::vector<DebEnter *> debs_; // These may not have sequential counts when multithreaded.
public:
FunctionCallSequence(const char * _func_name, const int _count)
FunctionCallSequence(const char * _func_name, DebEnter * _deb)
: func_name_(_func_name)
{
counts_.push_back(_count);
debs_.push_back(_deb);
}
~FunctionCallSequence() {}
bool add(const char * _func_name, const int _count)
bool add(const char * _func_name, DebEnter * _deb)
{
if (func_name_ == _func_name)
{
counts_.push_back(_count);
debs_.push_back(_deb);
return true;
}
return false;
......@@ -55,25 +55,25 @@ namespace ReForm
bool pop()
{
if (counts_.size() > 1 )
if (debs_.size() > 1 )
{
counts_.pop_back();
debs_.pop_back();
return true;
}
counts_.clear();
debs_.clear();
return false;
}
int number_calls() const
{
if (!this) return 0;
return (int)counts_.size();
return (int)debs_.size();
}
int count(int i=0) const
{
int num = number_calls();
if (i < num) return counts_[num -1 - i];
if (i < num) return debs_[num -1 - i]->count_;
return -1;
}
......@@ -99,11 +99,11 @@ namespace ReForm
}
// Get single call stack element string
void get(std::string& str, const bool _strip_angled, bool _with_counts) const
void get(std::string& _str, const bool _strip_angled, bool _with_counts) const
{
if (_strip_angled) compact_name(str);
else str.append(name());
str.append("[");
if (_strip_angled) compact_name(_str);
else _str.append(name());
_str.append("[");
if (_with_counts)
{
......@@ -112,20 +112,20 @@ namespace ReForm
int seq_cnt =0;
for (int i=0; i < num; ++i)
{
int cnt = counts_[i];
int cnt = debs_[i]->count_;
if (cnt != prev + 1)
{
char buffer[64];
if (seq_cnt > 0)
{
str.append("-");
_str.append("-");
sprintf_s(buffer, sizeof(buffer), "%i", prev);
str.append(buffer);
_str.append(buffer);
}
if (i>0) str.append(",");
if (i>0) _str.append(",");
sprintf_s(buffer, sizeof(buffer), "%i", cnt);
str.append(buffer);
_str.append(buffer);
seq_cnt=0;
}
else
......@@ -135,11 +135,13 @@ namespace ReForm
} // endif _with_counts
else
{
str.append("*");
_str.append("*");
}
str.append("]");
_str.append("]");
} // endfunc get
void indent(std::string & _str, DebFile * _dfile, bool _is_html);
}; // endclass FunctionCallSequence
......@@ -151,11 +153,11 @@ namespace ReForm
CallStack() : depth_(0) {}
~CallStack() {}
void add(const char * _func_name, const int _count)
void add(const char * _func_name, DebEnter * _deb)
{
if (calls_.empty() || !calls_.back().add(_func_name, _count))
if (calls_.empty() || !calls_.back().add(_func_name, _deb))
{
calls_.push_back( FunctionCallSequence(_func_name, _count) );
calls_.push_back( FunctionCallSequence(_func_name, _deb) );
}
++depth_;
}
......@@ -202,7 +204,8 @@ namespace ReForm
int depth() const { return depth_; }
}; // endclass CallStack
bool indent(std::string& _str, DebFile * _dfile, const bool is_html);
}; // endclass CallStack
......@@ -226,11 +229,12 @@ private:
int lev_;
int num_flush_;
int priority_; // Last permission granted
int indent_size_;
std::string current_;
std::string output_;
std::string file_name_;
std::fstream file_stream_;
std::string indent_string_;
//std::string indent_string_;
DebStream * deb_stream_;
CallStack call_stack_;
......@@ -244,6 +248,7 @@ public:
bool is_appended() const { return 0 != (type_ & DebStream::StreamType::append); }
// Only applies to HTML DEB_out
bool is_white_on_black() const { return true; }
int indent_size() { return indent_size_; }
bool file_is_open() const { return file_stream_.is_open(); }
int priority() const { return priority_; }
......@@ -272,25 +277,21 @@ public:
return '\0';
}
void indent(int _depth)
void indent()
{
for (int i=0; i < _depth; ++i)
{
if (is_html()) current_.append("-");
//else current_.append(" ");
}
std::string str;
if (call_stack().indent(str, this, is_html()))
current_.append(str);
}
void line_break(bool _with_indent = true)
{
_with_indent;
if ( is_html() ) current_.append("<br>"); // Don't bother with matching </br>
current_.append("\n", 1);
if (_with_indent)
{
indent(call_stack().depth() );
}
if (_with_indent) indent();
}
......@@ -304,8 +305,34 @@ public:
void print(const char _c)
{
if (_c == '\n') line_break();
else current_.append(&_c, 1);
if (_c == '\n')
{
line_break();
return;
}
if ( is_html() )
{ // translate the esoteric characters used in IGM DEB_out
if( _c == '') // -62
{
return;
}
if (_c == '') // 167 = -89
{
current_.append("&sect;");
return;
}
if (_c == '') // -80
{
current_.append("&deg;");
return;
}
}
current_.append(&_c, 1);
}
void print(const char * const _s, bool _fork = true)
......@@ -325,7 +352,6 @@ public:
if (fork_to_cerr())
std::cerr << _s;
}
}
}
......@@ -356,7 +382,6 @@ public:
}
}
DebStream & stream() { return *deb_stream_; }
// Append current asctime to given string
......@@ -380,7 +405,7 @@ public:
}
#if 0
#if 1
bool hover(std::string & _str, const std::string & _hover, const bool _open)
{
if (is_html())
......@@ -447,16 +472,23 @@ public:
if ( is_white_on_black() )
{
str.append( "\n<BODY BGCOLOR=\"#000000\" TEXT=\"#FFFFFF\" LINK=\"#%00FFFF\" VLINK=\"#FFFF00\" >");
//str.append( "\n<BODY BGCOLOR=\"#000000\" TEXT=\"#FFFFFF\" >");
}
else
{
str.append("\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#%FF0000\" VLINK=\"#0000FF\" >");
//str.append( "\n<BODY BGCOLOR=\"#000000\" TEXT=\"#FFFFFF\" >");
}
str.append("\n");
} // endif is_html
bool date_header = true;
if (date_header)
{
if(!file_name_.empty())
{
str.append(file_name_);
str.append(" opened ");
}
add_time(str);
str.append( "[ Build: " __TIME__ " " __DATE__ "] ");
if (is_html()) str.append("<BR>");
......@@ -469,7 +501,9 @@ public:
bool date_footer = true;
if (date_footer)
{
std::string str = " \n Closed: ";
std::string str("\n");
if(!file_name_.empty()) str.append(file_name_);
str.append(" Closed: ");
add_time(str);
stream() << str << "\n";
}
......@@ -478,8 +512,8 @@ public:
{
stream().print("\n</BODY></HTML>", false);
}
}
bool is_first_flush()
{
return num_flush_ == 0 ;
......@@ -552,7 +586,6 @@ public:
{
type_ = (DebStream::StreamType)(type_ | DebStream::StreamType::html);
}
}
void set_module_level(const char * const _module, const int _lev)
......@@ -597,9 +630,8 @@ public:
if (lev > 0) priority_ = lev;
return lev;
}
bool at_line_start()
bool is_at_line_start()
{
char prev = prev_char();
return (prev=='\n') || (prev=='\0');
......@@ -613,12 +645,15 @@ public:
type_(_type), lev_(5), deb_stream_(_deb_stream), num_flush_(0)
{
set_file_name(_file_name);
indent_string_ = ".";
set_module_color("PARA", 0xFF0000);
indent_size_ = 3;
// indent_string_ = ".";
set_module_color("PARA", 0xFF8000);
set_module_color("SOLV", 0x00FF00);
set_module_color("NSLV", 0xFFFF00);
set_module_color("CFLD", 0x0000FF);
set_module_color("FELD", 0x0080FF);
set_module_color("CURV", 0x00FFFF);
set_module_color("QMGN", 0xFF00FF);
// Don't set a TEST module colour here because Test is not part of Reform
}
~DebFile() {}
......@@ -636,28 +671,21 @@ DebEnter::DebEnter(const char * const _funcname, const int _count, const char *
static int id_cnt=0;
module_ = _module;
deb_outs_ = 0;
deb_lines_ = 0;
id_ = ++id_cnt;
stream(0, false).dfile()->call_stack().add(_funcname, _count);
count_ = _count;
stream(0, false).dfile()->call_stack().add(_funcname, this);
}
DebEnter::~DebEnter()
{
DebFile * impl = stream(0, false).dfile();
impl->call_stack().pop();
std::string str;
if ((deb_outs_ > 0) && impl->anchor(str, id_, "exit", true))
if ( ((deb_outs_ > 0) || (deb_lines_ >0)) && impl->anchor(str, id_, "exit", true))
{
std::string cstk;
impl->call_stack().get(cstk);
if (impl->link_to(str, id_, "enter", cstk, true))
{
str.append("&lt;");
impl->link_to(str, id_, "enter", cstk, false);
}
impl->anchor(str, id_, "exit", false);
impl->anchor(str, id_, "exit", false);
impl->print_direct(str);
}
}
......@@ -682,32 +710,28 @@ DebStream& DebEnter::stream(const int _warn, const bool _print)
{
// First DEB_out in this function so output callstack, and flush.
std::string str;
std::string cstk;
bool is_html = impl->is_html();
if (is_html)
{
str.append("<FONT SIZE=2>");
impl->anchor(str, id_,"enter", true);
}
str.append("***");
if (is_html)
{
impl->anchor(str, id_,"enter", false);
impl->link_to(str, id_,"exit", cstk, true);
str.append("&gt;");
impl->link_to(str, id_,"exit", cstk, false);
str.append("<FONT SIZE=2><u>");
impl->anchor(str, id_,"enter", true);
}
else
{ // .txt call stack lead in
str.append("****>");
}
impl->call_stack().get(str);
if (is_html) str.append("</FONT>");
if (is_html) str.append("</u></FONT>");
str.append("\n");
ds.print(str.c_str(), false); // Don't fork callstack to cerr etc.
ds.dfile()->flush();
}
else
{
if ( impl->at_line_start() )
if ( impl->is_at_line_start() )
{
impl->indent( impl->call_stack().depth() );
impl->indent();
}
}
++deb_outs_;
......@@ -722,6 +746,74 @@ int DebEnter::permission(const int _lev, const int _warn)
return res;
}
void FunctionCallSequence::indent(std::string & _str, DebFile * _dfile, bool _is_html)
{
int num = number_calls();
for (int i=0; i<num; ++i)
{
DebEnter * deb = debs_[i];
if (_is_html)
{
/* HTML indent element is <L> with span title the name and count
of the function and with < linking to the entry anchor (if present) and
> linking to the exit anchor (will be present).
L is the first letter of the module name */
char hovert[1024];
sprintf_s(hovert, sizeof(hovert), "%s[%i]", func_name_.c_str(), deb->count_);
int col = _dfile->get_module_color(deb->module_);
char buffer[1024];
sprintf_s(buffer, sizeof(buffer), "<FONT COLOR=\"#%06X\">.", col);
_dfile->hover(_str, std::string(hovert), true);
_str.append(buffer);
std::string cstk;
//impl->call_stack().get(cstk);
if ((deb->deb_outs_>0) && _dfile->link_to(_str, deb->id_, "enter", cstk, true))
{
_str.append("&lt;");
_dfile->link_to(_str, deb->id_, "enter", cstk, false);
}
else _str.append("&lt;");
_str.append(deb->module_, 1);
if (_dfile->link_to(_str, deb->id_, "exit", cstk, true))
{
_str.append("&gt;");
_dfile->link_to(_str, deb->id_, "exit", cstk, false);
++deb->deb_lines_;
}
_dfile->hover(_str, std::string(hovert), false);
_str.append("</FONT>");
} // endif html
else _str.append(" ");
}
}
bool CallStack::indent(std::string& _str, DebFile * _dfile, const bool is_html)
{
if (_dfile->indent_size() == 0) return false;
if (is_html)
{
char buffer[64];
sprintf_s(buffer, sizeof(buffer), "<FONT SIZE=%i>", _dfile->indent_size());
_str.append(buffer);
}
int num = (int)calls_.size();
for (int i =0; i< num; ++i)
{
calls_[i].indent(_str, _dfile, is_html);
}
if (is_html) _str.append(":&nbsp;</FONT>\n");
return true;
}
// =====================================
// DebStream member funcs
// =====================================
......
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