1 Star 1 Fork 0

Rong Tao/autofdo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
instruction_map.h 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
Wei Mi 提交于 2021-05-09 10:38 . Update to latest internal version.
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: dehao@google.com (Dehao Chen)
// Class to build a map from instruction address to its information.
#ifndef AUTOFDO_INSTRUCTION_MAP_H_
#define AUTOFDO_INSTRUCTION_MAP_H_
#include <cstdint>
#include <map>
#include <string>
#include <utility>
#include "base/integral_types.h"
#include "base/logging.h"
#include "base/macros.h"
#include "symbol_map.h"
namespace devtools_crosstool_autofdo {
class SampleReader;
class Addr2line;
// InstructionMap stores all the disassembled instructions in
// the binary, and maps it to its information.
class InstructionMap {
public:
// Arguments:
// addr2line: addr2line class, used to get the source stack.
// symbol: the symbol map. This object is not const because
// we will update the file name of each symbol
// according to the debug info of each instruction.
InstructionMap(Addr2line *addr2line,
SymbolMap *symbol)
: symbol_map_(symbol), addr2line_(addr2line) {
}
// Deletes all the InstInfo, which was allocated in BuildInstMap.
~InstructionMap();
// Returns the size of the instruction map.
uint64_t size() const { return inst_map_.size(); }
// Builds instruction map for a function.
void BuildPerFunctionInstructionMap(const std::string &name,
uint64_t start_addr, uint64_t end_addr);
// Contains information about each instruction.
struct InstInfo {
const SourceInfo &source(int i) const {
DCHECK(i >= 0 && source_stack.size() > i);
return source_stack[i];
}
SourceStack source_stack;
};
typedef std::map<uint64_t, InstInfo *> InstMap;
const InstMap &inst_map() const {
return inst_map_;
}
private:
// A map from instruction address to its information.
InstMap inst_map_;
// A map from symbol name to symbol data.
SymbolMap *symbol_map_;
// Addr2line driver which is used to derive source stack.
Addr2line *addr2line_;
DISALLOW_COPY_AND_ASSIGN(InstructionMap);
};
} // namespace devtools_crosstool_autofdo
#endif // AUTOFDO_INSTRUCTION_MAP_H_
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rtoax/autofdo.git
git@gitee.com:rtoax/autofdo.git
rtoax
autofdo
autofdo
master

搜索帮助