mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
proc: fix prettyprint for register components with large values (#3022)
Fix pretty printing for CPU register components (created with the XMM0.uintN syntax) while using format strings Also fixes printing large literal constants with format strings. Fixes #3020
This commit is contained in:
committed by
GitHub
parent
d05e88cca2
commit
ac81269eef
@ -740,11 +740,16 @@ func resolveTypedef(typ godwarf.Type) godwarf.Type {
|
||||
}
|
||||
}
|
||||
|
||||
var constantMaxInt64 = constant.MakeInt64(1<<63 - 1)
|
||||
|
||||
func newConstant(val constant.Value, mem MemoryReadWriter) *Variable {
|
||||
v := &Variable{Value: val, mem: mem, loaded: true}
|
||||
switch val.Kind() {
|
||||
case constant.Int:
|
||||
v.Kind = reflect.Int
|
||||
if constant.Sign(val) >= 0 && constant.Compare(val, token.GTR, constantMaxInt64) {
|
||||
v.Kind = reflect.Uint64
|
||||
}
|
||||
case constant.Float:
|
||||
v.Kind = reflect.Float64
|
||||
case constant.Bool:
|
||||
@ -2278,37 +2283,47 @@ func (v *Variable) registerVariableTypeConv(newtyp string) (*Variable, error) {
|
||||
switch newtyp {
|
||||
case "int8":
|
||||
child = newConstant(constant.MakeInt64(int64(int8(v.reg.Bytes[i]))), v.mem)
|
||||
child.Kind = reflect.Int8
|
||||
n = 1
|
||||
case "int16":
|
||||
child = newConstant(constant.MakeInt64(int64(int16(binary.LittleEndian.Uint16(v.reg.Bytes[i:])))), v.mem)
|
||||
child.Kind = reflect.Int16
|
||||
n = 2
|
||||
case "int32":
|
||||
child = newConstant(constant.MakeInt64(int64(int32(binary.LittleEndian.Uint32(v.reg.Bytes[i:])))), v.mem)
|
||||
child.Kind = reflect.Int32
|
||||
n = 4
|
||||
case "int64":
|
||||
child = newConstant(constant.MakeInt64(int64(binary.LittleEndian.Uint64(v.reg.Bytes[i:]))), v.mem)
|
||||
child.Kind = reflect.Int64
|
||||
n = 8
|
||||
case "uint8":
|
||||
child = newConstant(constant.MakeUint64(uint64(v.reg.Bytes[i])), v.mem)
|
||||
child.Kind = reflect.Uint8
|
||||
n = 1
|
||||
case "uint16":
|
||||
child = newConstant(constant.MakeUint64(uint64(binary.LittleEndian.Uint16(v.reg.Bytes[i:]))), v.mem)
|
||||
child.Kind = reflect.Uint16
|
||||
n = 2
|
||||
case "uint32":
|
||||
child = newConstant(constant.MakeUint64(uint64(binary.LittleEndian.Uint32(v.reg.Bytes[i:]))), v.mem)
|
||||
child.Kind = reflect.Uint32
|
||||
n = 4
|
||||
case "uint64":
|
||||
child = newConstant(constant.MakeUint64(uint64(binary.LittleEndian.Uint64(v.reg.Bytes[i:]))), v.mem)
|
||||
child.Kind = reflect.Uint64
|
||||
n = 8
|
||||
case "float32":
|
||||
a := binary.LittleEndian.Uint32(v.reg.Bytes[i:])
|
||||
x := *(*float32)(unsafe.Pointer(&a))
|
||||
child = newConstant(constant.MakeFloat64(float64(x)), v.mem)
|
||||
child.Kind = reflect.Float32
|
||||
n = 4
|
||||
case "float64":
|
||||
a := binary.LittleEndian.Uint64(v.reg.Bytes[i:])
|
||||
x := *(*float64)(unsafe.Pointer(&a))
|
||||
child = newConstant(constant.MakeFloat64(x), v.mem)
|
||||
child.Kind = reflect.Float64
|
||||
n = 8
|
||||
default:
|
||||
if n == 0 {
|
||||
|
||||
Reference in New Issue
Block a user