Skip to content
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

New crash screen #725

Draft
wants to merge 615 commits into
base: develop/3.0.0
Choose a base branch
from
Draft

Conversation

Arceveti
Copy link
Collaborator

@Arceveti Arceveti commented Oct 6, 2023

Moved from #466.

(description currently WIP)

sm64-231015-190402

The crash screen has been entirely rewritten.

  • New pages and features
  • Visual improvements
  • Stability improvements
  • Many bugfixes
  • New assert functionality
  • UNF compatibility (Z+START to print the current page's data)

Pages:

Context page

sm64-231015-190402
sm64-231015-190422

  • Displays:
    • Crash cause.
    • Crashed Thread ID and name.
    • Current function name.
    • FPCSR and FPCSR description.
    • All registers in __OSThreadContext.
  • In settings, a mode can be enabled where registers that are storing a valid mapped address can print the name of that address's destination.
  • Press B to toggle float register format.

Logs/Assert page

sm64-231006-135015

  • Scrollable Puppyprint log.
  • The current assert if it exists (see "New asserts" section for new functionality).

Stack trace page

sm64-231006-134024

  • Now properly traverses the stack buffer.
  • Prints offsets too.
  • Scrollable.
  • Press B to toggle between parsed names + offsets or addresses only

Map view page

sm64-231006-134145

  • Scrollable.
  • Lists all map data in a scrollable list.
  • Includes:
    • Symbol address
    • Symbol name
    • Symbol type
    • Symbol size (when possible. See mapPacker.py)
  • See "Map Parser" section.

RAM view page

sm64-231006-134437
sm64-231006-134533

  • Scrollable.
  • Directly prints a section of RAM.
  • Press B to toggle between hex values and ASCII values for each byte.

Disassembly page

sm64-231006-135350

  • Scrollable.
  • Interprets a section of RAM as assembly, and prints the formatted results.
  • Branch Arrows (configurable method):
    • FUNCTION:
      • Default when INCLUDE_DEBUG_MAP is defined.
      • Puts all the branch data for the current function into a buffer, and displays them all, so arrow positions stay consistent when the selection cursor is within a function.
    • SELECTION:
      • Default when INCLUDE_DEBUG_MAP is not defined.
      • Only displays the branch arrow for the current selected branch instruction.
    • OVERSCAN:
      • Displays arrows relative to the viewport.
      • Arrows will move around while scrolling the viewport.
      • Not yet implemented.

Settings page

sm64-231006-134614
sm64-231006-134633

  • Settings for all pages.
  • Scrollable.
  • Press A+B on a setting to reset it to default, or on a collapsible header to reset that section to default.

Other:

Header

  • Reads version number directly from VERSION.txt

Manual address select box

sm64-231006-153747

  • On pages where the selection box is on an address, press A to open a box that allows you to choose a specific address to jump to.
  • Green for valid/mapped addresses and red for invalid/unmapped addresses.

Controls

sm64-231006-153819

  • Press START on any page to open a popup which lists the controls for that page.

Safe memory reads

  • See src/crash_screen/memory_read.c

Map parser

  • See src/crash_screen/map_parser.c and tools/mapPacker.py
  • Uses nm --print-size --numeric-sort instead of just reading from the sm64_prelim.map file. This change allows reading static functions, externs, and also symbol types and sizes.

UNF compatibility

  • Crash screen and UNF can now be built at the same time
  • Debug info is sent to UNF on crash (see debug_printcontext() in src/usb/debug.c

New drawing system

  • General
    • Translucency support
    • Scissor box
    • Rectangle, diamond, triangle, line (unused), and glyph functions
  • Text
    • cs_print()
    • Text wrapping
    • Support for common formatting characters ('\t', '\n', '\r')
    • Color text
      • '@' plus 8 char string of the color hex code. For example, "@FF0000FFred text" will print "red text" in red.
    • A maximum width limit can be specified via cs_print_scroll(). If the final formatted string length exceeds the width, it will scroll the text instead
      • Scroll speed can be changed on the settings page

Saved screenshot

  • On crash, the last frame of the game is saved as a screenshot (repurposing the Z buffer space). This is drawn at the beginning of every frame so that the crash screen no longer overlaps its previous frames.
  • This can be turned off in settings.
  • Hold Z to hide the crash screen and show only the saved screenshot.
  • All anti-aliasing is removed from the screenshot due to how coverage interacts with the crash screen's background's translucency.

Support for crash screen crashes

  • When the game initially crashes, a new thread is created to watch the crash screen itself for crashes. When the first crash screen crashes, the page it was on will be disabled, and the second thread will become the new crash screen thread with information on the first crash screen thread. This can go on indefinitely and uses threads 1000-1002.

New asserts

  • See src/game/assert.h
  • Asserts now print a string of the condition.
  • ERROR(message) Will always assert with 'message' without a condition.
  • ASSERT(condition, message) Will assert with 'message' if 'condition' is false.
  • Add DEBUG_ prefix to the beginning of either of the above to have it only run if ENABLE_DEBUG_ASSERTS is defined (eg. (DEBUG_ASSERT()).
  • Add F suffix to the end of either of the above to allow formatting in 'message' like printf (eg. ASSERTF()).

(moved TODO to src/crash_screen/README.md)

@Arceveti Arceveti requested a review from gheskett as a code owner October 6, 2023 21:51
@Arceveti Arceveti changed the title Develop/2.1.0 new crash screen New crash screen Oct 6, 2023
@Arceveti Arceveti added enhancement New feature or request do not merge Do not merge (yet) critical Extremely important issue or feature / highest priority labels Oct 6, 2023
@Arceveti Arceveti added this to the 2.2 milestone Oct 6, 2023
@Arceveti Arceveti linked an issue Oct 6, 2023 that may be closed by this pull request
@someone2639 someone2639 self-assigned this Nov 21, 2023
@gheskett gheskett added high priority Important, non-critical issue or feature / high priority and removed critical Extremely important issue or feature / highest priority labels Dec 10, 2023
Copy link
Collaborator

@someone2639 someone2639 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments for requested changes (3 are changes, the rest are notes), also here's the todo list but annotated for things i think fit the scope of this PR and things that should be saved for later

Annotated with 4 categories:

  • Add: I'll approve when these are done
  • Defer: Good features, but save them for another PR
  • Wait: Save until problematic
  • Out of Scope: self-explanatory

General

  • A "print current page to UNF" button. (hold START or Z?). (Add)

  • Verify whether FORCE_CRASH_AT_ADDR works or is needed. (Add)

  • Fix lowercase debug_assert conflict with UNF debug_assert. (Add)

  • Fix the flickering on Ares if possible. (Add)

  • Fix data in extended RAM not being read correctly. (Add)

  • Verify whether osWritebackDCacheAll() usage is correct. (Add)

  • Don't have all crash screen code always loaded (keep in its own segment then DMA it on crash?). (Defer)

  • Ifdef the entire crash screen. (Defer)

  • Simplified crash screen (for HLE? or if DMA fails?). (Defer)

  • Finish and clean up macros.h stuff. (Defer, some of these might not be possible to trigger)

  • Combine sRegNames from pages/context.c and sRegisterNames from insn_disasm.c if possible. (Defer)

  • Clean up INCLUDE_DEBUG_MAP ifdefs as much as possible. (Defer)

  • Page selection grid popup. (Defer)

  • Individual page settings in each page's controls/help popup box. (Defer)

  • Ability to undo address select and disasm jumps? (Defer)

  • Horizontal text scrolling should actually scroll by pixels rather than scrolling the char buffer. (Defer)

  • Make controls list scrollable if too long. (Wait)

  • A page to interpret memory as an image? For texture viewing? How would wrap width work? (Wait)

  • Physical vs. Virtual address setting? (Wait)

  • "Home" page with crash screen instructions. (Wait)

  • Controls rebinding page (necessary?) (Wait)

  • Should assert macros be uppercase or lowercase? (Wait) (also lowercase imo)

  • Low vs. High resolution setting. (Out of Scope)

Context page

  • Is R0 needed? It's always 0. (Already done)

  • T8 and T9 registers. (Already Done)

  • Jump to selected register address, or value (if the value is a valid address). (Already Done)

  • Show offsets in parse register address names mode. (Defer)

  • Extended version with a scrollable list of all registers and their full 64 bit contents (Everything from here plus any other CPU/RCP registers). (Wait)

  • Select individual registers (Wait)

  • Selected register descriptions. (Wait)

  • Setting for interpreting integer registers as decimal? (Wait)

  • Different colors for register names from parsed global variable names (disasm page too). (Wait)

  • Multiple FPCSR descriptions at once. (Wait)

Log/Assert page

  • Timestamps? (Wait)

Stack trace page

  • Libdragon stack trace functionality. (Defer)

Map view page

  • Is search functionality possible/reasonable? (Wait)

  • Should moving the cursor location here also change the location in ram view and disasm? (Out of Scope) (Also no)

RAM view page

  • Read 4 bytes as address for address select popup (requires multi-select?). (Defer)

  • Is search functionality possible/reasonable? (Wait)

  • Binary view mode. (Wait)

  • Write the viewed area to a buffer on each scroll to avoid constant data reads each frame. (Wait)

Disasm page

  • Show addresses for each row (setting). (Defer)

  • Can the insn_as_string and insn_name buffers be combined? (Defer)

  • Multi-line pseudoinstructions if possible (ABS, BLT, BGT, BLE, NEG, NEGU, NOT, BGE, LI, LA, SGE, SGE, ADD?). (Wait)

  • Is it possible to include function names inline at the beginning of each function without compromising scrolling? (Wait)

  • Implement "OVERSCAN" mode for branch arrows. (Wait)

Settings page

  • Save all changed settings somehow? (Wait)
  • Confirmation dialog box to reset all to defaults. (Wait)
  • Jump to the page from a page group. (Unnecessary if settings become part of their respective pages)

};

static const char* sCauseDesc[18] = {
/*EXC_INT */ "Interrupt",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array can use designated initializers too using [EXC >> 2] = ...,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't work for the last two entries because the index would skip from 15 to 23 then 31 (see R4300.h line 211-228).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having it skip would introduce a bit of padding space but it also eliminates the correction in line 103 in this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a net increase of 0x138 bytes for a negligible optimization, and code size matters more than performance here.

return numChars;
}

static void cs_scroll_buffer(size_t bufferCount, size_t charLimit) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only complaint here is that this gets hard to read on the cause screen (maybe a pause here?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can slow down the text scroll speed on the settings page. Should holding B pause scrolling text in its place?

src/crash_screen/pages/page_settings.c Show resolved Hide resolved
}
escaped = TRUE;
break;
case CHAR_COLOR: // @RRGGBBAA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this specific color syntax will be obsoleted by the ascii pr

#define SET_CRASH_ADDR(ptr) \
do { \
extern uintptr_t gSetCrashAddress; \
gSetCrashAddress = (uintptr_t)&(ptr); \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Will not work on arbitrary numbers as pointers

src/crash_screen/crash_main.c Outdated Show resolved Hide resolved
@gheskett gheskett modified the milestones: 2.2, 3.0 Dec 16, 2023
@gheskett gheskett added the monkaS monkaS label Dec 31, 2023
@Arceveti Arceveti requested a review from someone2639 February 25, 2024 08:32
@Arceveti Arceveti removed the do not merge Do not merge (yet) label Feb 25, 2024
@gheskett gheskett deleted the branch develop/3.0.0 July 4, 2024 07:18
@gheskett gheskett closed this Jul 4, 2024
@gheskett gheskett reopened this Jul 4, 2024
@gheskett gheskett changed the base branch from develop/2.3.0 to develop/2.4.0 July 4, 2024 07:26
@gheskett gheskett changed the base branch from develop/2.4.0 to develop/3.0.0 July 4, 2024 07:26
@gheskett
Copy link
Collaborator

gheskett commented Jul 4, 2024

Repointing to 3.0 (this is way too dramatic to fit in a minor release)

@gheskett
Copy link
Collaborator

gheskett commented Jul 4, 2024

WARNING: Please do not update this branch with non-3.0 changes! This will only serve to prevent this PR from ever being in a mergeable state until the next minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority Important, non-critical issue or feature / high priority monkaS monkaS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash Screen Overhaul
5 participants