diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea519e..3ae90c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v2.2 + +- stdump: The `functions` and `globals` subcommands now output a header comment like the `types` command. +- stdump: The output format of the `files` subcommand has been updated. + ## v2.1 - Variable symbols are no longer incorrectly deduplicated as if they were types. diff --git a/README.md b/README.md index 5f28531..853ac33 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This is intended to be used with [ghidra-emotionengine-reloaded](https://github. ### uncc -This is similar to stdump except it organizes its output into separate source files, and has a number of extra features designed to try and make said output closer to valid source code. A `SOURCES.txt` file must be provided in the output directory, which can be generated using the `stdump files` command (you should fixup the paths manually so that they're relative to the output directory, and remove the address comments). Additionally, non-empty files that do not start with `// STATUS: NOT STARTED` will not be overwritten. +This is similar to stdump except it organizes its output into separate source files, and has a number of extra features designed to try and make said output closer to valid source code. A `SOURCES.txt` file must be provided in the output directory, which can be generated using the `stdump files` command (you should fixup the paths manually so that they're relative to the output directory, and remove the addresses). Additionally, non-empty files that do not start with `// STATUS: NOT STARTED` will not be overwritten. If a `FUNCTIONS.txt` file is provided in the output directory, as can be generated using the included `CCCDecompileAllFunctions.java` script for Ghidra, the code from that file will be used to populate the function bodies in the output. In this case, the first group of local variable declarations emitted will be those recovered from the symbols, and the second group will be from the code provided in the functions file. Function names are demangled. diff --git a/src/stdump.cpp b/src/stdump.cpp index 13f8b2a..65cd6a4 100644 --- a/src/stdump.cpp +++ b/src/stdump.cpp @@ -227,6 +227,8 @@ static void print_functions(FILE* out, const Options& options) CppPrinter printer(out, config); + printer.comment_block_beginning(options.input_file.filename().string().c_str(), "stdump", get_version()); + bool first_iteration = true; SourceFileHandle source_file_handle; for(const Function* function : functions) { @@ -267,6 +269,8 @@ static void print_globals(FILE* out, const Options& options) CppPrinter printer(out, config); + printer.comment_block_beginning(options.input_file.filename().string().c_str(), "stdump", get_version()); + bool first_iteration = true; SourceFileHandle source_file_handle; for(const GlobalVariable* global_variable : global_variables) { @@ -304,9 +308,11 @@ static void print_types_deduplicated(FILE* out, SymbolDatabase& database, const config.caller_stack_offsets = options.flags & FLAG_CALLER_STACK_OFFSETS; CppPrinter printer(out, config); + printer.comment_block_beginning(options.input_file.filename().string().c_str(), "stdump", get_version()); printer.comment_block_toolchain_version_info(database); printer.comment_block_builtin_types(database); + for(const DataType& data_type : database.data_types) { printer.data_type(data_type, database); } @@ -318,6 +324,7 @@ static void print_types_per_file(FILE* out, SymbolDatabase& database, const Opti config.caller_stack_offsets = options.flags & FLAG_CALLER_STACK_OFFSETS; CppPrinter printer(out, config); + printer.comment_block_beginning(options.input_file.filename().string().c_str(), "stdump", get_version()); for(const SourceFile& source_file : database.source_files) { @@ -422,7 +429,7 @@ static void print_files(FILE* out, const Options& options) SymbolDatabase database = read_symbol_table(symbol_file, options); for(const SourceFile& source_file : database.source_files) { - fprintf(out, "/* %08x */ %s\n", source_file.address().value, source_file.name().c_str()); + fprintf(out, "%08x %s\n", source_file.address().value, source_file.name().c_str()); } }