Skip to content

Add symex-backtrace #3468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/goto-symex/goto_symex_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,3 +774,26 @@ void goto_symex_statet::get_l1_name(exprt &expr) const
Forall_operands(it, expr)
get_l1_name(*it);
}

/// Dumps the current state of symex, printing the function name and location
/// number for each stack frame in the currently active thread.
/// This is for use from the debugger or in debug code; please don't delete it
/// just because it isn't called at present.
/// \param out: stream to write to
void goto_symex_statet::print_backtrace(std::ostream &out) const
{
out << source.pc->function << " " << source.pc->location_number << "\n";

for(auto stackit = threads[source.thread_nr].call_stack.rbegin(),
stackend = threads[source.thread_nr].call_stack.rend();
stackit != stackend;
++stackit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ I would suggest the slighly nicer:

for(const auto &frame : make_range(
    threads[source.thread_nr].call_stack.rbegin(),
    threads[source.thread_nr].call_stack.rend()))

{
const auto &frame = *stackit;
if(frame.calling_location.is_set)
{
out << frame.calling_location.pc->function << " "
<< frame.calling_location.pc->location_number << "\n";
}
}
}
2 changes: 2 additions & 0 deletions src/goto-symex/goto_symex_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ class goto_symex_statet final
void pop_frame() { call_stack().pop_back(); }
const framet &previous_frame() { return *(--(--call_stack().end())); }

void print_backtrace(std::ostream &) const;

// threads
unsigned atomic_section_id;
typedef std::pair<unsigned, std::list<guardt> > a_s_r_entryt;
Expand Down