Giter Club home page Giter Club logo

ddbug_c_to_json's Introduction

DDbug C to JSON

This project exists to take ddbug output text files (based on C projects) and convert them to JSON so that you can create your own custom programs based on the generated JSON & DWARF file data.

With the ddbug parser output files serialized to Rust Structs, which then uses serde to serialize the data to machine parsable JSON format.

This project is also being used as a way for me to learn the Rust language string features, so the code will probably be sloppy, inefficient and not cleanest. So keep in mind that this project is a 50% learning exercise for myself.

Notes

** IMPORTANT** Thios tool was developed using C based embedded project. It will not work with C++ or Rust based elf files.

IMPORTANT, this tool only works with -p all option. The -p all option makes ddbug output all the extra fields that it can parse.

Also note that "unit" field needs to be present because each function, base type, variable, enum belongs to a translation unit. Without the "unit" field, its much harder to associate functions, types, structures, enums, variables, etc to a specific unit.

The original ddbug tool simply dumps all this info in order for each translation unit which creates a ton duplicates. Therefore, I intentionally structured everything in a hierarchial manner so that each of the functions, variables, types, etc belong to specific translation unit.

How to use

First, go grab ddbug from the repo and install it. Once installed, run the following command to generate a "output_dump.txt" file.

ddbug -p all YOUR_BINARY_ELF.elf > output_dump.txt

IMPORTANT, this tool only works with -p all option. The -p all option makes ddbug output all the extra fields that it can parse.

DDbug C to JSON 0.1
Yoofie <[email protected]>
This project exists to take ddbug output text files and convert them to Rust structures so that you can create your own custom programs based on DWARF file data.

With the `ddbug` parser output files serialized to Rust Structs, you can also use serde to serialize the data to machine parsable JSON format.

USAGE:
    ddbugC_tojson [OPTIONS] --input <INPUT_FILE>

OPTIONS:
    -d, --rdbg                         Prints out the internal Rust structures
    -h, --help                         Print help information
    -i, --input <INPUT_FILE>           The input file into this tool. This file should have been
                                       generated from the ddbug tool
    -o, --output [<OUTPUT_FILE>...]    The name of the generated output file.  [default: output.json]
    -V, --version                      Print version information

Example usage

Example #1 - Just plain JSON output that will create output.json in the same directory where this exe is run from:

ddbugC_tojson -i input_file.txt

Example #2 - Plain JSON ouput like in example #1 except with a custom file name

ddbugC_tojson -i input_file.txt -o output_file.json

Example #3 - Display Rust struct debug output:

ddbugC_tojson -d -i input_file.txt -o output_file.json

Todo list

  • Functions not fully supported (parameters, etc are missing)
  • arrays/union memebers not yet supported
    • Currently supported but the datastructure is flattened and not nested
  • Each translation unit currently uses vectors that can be empty. Convert these to Options
  • padding fields curently return a error. Make it so that they are left blank instead
  • Integrate CLI interface

Wishlist maybe?

  • Make tool more flexible so that -p all option is not necessary. If this becomes a goal, then I need to figure out a way to associate each function, type, enum, etc to belong to a translation unit when the unit data is not available.

ddbug_c_to_json's People

Contributors

yoofie avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.