Verified Commit e1ca8a16 authored by jD91mZM2's avatar jD91mZM2

FINALLY fix float registers, like, for real

I finally found a good example target-desc.xml that clearly describes
that the st* registers should be 80-bit long, and then I also happened
to find that byteorder already supports writing an integer n bytes long.
This is my lucky day!!!
parent d56a2a81
......@@ -72,11 +72,6 @@ dependencies = [
"termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "f80"
version = "0.1.0"
source = "git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286#d8de286afe27934c6ac002153e1610f100853ef9"
[[package]]
name = "gdb-remote-protocol"
version = "0.1.0"
......@@ -99,7 +94,6 @@ version = "0.1.0"
dependencies = [
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"f80 0.1.0 (git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286)",
"gdb-remote-protocol 0.1.0",
"libc 0.2.74 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -484,7 +478,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
"checksum f80 0.1.0 (git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286)" = "<none>"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
......
......@@ -13,7 +13,6 @@ env_logger = "0.7.1"
log = "0.4.8"
byteorder = "1.3.4"
num-traits = "0.2.12"
f80 = { git = "https://gitlab.redox-os.org/redox-os/f80.git", rev = "d8de286" }
libc = "0.2.71"
[[bin]]
......
use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
use f80::f80;
#[derive(Default)]
pub struct Registers {
......@@ -96,14 +95,14 @@ impl Registers {
fs: Some(input.read_u32::<NativeEndian>().unwrap()),
gs: Some(input.read_u32::<NativeEndian>().unwrap()),
st0: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st1: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st2: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st3: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st4: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st5: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st6: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st7: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st0: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st1: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st2: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st3: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st4: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st5: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st6: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
st7: Some(input.read_uint128::<NativeEndian>(10).unwrap()),
fctrl: Some(input.read_u32::<NativeEndian>().unwrap()),
fstat: Some(input.read_u32::<NativeEndian>().unwrap()),
ftag: Some(input.read_u32::<NativeEndian>().unwrap()),
......@@ -164,14 +163,14 @@ impl Registers {
output.write_u32::<NativeEndian>(self.fs.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.gs.unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st0.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st1.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st2.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st3.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st4.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st5.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st6.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st7.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_uint128::<NativeEndian>(self.st0.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st1.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st2.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st3.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st4.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st5.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st6.unwrap_or(0), 10).unwrap();
output.write_uint128::<NativeEndian>(self.st7.unwrap_or(0), 10).unwrap();
output.write_u32::<NativeEndian>(self.fctrl.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.fstat.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.ftag.unwrap_or(0)).unwrap();
......
<?xml version="1.0"?>
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<!-- See https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format -->
<!-- Also https://sourceware.org/gdb/onlinedocs/gdb/i386-Features.html#i386-Features -->
<!--
Wiki pages:
- https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format.
- https://sourceware.org/gdb/onlinedocs/gdb/i386-Features.html#i386-Features
Source examples:
- gdb/features/i386/64bit-core.xml (I searched for "org.gnu.gdb.i386.core" to find this)
-->
<target version="1.0">
<architecture>i386:x86-64</architecture>
<feature name="org.gnu.gdb.i386.core">
<reg name="rax" bitsize="64" group="general" />
<reg name="rbx" bitsize="64" group="general" />
<reg name="rcx" bitsize="64" group="general" />
<reg name="rdx" bitsize="64" group="general" />
<reg name="rsi" bitsize="64" group="general" />
<reg name="rdi" bitsize="64" group="general" />
<reg name="rbp" bitsize="64" group="general" />
<reg name="rsp" bitsize="64" group="general" />
<reg name="r8" bitsize="64" group="general" />
<reg name="r9" bitsize="64" group="general" />
<reg name="r10" bitsize="64" group="general" />
<reg name="r11" bitsize="64" group="general" />
<reg name="r12" bitsize="64" group="general" />
<reg name="r13" bitsize="64" group="general" />
<reg name="r14" bitsize="64" group="general" />
<reg name="r15" bitsize="64" group="general" />
<reg name="rip" bitsize="64" group="general" />
<reg name="rax" bitsize="64" group="general" />
<reg name="rbx" bitsize="64" group="general" />
<reg name="rcx" bitsize="64" group="general" />
<reg name="rdx" bitsize="64" group="general" />
<reg name="rsi" bitsize="64" group="general" />
<reg name="rdi" bitsize="64" group="general" />
<reg name="rbp" bitsize="64" group="general" />
<reg name="rsp" bitsize="64" group="general" />
<reg name="r8" bitsize="64" group="general" />
<reg name="r9" bitsize="64" group="general" />
<reg name="r10" bitsize="64" group="general" />
<reg name="r11" bitsize="64" group="general" />
<reg name="r12" bitsize="64" group="general" />
<reg name="r13" bitsize="64" group="general" />
<reg name="r14" bitsize="64" group="general" />
<reg name="r15" bitsize="64" group="general" />
<reg name="rip" bitsize="64" group="general" />
<reg name="eflags" bitsize="32" group="general" />
<reg name="cs" bitsize="32" group="general" />
<reg name="ss" bitsize="32" group="general" />
<reg name="ds" bitsize="32" group="general" />
<reg name="es" bitsize="32" group="general" />
<reg name="fs" bitsize="32" group="general" />
<reg name="gs" bitsize="32" group="general" />
<reg name="st0" bitsize="64" type="float" group="float" />
<reg name="st1" bitsize="64" type="float" group="float" />
<reg name="st2" bitsize="64" type="float" group="float" />
<reg name="st3" bitsize="64" type="float" group="float" />
<reg name="st4" bitsize="64" type="float" group="float" />
<reg name="st5" bitsize="64" type="float" group="float" />
<reg name="st6" bitsize="64" type="float" group="float" />
<reg name="st7" bitsize="64" type="float" group="float" />
<reg name="fctrl" bitsize="32" type="float" group="float" />
<reg name="fstat" bitsize="32" type="float" group="float" />
<reg name="ftag" bitsize="32" type="float" group="float" />
<reg name="fiseg" bitsize="32" type="float" group="float" />
<reg name="fioff" bitsize="32" type="float" group="float" />
<reg name="foseg" bitsize="32" type="float" group="float" />
<reg name="fooff" bitsize="32" type="float" group="float" />
<reg name="fop" bitsize="32" type="float" group="float" />
<reg name="cs" bitsize="32" group="general" />
<reg name="ss" bitsize="32" group="general" />
<reg name="ds" bitsize="32" group="general" />
<reg name="es" bitsize="32" group="general" />
<reg name="fs" bitsize="32" group="general" />
<reg name="gs" bitsize="32" group="general" />
<reg name="st0" bitsize="80" type="i387_ext" group="float" />
<reg name="st1" bitsize="80" type="i387_ext" group="float" />
<reg name="st2" bitsize="80" type="i387_ext" group="float" />
<reg name="st3" bitsize="80" type="i387_ext" group="float" />
<reg name="st4" bitsize="80" type="i387_ext" group="float" />
<reg name="st5" bitsize="80" type="i387_ext" group="float" />
<reg name="st6" bitsize="80" type="i387_ext" group="float" />
<reg name="st7" bitsize="80" type="i387_ext" group="float" />
<reg name="fctrl" bitsize="32" type="float" group="float" />
<reg name="fstat" bitsize="32" type="float" group="float" />
<reg name="ftag" bitsize="32" type="float" group="float" />
<reg name="fiseg" bitsize="32" type="float" group="float" />
<reg name="fioff" bitsize="32" type="float" group="float" />
<reg name="foseg" bitsize="32" type="float" group="float" />
<reg name="fooff" bitsize="32" type="float" group="float" />
<reg name="fop" bitsize="32" type="float" group="float" />
</feature>
<feature name="org.gnu.gdb.i386.sse">
<reg name="xmm0" bitsize="128" type="float" group="float" />
<reg name="xmm1" bitsize="128" type="float" group="float" />
<reg name="xmm2" bitsize="128" type="float" group="float" />
<reg name="xmm3" bitsize="128" type="float" group="float" />
<reg name="xmm4" bitsize="128" type="float" group="float" />
<reg name="xmm5" bitsize="128" type="float" group="float" />
<reg name="xmm6" bitsize="128" type="float" group="float" />
<reg name="xmm7" bitsize="128" type="float" group="float" />
<reg name="xmm8" bitsize="128" type="float" group="float" />
<reg name="xmm9" bitsize="128" type="float" group="float" />
<reg name="xmm0" bitsize="128" type="float" group="float" />
<reg name="xmm1" bitsize="128" type="float" group="float" />
<reg name="xmm2" bitsize="128" type="float" group="float" />
<reg name="xmm3" bitsize="128" type="float" group="float" />
<reg name="xmm4" bitsize="128" type="float" group="float" />
<reg name="xmm5" bitsize="128" type="float" group="float" />
<reg name="xmm6" bitsize="128" type="float" group="float" />
<reg name="xmm7" bitsize="128" type="float" group="float" />
<reg name="xmm8" bitsize="128" type="float" group="float" />
<reg name="xmm9" bitsize="128" type="float" group="float" />
<reg name="xmm10" bitsize="128" type="float" group="float" />
<reg name="xmm11" bitsize="128" type="float" group="float" />
<reg name="xmm12" bitsize="128" type="float" group="float" />
<reg name="xmm13" bitsize="128" type="float" group="float" />
<reg name="xmm14" bitsize="128" type="float" group="float" />
<reg name="xmm15" bitsize="128" type="float" group="float" />
<reg name="mxcsr" bitsize="32" type="float" group="float" />
<reg name="mxcsr" bitsize="32" type="float" group="float" />
</feature>
<feature name="org.gnu.gdb.i386.segments">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment