From b8e6c1c82d91fb6d3da2bbf825babda097685c0e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 29 Mar 2017 14:09:40 -0700 Subject: wasmdump: Fix output of local names (#372) Previously we could nest the local names inside the function names, but in the new names sections the locals all come later on. --- src/binary-reader-objdump.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/binary-reader-objdump.cc') diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 47f05770..bb251fa2 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -598,15 +598,12 @@ static Result on_function_name(uint32_t index, StringSlice name, void* user_data) { Context* ctx = static_cast(user_data); - print_details(ctx, " - func[%d] " PRIstringslice "\n", index, - WABT_PRINTF_STRING_SLICE_ARG(name)); if (ctx->options->mode == ObjdumpMode::Prepass) { - while (ctx->options->function_names.size() < index) { - ctx->options->function_names.emplace_back(); - } - if (ctx->options->function_names.size() == index) { - ctx->options->function_names.push_back(string_slice_to_string(name)); - } + ctx->options->function_names.resize(index+1); + ctx->options->function_names[index] = string_slice_to_string(name); + } else { + print_details(ctx, " - func[%d] " PRIstringslice "\n", index, + WABT_PRINTF_STRING_SLICE_ARG(name)); } return Result::Ok; } @@ -617,8 +614,8 @@ static Result on_local_name(uint32_t func_index, void* user_data) { Context* ctx = static_cast(user_data); if (name.length) { - print_details(ctx, " - local[%d] " PRIstringslice "\n", local_index, - WABT_PRINTF_STRING_SLICE_ARG(name)); + print_details(ctx, " - func[%d] local[%d] " PRIstringslice "\n", func_index, + local_index, WABT_PRINTF_STRING_SLICE_ARG(name)); } return Result::Ok; } -- cgit v1.2.3