/
register_info.rs
93 lines (88 loc) · 3.62 KB
/
register_info.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use super::prelude::*;
use crate::protocol::commands::ext::RegisterInfo;
impl<T: Target, C: Connection> GdbStubImpl<T, C> {
pub(crate) fn handle_register_info(
&mut self,
res: &mut ResponseWriter<'_, C>,
target: &mut T,
command: RegisterInfo,
) -> Result<HandlerStatus, Error<T::Error, C::Error>> {
let ops = match target.support_register_info() {
Some(ops) => ops,
None => return Ok(HandlerStatus::Handled),
};
crate::__dead_code_marker!("register_info", "impl");
let handler_status = match command {
RegisterInfo::qRegisterInfo(cmd) => {
use crate::target::ext::register_info::Register;
match ops
.get_register_info(cmd.reg_id)
.map_err(Error::TargetError)?
{
Some(Register {
name,
alt_name,
bitsize,
offset,
encoding,
format,
set,
gcc,
dwarf,
generic,
container_regs,
invalidate_regs,
}) => {
res.write_str("name:")?;
res.write_str(name)?;
res.write_str(";alt-name:")?;
res.write_str(alt_name)?;
res.write_str(";bitsize:")?;
res.write_dec(bitsize)?;
res.write_str(";offset:")?;
res.write_dec(offset)?;
res.write_str(";encoding:")?;
res.write_str(encoding)?;
res.write_str(";format:")?;
res.write_str(format)?;
res.write_str(";set:")?;
res.write_str(set)?;
if let Some(gcc) = gcc {
res.write_str(";gcc:")?;
res.write_dec(gcc)?;
}
if let Some(dwarf) = dwarf {
res.write_str(";dwarf:")?;
res.write_dec(dwarf)?;
}
if let Some(generic) = generic {
res.write_str(";generic:")?;
res.write_str(generic)?;
}
if let Some(c_regs) = container_regs {
res.write_str(";container-regs:")?;
res.write_num(c_regs[0])?;
for c_reg in c_regs.iter().skip(1) {
res.write_str(",")?;
res.write_num(*c_reg)?;
}
}
if let Some(i_regs) = invalidate_regs {
res.write_str(";invalidate-regs:")?;
res.write_num(i_regs[0])?;
for i_reg in i_regs.iter().skip(1) {
res.write_str(",")?;
res.write_num(*i_reg)?;
}
}
res.write_str(";")?;
}
// This will end the 'qRegisterInfo' query
None => res.write_str("E45")?,
}
HandlerStatus::Handled
}
};
Ok(handler_status)
}
}