Giter Club home page Giter Club logo

cpp_box's Introduction

lefticus - Jason Turner

I am regular conference speaker, trainer, and C++ contractor.

I am available for code reviews and on-site training.

cpp_box's People

Contributors

klemens-morgenstern avatar lefticus avatar mattgodbolt avatar paulls20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpp_box's Issues

Create more lessons / goals

Currently two sample goals exist, this issue should be used to track a specific set of lessons that we might want to implement.

Make it possible to script lessons

We'll prefer ChaiScript (for obvious reasons) for the scripting technology.

The current interface to the lessons / goals can be found here:

cpp_box/src/cpp_box.cpp

Lines 580 to 608 in 2da3c85

struct Goal
{
std::string name;
std::string description;
std::vector<std::string> hints;
std::function<bool(const Status &)> completion_state;
std::size_t hints_shown{ 0 };
bool completed{ false };
};
static std::vector<Goal> generate_goals()
{
return { { "Compile a Program",
"Make a simple program with a `main` function that compiles\nand produces a binary and returns 0",
{ "a simple `main` in C++ has this signature: `int main();`",
"0 is returned by default",
"Your program should look something like: `int main() {}`" },
[](const Status &s) -> bool { return s.sys->registers[0] == 0; },
0,
false },
{ "Return 5 From Main",
"Make a simple program with a `main` function that compiles\nand produces a binary and returns 5",
{ "To make a function return a value, you use the `return` keyword",
"0 is returned by default",
"Your program should look something like: `int main() { return 5; }`" },
[](const Status &s) -> bool { return s.sys->registers[0] == 5; },
0,
false } };
}

Attempt making opcodes decode up front

Currently each part of the opcode is decoded on demand, we should try doing this upfront when the opcode type is constructed to see if the reduced work done during actual processing of the instruction helps performance.

if it does we can build a better/smarter CPU cache.

Relies on #26

Compilation causes ICE on gcc 8.1.0

internal compiler error: in force_type_die, at dwarf2out.c:25955
         for (int i = 0; i < status.opsPerFrame && status.sys->operations_remaining(); ++i) { status.sys->next_operation(); }

g++ version:
g++ (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0

Show compiler output

User needs to have compiler output (warnings and errors) parsed and shown in the IDE.

Minor: Displaying `%s` instead of Hint headers.

Minor: Displaying %s instead of Hint headers.
From the cpp_box.cpp: 641

if (ImGui::CollapsingHeader("%s", fmt::format("Show Hint #{}", clue).c_str())) { text(true, "{}", goal.hints[clue]); }

Increase test coverage of data processing instructions

You can see here in codecov that the unit tests are only covering about 1/2 of the possible Data Processing instructions that the ARM supports.

https://codecov.io/gh/lefticus/cpp_box/src/master/include/cpp_box/arm.hpp#L725...742

You can see details about the instruction format and architecture supported in the README

The instructions to test can be generated by hand or with an ARM assembler or compiler (using objdump on an ARM object file can be quite revealing)

$ clang++ --target=armv4-linux -stdlib=libc++ -O3 some_file.cpp -o some_file.o
$ llvm-objdump --disassemble some_file.o

Tests are located here: https://github.com/lefticus/cpp_box/blob/master/test/constexpr_tests.cpp

There are a couple of important things to notice:

  • We are using a macro so that the tests can be built in either constexpr or not. This is important for debugging. A constexpr build will simply fail to build if there is a problem, and this makes debugging the issue very difficult.
  • The relaxed_constexpr_tests binary is built specifically for this reason, so we can test all aspects of the CPU as either constexpr or not
  • Follow the patterns shown for how to enable a specific test for both constexpr and non-constexpr
  • Do not limit yourself to just the catch2 directives I'm using - be as explicit and verbose with the test descriptions as you would like. (see also, for example https://github.com/catchorg/Catch2/blob/master/docs/test-cases-and-sections.md#top)
  • Try to make the tests small, so it's possible to debug them more easily
  • Consider what register values you need to set up. Consider adding a new overload to run that takes a set of pre-set register values if desired.
  • Look at CMP test for a basic design https://github.com/lefticus/cpp_box/blob/master/test/constexpr_tests.cpp#L94-L101

Once you have made the PR we should be able to see the change in test coverage in the PR report on github.

Feel free to make multiple PRs as well, for different instruction tests.

Utilize better type safety for function parameters

Currently there are some functions that take a list of strings or paths and it's possible to swap up the order of parameters. Look for these cases and better utilize strongly typed wrappers to make mixing up params impossible.

Properly handle unhandled opcodes

They should result in a call to the unhandled opcode vector

Which should by default log / emit / somehow log that what the unhandled opcode was so it can be tracked and later implemented if it's a valid correct opcode.

No filesystem header on OSX

Apple LLVM version 10.0.1 does not come with filesystem library header, resulting in an error on compilation. experimental/filesystem is also cannot be found.

Any workarounds?

add assembly editor

Currently it's not possible to write assembly code directly. While it's possible to utilize inline assembly, it's just not very nice. I know this project is called cpp_box but an "Assembly" switch would be nice anyway. Especially if you plan any more videos like this one.

I will try to implement this myself because it seems relatively trivial, Clang can do all the heavy lifting for me. This is my working branch in a local fork: asynts/cpp_box.

Speed up compilation of main.cpp

Currently main.cpp takes too long to compile.

Options include:

  • breaking out arm.hpp so we don't compile the emulator each time
  • breaking out fmt:: calls, they are heavy at compile time
  • Upgrading {fmt}, newer versions should compile faster.

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.