Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeComma
BreakTemplateDeclarations: Yes
ColumnLimit: 120
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Expand All @@ -48,13 +48,8 @@ IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 3
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 500
PointerAlignment: Left
ReflowComments: false
Expand Down
1 change: 0 additions & 1 deletion src/ccc/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#pragma once

#include "int128.h"
#include "symbol_database.h"

namespace ccc::ast {
Expand Down
6 changes: 3 additions & 3 deletions src/ccc/ast_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#pragma once

#include "ast.h"
#include "symbol_database.h"

#define RAPIDJSON_HAS_STDSTRING 1
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>

#include "ast.h"
#include "symbol_database.h"

namespace ccc::ast {

template <typename Writer>
Expand Down
5 changes: 3 additions & 2 deletions src/ccc/data_refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include "data_refinement.h"

#include <cinttypes>

#include "ast.h"
#include "int128.h"

#include <cinttypes>

namespace ccc {

Expand Down
2 changes: 0 additions & 2 deletions src/ccc/dwarf_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "dwarf_section.h"

#include "importer_flags.h"

namespace ccc::dwarf {

Result<std::optional<DIE>> DIE::parse(std::span<const u8> debug, u32 offset, u32 importer_flags)
Expand Down
3 changes: 2 additions & 1 deletion src/ccc/elf_symtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ Result<void> import_symbols(SymbolDatabase& database,
// and aren't extremely useful, so we want to mark them to
// prevent them from possibly being used as function names.
(*label)->is_junk = (*label)->name() == "__gnu_compiled_c"
|| (*label)->name() == "__gnu_compiled_cplusplus" || (*label)->name() == "gcc2_compiled.";
|| (*label)->name() == "__gnu_compiled_cplusplus"
|| (*label)->name() == "gcc2_compiled.";

break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ccc/mdebug_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Result<void> LocalSymbolTableAnalyser::data_type(const ParsedSymbol& symbol)
}

bool is_struct = (*node)->descriptor == ast::STRUCT_OR_UNION && (*node)->as<ast::StructOrUnion>().is_struct;
bool force_typedef = ((m_context.importer_flags & TYPEDEF_ALL_ENUMS) && (*node)->descriptor == ast::ENUM)
|| ((m_context.importer_flags & TYPEDEF_ALL_STRUCTS) && (*node)->descriptor == ast::STRUCT_OR_UNION
&& is_struct)
bool force_typedef =
((m_context.importer_flags & TYPEDEF_ALL_ENUMS) && (*node)->descriptor == ast::ENUM)
|| ((m_context.importer_flags & TYPEDEF_ALL_STRUCTS) && (*node)->descriptor == ast::STRUCT_OR_UNION && is_struct)
|| ((m_context.importer_flags & TYPEDEF_ALL_UNIONS) && (*node)->descriptor == ast::STRUCT_OR_UNION
&& !is_struct);

Expand Down
4 changes: 2 additions & 2 deletions src/ccc/mdebug_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#pragma once

#include "util.h"
#include "stabs.h"
#include "mdebug_section.h"
#include "stabs.h"
#include "util.h"

namespace ccc::mdebug {

Expand Down
8 changes: 4 additions & 4 deletions src/ccc/print_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

#include "print_cpp.h"

#include <cmath>
#include <chrono>

#include "ast.h"
#include "registers.h"

#include <cmath>
#include <chrono>
#include <set>

namespace ccc {

enum VariableNamePrintFlags
Expand Down Expand Up @@ -102,7 +103,6 @@ void CppPrinter::comment_block_file(const char* path)
m_has_anything_been_printed = true;
}


void CppPrinter::begin_include_guard(const char* macro)
{
if (m_has_anything_been_printed) {
Expand Down
4 changes: 2 additions & 2 deletions src/ccc/stabs_to_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Result<std::unique_ptr<ast::Node>> stabs_type_to_ast(const StabsType& type,

// This prevents infinite recursion when an automatically generated member
// function references an unnamed type.
bool can_compare_type_numbers = type.type_number.valid() && enclosing_struct
&& enclosing_struct->type_number.valid();
bool can_compare_type_numbers = type.type_number.valid()
&& enclosing_struct && enclosing_struct->type_number.valid();
if (force_substitute && can_compare_type_numbers && type.type_number == enclosing_struct->type_number) {
// It's probably a this parameter (or return type) for an unnamed type.
auto type_name = std::make_unique<ast::TypeName>();
Expand Down
6 changes: 3 additions & 3 deletions src/ccc/symbol_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#pragma once

#include <map>
#include "util.h"

#include <atomic>
#include <limits>
#include <map>
#include <variant>

#include "util.h"

namespace ccc {

// An X macro for all the symbol types.
Expand Down
4 changes: 2 additions & 2 deletions src/ccc/symbol_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#pragma once

#include "symbol_database.h"

#define RAPIDJSON_HAS_STDSTRING 1
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>

#include "symbol_database.h"

namespace ccc {

extern const u32 JSON_FORMAT_VERSION;
Expand Down
4 changes: 2 additions & 2 deletions src/ccc/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include "symbol_table.h"

#include "elf.h"
#include "elf_symtab.h"
#include "dwarf_importer.h"
#include "dwarf_printer.h"
#include "elf.h"
#include "elf_symtab.h"
#include "mdebug_importer.h"
#include "mdebug_section.h"
#include "sndll.h"
Expand Down
4 changes: 2 additions & 2 deletions src/ccc/symbol_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#pragma once

#include <atomic>

#include "symbol_database.h"

#include <atomic>

namespace ccc {

// Determine which symbol tables are present in a given file.
Expand Down
14 changes: 7 additions & 7 deletions src/ccc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

#pragma once

#include <set>
#include <span>
#include <cstdio>
#include <vector>
#include <memory>
#include <string>
#include <cstdint>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <string>
#include <vector>

namespace ccc {

Expand Down
119 changes: 96 additions & 23 deletions src/stdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,103 @@ struct StdumpCommand
};

static const StdumpCommand commands[] = {
{identify_symbol_tables, "identify",
{"Identify the symbol table(s) present in the input file(s). If the input path",
"is a directory, it will be walked recursively."}},
{print_functions, "functions", {"Print all the functions defined in the input symbol table(s) as C++."}},
{print_globals, "globals", {"Print all the global variables defined in the input symbol table(s) as C++."}},
{print_types, "types", {"Print all the types defined in the input symbol table(s) as C++."}},
{print_type_graph, "type_graph", {"Print a dependency graph of all the types as a graphviz DOT file."}},
{print_labels, "labels",
{"Print all the labels defined in the input symbol table(s). Note that this",
"may include other symbols where their type is not recoverable."}},
{print_json, "json",
{"Print all of the above as JSON.", "",
"--compact Omit whitespace and newlines from the output."}},
{print_symbols, "symbols",
{"Print the raw symbols in the input symbol table(s). If no additional options",
{
identify_symbol_tables,
"identify",
{
"Identify the symbol table(s) present in the input file(s). If the input path",
"is a directory, it will be walked recursively.",
},
},
{
print_functions,
"functions",
{
"Print all the functions defined in the input symbol table(s) as C++.",
},
},
{
print_globals,
"globals",
{
"Print all the global variables defined in the input symbol table(s) as C++.",
},
},
{
print_types,
"types",
{
"Print all the types defined in the input symbol table(s) as C++.",
},
},
{
print_type_graph,
"type_graph",
{
"Print a dependency graph of all the types as a graphviz DOT file.",
},
},
{
print_labels,
"labels",
{
"Print all the labels defined in the input symbol table(s). Note that this",
"may include other symbols where their type is not recoverable.",
},
},
{
print_json,
"json",
{
"Print all of the above as JSON.",
"",
"--compact Omit whitespace and newlines from the output.",
},
},
{
print_symbols,
"symbols",
{
"Print the raw symbols in the input symbol table(s). If no additional options",
"are passed, the default behaviour is to print the local and external .mdebug",
"symbols, but not the procedure descriptors.", "",
"--locals Print local .mdebug symbols.", "",
"--procedures Print .mdebug procedure descriptors.", "",
"--externals Print external .mdebug symbols."}},
{print_headers, "headers", {"Print the contents of the .mdebug header."}},
{print_files, "files", {"Print a list of all the source files."}},
{print_includes, "includes", {"Print a list of the include paths stored with .mdebug inlining information."}},
{print_sections, "sections", {"List the names of the source files associated with each ELF section."}}};
"symbols, but not the procedure descriptors.",
"",
"--locals Print local .mdebug symbols.",
"",
"--procedures Print .mdebug procedure descriptors.",
"",
"--externals Print external .mdebug symbols.",
},
},
{
print_headers,
"headers",
{
"Print the contents of the .mdebug header.",
},
},
{
print_files,
"files",
{
"Print a list of all the source files.",
},
},
{
print_includes,
"includes",
{
"Print a list of the include paths stored with .mdebug inlining information.",
},
},
{
print_sections,
"sections",
{
"List the names of the source files associated with each ELF section.",
},
},
};

int main(int argc, char** argv)
{
Expand Down
Loading