-
Notifications
You must be signed in to change notification settings - Fork 1
Stubbing debugger functionality #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dadcf59
feat: init stub.py
interfiberschool da26145
feat(stub): pretty.h generation + v5dbg.mk config file
Interfiber b334a38
feat(stub): fix stub generator output + impl v5dbg.mk config
interfiberschool 5944c97
doc: v5dbg.mk
interfiberschool d5d1f18
feat+fix(stub+v5dbg): don't start server when disabled + fix linker e…
interfiberschool 204b2a6
fix: spelling in server.cpp disabled message
interfiberschool 97a5bb3
rm: config.h, replaced with v5dbg.mk
interfiberschool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #pragma once | ||
| /// Stubbed version of normal $function, automatically generated | ||
| #define $function | ||
| /// Stubbed version of normal $expose, automatically generated | ||
| #define $expose(target) | ||
| /// Stubbed version of normal $break, automatically generated | ||
| #define $break | ||
| /// Stubbed version of normal $cbreak, automatically generated | ||
| #define $cbreak(value) | ||
| /// Stubbed version of normal $ntask, automatically generated | ||
| #define $ntask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #pragma once | ||
| /// Stubbed version of normal $pretty_printer, automatically generated | ||
| #define $pretty_printer(func,type) | ||
| /// Stubbed version of normal $pretty_printer_allocator, automatically generated | ||
| #define $pretty_printer_allocator(func,type) | ||
| /// Stubbed version of normal $link_type_db, automatically generated | ||
| #define $link_type_db(cpptype,etype) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import io | ||
|
|
||
| """ | ||
| stub.py generates stub versions of macros so you can easily disable the debugger with V5DBG_DISABLE | ||
| """ | ||
|
|
||
| def gen_macro(params: list[str]) -> str: | ||
| macro_name = params[0].strip() | ||
| macro_params = params[1:len(params)] # Collect rest of the macro params | ||
|
|
||
| print(f"> stub macro: {macro_name}") | ||
| print(f"> stub macro arguments: {macro_params}") | ||
|
|
||
| result = f"\n/// Stubbed version of normal {macro_name}, automatically generated\n#define {macro_name}({','.join(macro_params).strip()})" | ||
| result = result.replace("()", "") # Replace empty parenthesis with nothing as they cause compiler errors | ||
|
|
||
| return result | ||
|
|
||
| def gen_stub(stub_str: str) -> str: | ||
| result = "" | ||
|
|
||
| stub_str = stub_str.replace("// stub:", "") | ||
|
|
||
| if stub_str.startswith("macro="): | ||
| stub_str = stub_str.replace("macro=", "") | ||
| result = gen_macro(stub_str.split(",")) | ||
| else: | ||
| print("gen_stub found invalid expression") | ||
|
|
||
| return result | ||
|
|
||
| def scan_file(file: io.FileIO): | ||
| # Load all lines from this file | ||
| lines = file.readlines() | ||
|
|
||
| file_contents_new = "#pragma once" | ||
|
|
||
| for line in lines: | ||
| if line.startswith("// stub:"): | ||
| # Handle macro stubbing | ||
|
|
||
| file_contents_new += gen_stub(line) | ||
|
|
||
| # File must have an extension | ||
| file_split = file.name.split(".") | ||
| ext = file_split[1] | ||
|
|
||
| new_file = file_split[0] + ".stub." + ext | ||
|
|
||
| print(f"> stub write to: {new_file}") | ||
|
|
||
| new_file_io = open(new_file, "w") | ||
| new_file_io.write(file_contents_new) | ||
| new_file_io.close() | ||
|
|
||
| stubbed_files = ["debug.h", "pretty.h"] | ||
|
|
||
| for file in stubbed_files: | ||
| scan_file(open(f"include/v5dbg/{file}", "r")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # V5dbg build configuration | ||
|
|
||
| # About: When 'true' debugger functionality is enabled, when 'false' its disabled | ||
| # Cont: Enables the including of .stub.h files to replace debugger functionality | ||
| # Note: Enable this for a final competition build! | ||
| ENABLE_DEBUGGER := true | ||
|
|
||
| ######## Apply configuration, DO NOT MODIFY ######## | ||
|
|
||
| EXTRA_CXXFLAGS += $(if $(filter $(ENABLE_DEBUGGER),true),,-DV5DBG_DISABLE) | ||
|
|
||
| stub: | ||
| @echo "Calling stub compiler..." | ||
| @python3 stub.py |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.