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 
23  const irep_idt function_id,
24  const goto_programt &goto_program)
25 {
26  for(goto_programt::instructionst::const_iterator
27  it=goto_program.instructions.begin();
28  it!=goto_program.instructions.end();
29  it++)
30  {
31  const source_locationt &source_location=it->source_location;
32 
33  switch(ui)
34  {
36  {
37  xmlt xml("program_location");
38  xml.new_element("function").data=id2string(function_id);
39  xml.new_element("id").data=std::to_string(it->location_number);
40 
41  xmlt &l=xml.new_element();
42  l.name="location";
43 
44  l.new_element("line").data=id2string(source_location.get_line());
45  l.new_element("file").data=id2string(source_location.get_file());
46  l.new_element("function").data=
47  id2string(source_location.get_function());
48 
49  std::cout << xml << '\n';
50  }
51  break;
52 
54  std::cout << function_id << " "
55  << it->location_number << " "
56  << it->source_location << '\n';
57  break;
58 
59  default:
60  assert(false);
61  }
62  }
63 }
64 
67  const goto_functionst &goto_functions)
68 {
69  for(goto_functionst::function_mapt::const_iterator
70  it=goto_functions.function_map.begin();
71  it!=goto_functions.function_map.end();
72  it++)
73  show_locations(ui, it->first, it->second.body);
74 }
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
instructionst instructions
The list of instructions in the goto program.
const irep_idt & get_function() const
std::string name
Definition: xml.h:30
xmlt xml(const source_locationt &location)
Definition: xml_expr.cpp:25
const irep_idt & get_line() const
Definition: xml.h:18
std::string data
Definition: xml.h:30
xmlt & new_element(const std::string &name)
Definition: xml.h:86
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
Definition: goto_program.h:24
Show program locations.
const irep_idt & get_file() const
void show_locations(ui_message_handlert::uit ui, const irep_idt function_id, const goto_programt &goto_program)