cprover
show_locations.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Show program locations
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "show_locations.h"
13 
14 #include <iostream>
15 
16 #include <util/xml.h>
17 #include <util/xml_irep.h>
18 
19 #include <langapi/language_util.h>
20 
22 
25  const irep_idt function_id,
27 {
28  for(goto_programt::instructionst::const_iterator
29  it=goto_program.instructions.begin();
30  it!=goto_program.instructions.end();
31  it++)
32  {
33  const source_locationt &source_location=it->source_location;
34 
35  switch(ui)
36  {
38  {
39  xmlt xml("program_location");
40  xml.new_element("function").data=id2string(function_id);
41  xml.new_element("id").data=std::to_string(it->location_number);
42 
43  xmlt &l=xml.new_element();
44  l.name="location";
45 
46  l.new_element("line").data=id2string(source_location.get_line());
47  l.new_element("file").data=id2string(source_location.get_file());
48  l.new_element("function").data=
49  id2string(source_location.get_function());
50 
51  std::cout << xml << '\n';
52  }
53  break;
54 
56  std::cout << function_id << " "
57  << it->location_number << " "
58  << it->source_location << '\n';
59  break;
60 
61  default:
63  }
64  }
65 }
66 
69  const goto_modelt &goto_model)
70 {
71  for(const auto &f : goto_model.goto_functions.function_map)
72  show_locations(ui, f.first, f.second.body);
73 }
const std::string & id2string(const irep_idt &d)
Definition: irep.h:43
const irep_idt & get_function() const
std::string name
Definition: xml.h:30
function_mapt function_map
xmlt xml(const source_locationt &location)
Definition: xml_expr.cpp:25
Symbol Table + CFG.
const irep_idt & get_line() const
instructionst instructions
The list of instructions in the goto program.
Definition: goto_program.h:403
Definition: xml.h:18
std::string data
Definition: xml.h:30
xmlt & new_element(const std::string &name)
Definition: xml.h:86
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:70
Show program locations.
const irep_idt & get_file() const
std::string to_string(const string_constraintt &expr)
Used for debug printing.
#define UNREACHABLE
Definition: invariant.h:250
goto_programt & goto_program
Definition: cover.cpp:63
void show_locations(ui_message_handlert::uit ui, const irep_idt function_id, const goto_programt &goto_program)
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:32