使用 set 命令。

(gdb) set $i="hello"
 (gdb) ptype $i
 type = char [6]
 (gdb) set $i=1
 (gdb) ptype $i
 type = int
 (gdb) set $i=(char)1
 (gdb) ptype $i
 type = char
 (gdb) set $i=(short)1
 (gdb) ptype $i
 type = short