summaryrefslogtreecommitdiff
path: root/src/binary-reader-objdump.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-12-12 17:03:23 -0800
committerGitHub <noreply@github.com>2018-12-12 17:03:23 -0800
commitbfc4f5b9cf7d1e43896d825d5485621956a3ec3f (patch)
treee0d264bcd1098fe817fcec699f82479aa48095d8 /src/binary-reader-objdump.cc
parenta5827e0c2e5d3e4a05a65853ec5b5284dffe9585 (diff)
downloadwabt-bfc4f5b9cf7d1e43896d825d5485621956a3ec3f.tar.gz
wabt-bfc4f5b9cf7d1e43896d825d5485621956a3ec3f.tar.bz2
wabt-bfc4f5b9cf7d1e43896d825d5485621956a3ec3f.zip
Pass function body size in BinaryReader callback (#975)
This is useful for finding large functions with wasm-objdump.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r--src/binary-reader-objdump.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index fb4c3d23..ca5e4332 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -331,7 +331,7 @@ class BinaryReaderObjdumpDisassemble : public BinaryReaderObjdumpBase {
std::string BlockSigToString(Type type) const;
- Result BeginFunctionBody(Index index) override;
+ Result BeginFunctionBody(Index index, Offset size) override;
Result OnLocalDeclCount(Index count) override;
Result OnLocalDecl(Index decl_index, Index count, Type type) override;
@@ -604,7 +604,8 @@ Result BinaryReaderObjdumpDisassemble::OnEndExpr() {
return Result::Ok;
}
-Result BinaryReaderObjdumpDisassemble::BeginFunctionBody(Index index) {
+Result BinaryReaderObjdumpDisassemble::BeginFunctionBody(Index index,
+ Offset size) {
const char* name = GetFunctionName(index);
if (name) {
printf("%06" PRIzx " <%s>:\n", state->offset, name);
@@ -718,6 +719,7 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
Result OnStartFunction(Index func_index) override;
Result OnFunctionBodyCount(Index count) override;
+ Result BeginFunctionBody(Index index, Offset size) override;
Result BeginElemSection(Offset size) override {
in_elem_section_ = true;
@@ -862,7 +864,7 @@ Result BinaryReaderObjdump::BeginSection(BinarySection section_code,
name, state->offset, state->offset + size, size);
break;
case ObjdumpMode::Details:
- if (section_match && section_code != BinarySection::Code) {
+ if (section_match) {
printf("%s", name);
// All known section types except the start section have a count
// in which case this line gets completed in OnCount().
@@ -978,6 +980,11 @@ Result BinaryReaderObjdump::OnFunctionBodyCount(Index count) {
return OnCount(count);
}
+Result BinaryReaderObjdump::BeginFunctionBody(Index index, Offset size) {
+ PrintDetails(" - func[%" PRIindex "] size=%" PRIzd "\n", index, size);
+ return Result::Ok;
+}
+
Result BinaryReaderObjdump::OnStartFunction(Index func_index) {
if (options_->mode == ObjdumpMode::Headers) {
printf("start: %" PRIindex "\n", func_index);