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

Add x86_64 support #11

Merged
merged 5 commits into from
Aug 21, 2020
Merged

Add x86_64 support #11

merged 5 commits into from
Aug 21, 2020

Conversation

jamcleod
Copy link
Contributor

One potential concern is the naming, which I'm fine with changing. Currently I have:

module: x86
Arch struct: X86_64
Registers struct: Amd64CoreRegs

@daniel5151 daniel5151 self-requested a review August 18, 2020 21:37
Copy link
Owner

@daniel5151 daniel5151 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I appreciate it!

I mention in one of the inline comments that you've mixed in some SSE extensions in with the core registers. My guess would be that just setting i386:x86-64 in the target description XML doesn't give GDB enough info about the system, and will simply assume that the system includes SSE registers as well. This is just a guess though, and I could be wrong...

For correctness, you may want to adjust the target description XML to include a <feature name="org.gnu.gdb.i386.sse"> tag (see the Target Description Format docs and i386 features).

Truth be told, I haven't put too much thought into the best way to support these sorts of fine-grained architecture-specific feature toggles in gdbstub. It would probably require a rework of the Arch trait itself... That's not really something that can be addressed in this PR though, so I'll just open an issue up for it and possibly look into it at some point down the line.


As for naming, I'm hoping to keep things somewhat consistent with the gdb source tree, namely, the definitions present under gdb/features (https://github.com/bminor/binutils-gdb/tree/master/gdb/features). It seems like the relevant file for x86-64 would be https://github.com/bminor/binutils-gdb/blob/master/gdb/features/i386/64bit-core.xml.

That said, using i386 everywhere would be quite ugly, so i'm cool with using x86 instead, for clarity's sake.

And while Amd64CoreRegs definitely looks nicer than X86_64CoreRegs, I think it'd be best to use the latter name, for consistency's sake. Similarly, amd64_core.rs aught to be renamed to x86_64_core.rs (or even just core64.rs, since it's a submodule of x86).

src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/amd64_core.rs Outdated Show resolved Hide resolved
@jamcleod jamcleod requested a review from daniel5151 August 20, 2020 05:48
@jamcleod
Copy link
Contributor Author

Also thanks for the quick and thorough review!

Copy link
Owner

@daniel5151 daniel5151 left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all the comments!

I had a few more nits and notes, but I think this this is very close to getting merged!

src/arch/x86/reg/core64.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/core64.rs Show resolved Hide resolved
src/arch/x86/reg/core64.rs Show resolved Hide resolved
@daniel5151
Copy link
Owner

p.s: not sure how helpful this might be, but it might be worth checking out how other gdbstub implementation (written in C) have added x86 support. Notably, the official gdbserver's source might reveal some answers.

https://github.com/facebookarchive/binutils/tree/master/gdb/gdbserver

@jamcleod jamcleod requested a review from daniel5151 August 20, 2020 19:40
Copy link
Owner

@daniel5151 daniel5151 left a comment

Choose a reason for hiding this comment

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

Awesome work! I've just jotted down 2 final nits, but other than that, it LGTM.

Thanks again!

src/arch/x86/reg/core64.rs Outdated Show resolved Hide resolved
src/arch/x86/reg/core64.rs Show resolved Hide resolved
@jamcleod jamcleod requested a review from daniel5151 August 21, 2020 17:46
@daniel5151 daniel5151 merged commit 31abecc into daniel5151:master Aug 21, 2020
@daniel5151
Copy link
Owner

When I get the chance, I'll bump the version and push to crates.io (sometime today / tomorrow).

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

Successfully merging this pull request may close these issues.

2 participants