Skip to content

Commit 6d85303

Browse files
authored
Merge pull request #3468 from smowton/smowton/feature/symex-backtrace
Add symex-backtrace
2 parents c752d9d + b34875a commit 6d85303

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,3 +774,26 @@ void goto_symex_statet::get_l1_name(exprt &expr) const
774774
Forall_operands(it, expr)
775775
get_l1_name(*it);
776776
}
777+
778+
/// Dumps the current state of symex, printing the function name and location
779+
/// number for each stack frame in the currently active thread.
780+
/// This is for use from the debugger or in debug code; please don't delete it
781+
/// just because it isn't called at present.
782+
/// \param out: stream to write to
783+
void goto_symex_statet::print_backtrace(std::ostream &out) const
784+
{
785+
out << source.pc->function << " " << source.pc->location_number << "\n";
786+
787+
for(auto stackit = threads[source.thread_nr].call_stack.rbegin(),
788+
stackend = threads[source.thread_nr].call_stack.rend();
789+
stackit != stackend;
790+
++stackit)
791+
{
792+
const auto &frame = *stackit;
793+
if(frame.calling_location.is_set)
794+
{
795+
out << frame.calling_location.pc->function << " "
796+
<< frame.calling_location.pc->location_number << "\n";
797+
}
798+
}
799+
}

src/goto-symex/goto_symex_state.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class goto_symex_statet final
230230
void pop_frame() { call_stack().pop_back(); }
231231
const framet &previous_frame() { return *(--(--call_stack().end())); }
232232

233+
void print_backtrace(std::ostream &) const;
234+
233235
// threads
234236
unsigned atomic_section_id;
235237
typedef std::pair<unsigned, std::list<guardt> > a_s_r_entryt;

0 commit comments

Comments
 (0)