firmware: add allocator debug feature, invoked by artiq_coredebug frontend.

This commit is contained in:
whitequark 2018-04-21 18:27:14 +00:00
parent 873324d52b
commit 3b054855ec
5 changed files with 56 additions and 1 deletions

View File

@ -17,6 +17,8 @@ class Request(Enum):
Hotswap = 4
Reboot = 5
DebugAllocator = 8
class Reply(Enum):
Success = 1
@ -151,3 +153,6 @@ class CommMgmt:
def reboot(self):
self._write_header(Request.Reboot)
self._read_expect(Reply.RebootImminent)
def debug_allocator(self):
self._write_header(Request.DebugAllocator)

View File

@ -16,6 +16,8 @@ pub enum Request {
Hotswap(Vec<u8>),
Reboot,
DebugAllocator,
}
pub enum Reply<'a> {
@ -52,6 +54,7 @@ impl Request {
6 => Request::SetUartLogFilter(read_log_level_filter(reader)?),
4 => Request::Hotswap(reader.read_bytes()?),
5 => Request::Reboot,
8 => Request::DebugAllocator,
_ => return Err(io::Error::new(io::ErrorKind::InvalidData, "unknown request type"))
})
}

View File

@ -97,7 +97,10 @@ fn worker(io: &Io, stream: &mut TcpStream) -> io::Result<()> {
stream.close()?;
warn!("restarting");
unsafe { boot::reset() }
}
},
Request::DebugAllocator =>
unsafe { println!("{}", ::ALLOC) },
};
}
}

View File

@ -0,0 +1,43 @@
#!/usr/bin/env python3
import argparse
import sys
import struct
from artiq.tools import verbosity_args, init_logger
from artiq.master.databases import DeviceDB
from artiq.coredevice.comm_mgmt import CommMgmt
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ core device debug tool")
verbosity_args(parser)
parser.add_argument("--device-db", default="device_db.py",
help="device database file (default: '%(default)s')")
subparsers = parser.add_subparsers(dest="action")
p_allocator = subparsers.add_parser("allocator",
help="show heap layout")
return parser
def main():
args = get_argparser().parse_args()
init_logger(args)
core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
mgmt = CommMgmt(core_addr)
try:
if args.action == "allocator":
mgmt.debug_allocator()
else:
print("An action needs to be specified.", file=sys.stderr)
sys.exit(1)
finally:
mgmt.close()
if __name__ == "__main__":
main()

View File

@ -25,6 +25,7 @@ console_scripts = [
"artiq_coreconfig = artiq.frontend.artiq_coreconfig:main",
"artiq_corelog = artiq.frontend.artiq_corelog:main",
"artiq_coreboot = artiq.frontend.artiq_coreboot:main",
"artiq_coredebug = artiq.frontend.artiq_coredebug:main",
"artiq_ctlmgr = artiq.frontend.artiq_ctlmgr:main",
"artiq_devtool = artiq.frontend.artiq_devtool:main",
"artiq_pcap = artiq.frontend.artiq_pcap:main",