-
Notifications
You must be signed in to change notification settings - Fork 0
/
show.cc
45 lines (36 loc) · 1.08 KB
/
show.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) 2015-2016 SUSE Linux GmbH
*
* Licensed under the GNU General Public License Version 2
* as published by the Free Software Foundation.
*
* See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* for details.
*
* Author: Joerg Roedel <jroedel@suse.de>
*/
#include <functional>
#include <iostream>
#include <string>
#include "assembly.h"
void show_symbol(const char *filename, const std::string &symbol)
{
std::unique_ptr<assembly::asm_object> obj(nullptr);
assembly::asm_file file(filename);
file.load();
if (file.has_function(symbol)) {
obj = file.get_function(symbol, assembly::func_flags::STRIP_DEBUG);
} else if (file.has_object(symbol)) {
obj = file.get_object(symbol, assembly::func_flags::STRIP_DEBUG);
} else {
std::cerr << "Error: Symbol not found: " << symbol << std::endl;
return;
}
std::cout << symbol << ":" << std::endl;
obj->for_each_statement([](assembly::asm_statement &stmt) {
std::string indent = "\t";
if (stmt.type() == assembly::stmt_type::LABEL)
indent = "";
std::cout << indent << stmt.raw() << std::endl;
});
}