gen_settings: dont try to display a Preset descriptor in Flags (#241)

* gen_settings: dont try to display a Preset descriptor in Flags

Trying to display a preset doesnt make sense, and before this commit it
does not display anything meaningful - the printout just says e.g.
"haswell =\n".

The offset byte a preset descriptor isnt a valid offset into the
flag bytes, it is actually an offset into the PRESETS table. It will
cause a panic when the offset is out of bounds for the flag bytes,
which happens in the intel isa as of this commit.

* intel settings: test that display impl doesnt panic
This commit is contained in:
Pat Hickey
2018-02-14 11:51:40 -08:00
committed by Jakob Stoklund Olesen
parent 42e1616b82
commit ed24320eda
3 changed files with 36 additions and 5 deletions

View File

@@ -218,11 +218,12 @@ def gen_display(sgrp, fmt):
'}'):
fmt.line('writeln!(f, "[{}]")?;'.format(sgrp.name))
with fmt.indented('for d in &DESCRIPTORS {', '}'):
fmt.line('write!(f, "{} = ", d.name)?;')
fmt.line(
'TEMPLATE.format_toml_value(d.detail,' +
'self.bytes[d.offset as usize], f)?;')
fmt.line('writeln!(f, "")?;')
with fmt.indented('if !d.detail.is_preset() {', '}'):
fmt.line('write!(f, "{} = ", d.name)?;')
fmt.line(
'TEMPLATE.format_toml_value(d.detail,' +
'self.bytes[d.offset as usize], f)?;')
fmt.line('writeln!(f, "")?;')
fmt.line('Ok(())')