The --verify option is now working properly again. Use "--verify --verbose"
if you wish to see memory usage statistics along with a top-level trace.
This commit is contained in:
parent
961b30926b
commit
162d982b0c
9 changed files with 98 additions and 48 deletions
16
format.cc
16
format.cc
|
|
@ -343,11 +343,19 @@ void format_t::format(std::ostream& out_str, const details_t& details) const
|
||||||
case element_t::AMOUNT:
|
case element_t::AMOUNT:
|
||||||
case element_t::TOTAL:
|
case element_t::TOTAL:
|
||||||
case element_t::VALUE_EXPR: {
|
case element_t::VALUE_EXPR: {
|
||||||
value_expr calc;
|
value_expr * calc;
|
||||||
switch (elem->type) {
|
switch (elem->type) {
|
||||||
case element_t::AMOUNT: calc = amount_expr; break;
|
case element_t::AMOUNT:
|
||||||
case element_t::TOTAL: calc = total_expr; break;
|
assert(value_expr::amount_expr.get());
|
||||||
case element_t::VALUE_EXPR: calc = elem->val_expr; break;
|
calc = value_expr::amount_expr.get();
|
||||||
|
break;
|
||||||
|
case element_t::TOTAL:
|
||||||
|
assert(value_expr::total_expr.get());
|
||||||
|
calc = value_expr::total_expr.get();
|
||||||
|
break;
|
||||||
|
case element_t::VALUE_EXPR:
|
||||||
|
calc = const_cast<value_expr *>(&elem->val_expr);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
25
main.cc
25
main.cc
|
|
@ -314,6 +314,31 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
|
|
||||||
INFO_FINISH(command);
|
INFO_FINISH(command);
|
||||||
|
|
||||||
|
// Clean up memory, if we
|
||||||
|
|
||||||
|
if (DO_VERIFY()) {
|
||||||
|
TRACE_START(cleanup, 1, "Cleaning up allocated memory");
|
||||||
|
|
||||||
|
clear_transaction_xdata xact_cleaner;
|
||||||
|
walk_entries(journal.entries, xact_cleaner);
|
||||||
|
|
||||||
|
clear_account_xdata acct_cleaner;
|
||||||
|
walk_accounts(*journal.master, acct_cleaner);
|
||||||
|
|
||||||
|
if (report.output_file)
|
||||||
|
checked_delete(out);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (std::list<item_handler<transaction_t> *>::iterator i
|
||||||
|
= formatter_ptrs.begin();
|
||||||
|
i != formatter_ptrs.end();
|
||||||
|
i++)
|
||||||
|
checked_delete(*i);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TRACE_FINISH(cleanup, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Write out the binary cache, if need be
|
// Write out the binary cache, if need be
|
||||||
|
|
||||||
if (session.use_cache && session.cache_dirty && session.cache_file) {
|
if (session.use_cache && session.cache_dirty && session.cache_file) {
|
||||||
|
|
|
||||||
|
|
@ -301,10 +301,12 @@ static void initialize()
|
||||||
{
|
{
|
||||||
amount_t::initialize();
|
amount_t::initialize();
|
||||||
value_t::initialize();
|
value_t::initialize();
|
||||||
|
value_expr::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shutdown()
|
static void shutdown()
|
||||||
{
|
{
|
||||||
|
value_expr::shutdown();
|
||||||
value_t::shutdown();
|
value_t::shutdown();
|
||||||
amount_t::shutdown();
|
amount_t::shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,14 @@ struct time_entry_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
expr::parser_t amount_parser;
|
value_expr parse_amount_expr(std::istream& in,
|
||||||
|
amount_t& amount,
|
||||||
static value_expr parse_amount_expr(std::istream& in, amount_t& amount,
|
|
||||||
transaction_t * xact,
|
transaction_t * xact,
|
||||||
unsigned short flags = 0)
|
unsigned short flags = 0)
|
||||||
{
|
{
|
||||||
value_expr expr =
|
value_expr expr =
|
||||||
amount_parser.parse(in, flags | EXPR_PARSE_RELAXED | EXPR_PARSE_PARTIAL);
|
value_expr::parser->parse(in, flags |
|
||||||
|
EXPR_PARSE_RELAXED | EXPR_PARSE_PARTIAL);
|
||||||
|
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
||||||
"Parsed an amount expression");
|
"Parsed an amount expression");
|
||||||
|
|
|
||||||
9
utils.cc
9
utils.cc
|
|
@ -109,8 +109,7 @@ void shutdown_memory_tracing()
|
||||||
if (live_objects) {
|
if (live_objects) {
|
||||||
IF_DEBUG("memory.counts")
|
IF_DEBUG("memory.counts")
|
||||||
report_memory(std::cerr, true);
|
report_memory(std::cerr, true);
|
||||||
else
|
else IF_DEBUG("memory.counts.live")
|
||||||
IF_DEBUG("memory.counts.live")
|
|
||||||
report_memory(std::cerr);
|
report_memory(std::cerr);
|
||||||
else if (live_objects->size() > 0)
|
else if (live_objects->size() > 0)
|
||||||
report_memory(std::cerr);
|
report_memory(std::cerr);
|
||||||
|
|
@ -254,7 +253,7 @@ inline void report_count_map(std::ostream& out, object_count_map& the_map)
|
||||||
i != the_map.end();
|
i != the_map.end();
|
||||||
i++)
|
i++)
|
||||||
out << " " << std::right << std::setw(12) << (*i).second.first
|
out << " " << std::right << std::setw(12) << (*i).second.first
|
||||||
<< " " << std::right << std::setw(12) << (*i).second.second
|
<< " " << std::right << std::setw(7) << (*i).second.second
|
||||||
<< " " << std::left << (*i).first
|
<< " " << std::left << (*i).first
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +346,7 @@ void report_memory(std::ostream& out, bool report_all)
|
||||||
for (live_memory_map::const_iterator i = live_memory->begin();
|
for (live_memory_map::const_iterator i = live_memory->begin();
|
||||||
i != live_memory->end();
|
i != live_memory->end();
|
||||||
i++)
|
i++)
|
||||||
out << " " << std::right << std::setw(7) << (*i).first
|
out << " " << std::right << std::setw(12) << (*i).first
|
||||||
<< " " << std::right << std::setw(7) << (*i).second.second
|
<< " " << std::right << std::setw(7) << (*i).second.second
|
||||||
<< " " << std::left << (*i).second.first
|
<< " " << std::left << (*i).second.first
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
@ -369,7 +368,7 @@ void report_memory(std::ostream& out, bool report_all)
|
||||||
for (live_objects_map::const_iterator i = live_objects->begin();
|
for (live_objects_map::const_iterator i = live_objects->begin();
|
||||||
i != live_objects->end();
|
i != live_objects->end();
|
||||||
i++)
|
i++)
|
||||||
out << " " << std::right << std::setw(7) << (*i).first
|
out << " " << std::right << std::setw(12) << (*i).first
|
||||||
<< " " << std::right << std::setw(7) << (*i).second.second
|
<< " " << std::right << std::setw(7) << (*i).second.second
|
||||||
<< " " << std::left << (*i).second.first
|
<< " " << std::left << (*i).second.first
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
|
||||||
29
valexpr.cc
29
valexpr.cc
|
|
@ -36,9 +36,6 @@
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
value_expr amount_expr;
|
|
||||||
value_expr total_expr;
|
|
||||||
|
|
||||||
namespace expr {
|
namespace expr {
|
||||||
|
|
||||||
std::auto_ptr<symbol_scope_t> global_scope;
|
std::auto_ptr<symbol_scope_t> global_scope;
|
||||||
|
|
@ -307,14 +304,14 @@ void op_t::compute(value_t& result, const details_t& details,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALUE_EXPR:
|
case VALUE_EXPR:
|
||||||
if (amount_expr.get())
|
if (value_expr::amount_expr.get())
|
||||||
amount_expr->compute(result, details, context);
|
value_expr::amount_expr->compute(result, details, context);
|
||||||
else
|
else
|
||||||
result = 0L;
|
result = 0L;
|
||||||
break;
|
break;
|
||||||
case TOTAL_EXPR:
|
case TOTAL_EXPR:
|
||||||
if (total_expr.get())
|
if (value_expr::total_expr.get())
|
||||||
total_expr->compute(result, details, context);
|
value_expr::total_expr->compute(result, details, context);
|
||||||
else
|
else
|
||||||
result = 0L;
|
result = 0L;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1080,8 +1077,20 @@ value_t op_t::calc(scope_t& scope)
|
||||||
|
|
||||||
} // namespace expr
|
} // namespace expr
|
||||||
|
|
||||||
namespace {
|
std::auto_ptr<value_expr> value_expr::amount_expr;
|
||||||
expr::parser_t value_expr_parser;
|
std::auto_ptr<value_expr> value_expr::total_expr;
|
||||||
|
std::auto_ptr<expr::parser_t> value_expr::parser;
|
||||||
|
|
||||||
|
void value_expr::initialize()
|
||||||
|
{
|
||||||
|
parser.reset(new expr::parser_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void value_expr::shutdown()
|
||||||
|
{
|
||||||
|
amount_expr.reset();
|
||||||
|
total_expr.reset();
|
||||||
|
parser.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
value_expr::value_expr(const string& _expr_str) : expr_str(_expr_str)
|
value_expr::value_expr(const string& _expr_str) : expr_str(_expr_str)
|
||||||
|
|
@ -1089,7 +1098,7 @@ value_expr::value_expr(const string& _expr_str) : expr_str(_expr_str)
|
||||||
TRACE_CTOR(value_expr, "const string&");
|
TRACE_CTOR(value_expr, "const string&");
|
||||||
|
|
||||||
if (! _expr_str.empty())
|
if (! _expr_str.empty())
|
||||||
ptr = value_expr_parser.parse(expr_str).ptr;
|
ptr = parser->parse(expr_str).ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
28
valexpr.h
28
valexpr.h
|
|
@ -825,6 +825,8 @@ inline ptr_op_t op_t::wrap_functor(const function_t& fobj) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class parser_t;
|
||||||
|
|
||||||
} // namespace expr
|
} // namespace expr
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -902,33 +904,37 @@ public:
|
||||||
const expr::ptr_op_t node_to_find,
|
const expr::ptr_op_t node_to_find,
|
||||||
unsigned long * start_pos,
|
unsigned long * start_pos,
|
||||||
unsigned long * end_pos);
|
unsigned long * end_pos);
|
||||||
|
|
||||||
|
static std::auto_ptr<value_expr> amount_expr;
|
||||||
|
static std::auto_ptr<value_expr> total_expr;
|
||||||
|
static std::auto_ptr<expr::parser_t> parser;
|
||||||
|
|
||||||
|
static void initialize();
|
||||||
|
static void shutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef value_expr::details_t details_t; // jww (2008-07-20): remove
|
typedef value_expr::details_t details_t; // jww (2008-07-20): remove
|
||||||
|
|
||||||
extern value_expr amount_expr;
|
|
||||||
extern value_expr total_expr;
|
|
||||||
|
|
||||||
inline void compute_amount(value_t& result,
|
inline void compute_amount(value_t& result,
|
||||||
const details_t& details = details_t()) {
|
const details_t& details = details_t()) {
|
||||||
if (amount_expr)
|
if (value_expr::amount_expr.get())
|
||||||
amount_expr->compute(result, details);
|
value_expr::amount_expr->compute(result, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline value_t compute_amount(const details_t& details = details_t()) {
|
inline value_t compute_amount(const details_t& details = details_t()) {
|
||||||
if (amount_expr)
|
if (value_expr::amount_expr.get())
|
||||||
return amount_expr->compute(details);
|
return value_expr::amount_expr->compute(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void compute_total(value_t& result,
|
inline void compute_total(value_t& result,
|
||||||
const details_t& details = details_t()) {
|
const details_t& details = details_t()) {
|
||||||
if (total_expr)
|
if (value_expr::total_expr.get())
|
||||||
total_expr->compute(result, details);
|
value_expr::total_expr->compute(result, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline value_t compute_total(const details_t& details = details_t()) {
|
inline value_t compute_total(const details_t& details = details_t()) {
|
||||||
if (total_expr)
|
if (value_expr::total_expr.get())
|
||||||
return total_expr->compute(details);
|
return value_expr::total_expr->compute(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
3
walk.h
3
walk.h
|
|
@ -110,7 +110,6 @@ struct transaction_xdata_t : public noncopyable
|
||||||
account(NULL), ptr(NULL), component_xacts(NULL) {
|
account(NULL), ptr(NULL), component_xacts(NULL) {
|
||||||
TRACE_CTOR(transaction_xdata_t, "");
|
TRACE_CTOR(transaction_xdata_t, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
~transaction_xdata_t() {
|
~transaction_xdata_t() {
|
||||||
TRACE_DTOR(transaction_xdata_t);
|
TRACE_DTOR(transaction_xdata_t);
|
||||||
if (component_xacts)
|
if (component_xacts)
|
||||||
|
|
@ -154,9 +153,11 @@ transaction_xdata_t& transaction_xdata(const transaction_t& xact);
|
||||||
void add_transaction_to(const transaction_t& xact, value_t& value);
|
void add_transaction_to(const transaction_t& xact, value_t& value);
|
||||||
|
|
||||||
inline account_t * xact_account(transaction_t& xact) {
|
inline account_t * xact_account(transaction_t& xact) {
|
||||||
|
if (xact.data) {
|
||||||
account_t * account = transaction_xdata(xact).account;
|
account_t * account = transaction_xdata(xact).account;
|
||||||
if (account)
|
if (account)
|
||||||
return account;
|
return account;
|
||||||
|
}
|
||||||
return xact.account;
|
return xact.account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue