Returns the index of a function call localtion. If not found, adds a location proto and returns the location index.
| 141 | // Returns the index of a function call localtion. If not found, adds a |
| 142 | // location proto and returns the location index. |
| 143 | uint64 GetIndex(const string& file_path, uint64 line_number, |
| 144 | const string& called_function_name, |
| 145 | const string& called_file_path, |
| 146 | uint64 called_func_start_line) { |
| 147 | auto key = std::tuple<string, string, uint64>( |
| 148 | file_path, called_function_name, line_number); |
| 149 | |
| 150 | auto idx = location_table_.find(key); |
| 151 | if (idx != location_table_.end()) { |
| 152 | return idx->second.id(); |
| 153 | } |
| 154 | pprof::Location* location_pb = &location_table_[key]; |
| 155 | location_pb->set_id(location_table_.size()); |
| 156 | pprof::Line* line_pb = location_pb->add_line(); |
| 157 | line_pb->set_function_id(function_table_->GetIndex( |
| 158 | called_file_path, called_function_name, called_func_start_line)); |
| 159 | line_pb->set_line(line_number); |
| 160 | return location_pb->id(); |
| 161 | } |
| 162 | |
| 163 | const std::map<std::tuple<string, string, uint64>, pprof::Location>& |
| 164 | locations() const { |