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

Fix parsing of GDB <reg> tags not separated by whitespace #4273

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

raphaelr
Copy link

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

regstr_end + 3 would advance into the next <reg> tag if there is no whitespace between the two tags. This would cause the latter register to be ignored by the parser. Such an XML is for example used by mGBA's GDB stub.

Test plan

In one terminal:

$ gdbserver localhost:2345 ls

In another terminal:

$ rizin -c dr -D gdb gdb://localhost:2345

Verify that the register list is complete for your architecture.

For testing with mGBA, which generates the problematic XML:

  1. Run the emulator and load any rom (free homebrew roms are available)
  2. Click Tools -> Start GDB server
  3. Click Start
  4. Run rizin -c dr -D gdb gdb://localhost:2345
  5. Verify that the register list is complete: r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, sp, lr, pc, cpsr (currently in the dev branch, the odd-numbered registers are omitted)

`regstr_end + 3` would advance into the next `<reg>` tag if there is no
whitespace between the two tags.
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

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

@wargio @thestr4ng3r take a look too please before merging.

@wargio
Copy link
Member

wargio commented Feb 21, 2024

this patch feels wrong. probably we should use one of the rz_str_* methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants