mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
trace_recorder: add combined ctf + pcapng policy
genodelabs/genode#4352
This commit is contained in:
parent
ef742001e8
commit
e4aceb7845
@ -13,6 +13,7 @@
|
||||
<rom label="vfs.lib.so"/>
|
||||
<rom label="ctf0"/>
|
||||
<rom label="pcapng"/>
|
||||
<rom label="ctf0_pcapng"/>
|
||||
<rom label="metadata"/>
|
||||
</content>
|
||||
|
||||
|
194
repos/gems/run/trace_recorder.run
Normal file
194
repos/gems/run/trace_recorder.run
Normal file
@ -0,0 +1,194 @@
|
||||
assert_spec linux
|
||||
|
||||
# check that babeltrace2 is present
|
||||
set babeltrace_missing [catch {
|
||||
spawn babeltrace2 -V
|
||||
expect {
|
||||
{Babeltrace 2.*} { }
|
||||
eof { return }
|
||||
timeout { return }
|
||||
}
|
||||
}]
|
||||
|
||||
if {$babeltrace_missing} {
|
||||
puts "\nPlease install babeltrace2 on your host system."
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# check that python-pcapng is present
|
||||
set python_pcapng_missing [catch {
|
||||
spawn -noecho sh -c "echo \"import pcapng\" | python"
|
||||
expect {
|
||||
{No module} { return }
|
||||
{not found} { return }
|
||||
eof { }
|
||||
}
|
||||
}]
|
||||
|
||||
if {$python_pcapng_missing} {
|
||||
puts "\nPlease install python-pcapng on your host system."
|
||||
exit 1;
|
||||
}
|
||||
|
||||
build { app/ping server/lx_fs }
|
||||
|
||||
create_boot_directory
|
||||
|
||||
import_from_depot \
|
||||
[depot_user]/src/[base_src] \
|
||||
[depot_user]/src/init \
|
||||
[depot_user]/src/libc \
|
||||
[depot_user]/src/nic_router \
|
||||
[depot_user]/src/report_rom \
|
||||
[depot_user]/src/vfs \
|
||||
[depot_user]/src/linux_rtc_drv \
|
||||
[depot_user]/src/trace_recorder \
|
||||
[depot_user]/raw/trace_recorder \
|
||||
[depot_user]/src/trace_recorder_policy \
|
||||
[depot_user]/src/dynamic_rom
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="LOG"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="PD"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="TRACE"/>
|
||||
</parent-provides>
|
||||
|
||||
<default-route>
|
||||
<service name="File_system"> <child name="vfs"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="linux_rtc_drv" ld="no">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Rtc"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="lx_fs" ld="no">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config>
|
||||
<default-policy root="/fs" writeable="yes"/>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="nic_router">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides>
|
||||
<service name="Nic"/>
|
||||
<service name="Uplink"/>
|
||||
</provides>
|
||||
<config icmp_echo_server="yes" trace_packets="yes">
|
||||
<default-policy domain="default"/>
|
||||
|
||||
<domain name="default" interface="10.0.4.1/24">
|
||||
<dhcp-server ip_first="10.0.4.2" ip_last="10.0.4.10"/>
|
||||
</domain>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="ping">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<config dst_ip="10.0.4.1" period_sec="1" count="10" verbose="yes"/>
|
||||
</start>
|
||||
|
||||
<!-- using dynamic_rom to delay enabling of trace_recorder -->
|
||||
<start name="dynamic_rom">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="ROM"/></provides>
|
||||
<config>
|
||||
<rom name="config">
|
||||
<inline>
|
||||
<config/>
|
||||
</inline>
|
||||
<sleep milliseconds="1000"/>
|
||||
<inline>
|
||||
<config period_ms="3000" enable="yes">
|
||||
<vfs> <fs/> </vfs>
|
||||
<policy label_suffix="nic_router" thread="ep" policy="ctf0_pcapng">
|
||||
<pcapng/>
|
||||
<ctf/>
|
||||
</policy>
|
||||
<policy label_suffix="ping" thread="ep" policy="ctf0">
|
||||
<ctf/>
|
||||
</policy>
|
||||
</config>
|
||||
</inline>
|
||||
<sleep milliseconds="2000"/>
|
||||
<inline>
|
||||
<config/>
|
||||
</inline>
|
||||
<sleep milliseconds="10000"/>
|
||||
</rom>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="trace_recorder" caps="200">
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
<route>
|
||||
<service name="File_system"> <child name="lx_fs"/> </service>
|
||||
<service name="ROM" label="config"> <child name="dynamic_rom"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
</config>
|
||||
}
|
||||
|
||||
exec rm -rf bin/fs
|
||||
exec mkdir -p bin/fs
|
||||
|
||||
build_boot_image { lx_fs
|
||||
fs
|
||||
ping }
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until {Enabled ctf writer for init -> ping -> ep} 20
|
||||
set spawn_id [output_spawn_id]
|
||||
run_genode_until {.*child "ping" exited with exit value 0.*} 60 $spawn_id
|
||||
|
||||
#######################
|
||||
# validate CTF output #
|
||||
#######################
|
||||
|
||||
set ctf_path [exec find bin/fs -type d -name nic_router]
|
||||
exec test -s $ctf_path/ep
|
||||
|
||||
# check generated trace by reading CTF trace as fast as possible using a dummy output
|
||||
exec babeltrace2 $ctf_path --output-format=dummy
|
||||
|
||||
|
||||
##########################
|
||||
# validate PCAPNG output #
|
||||
##########################
|
||||
|
||||
# create python script for pcapng parsing
|
||||
set fd [open [run_dir]/genode/check_pcapng.py "w"]
|
||||
puts $fd {
|
||||
import sys
|
||||
import pcapng
|
||||
|
||||
with open(sys.argv[1], "rb") as fp:
|
||||
scanner = pcapng.FileScanner(fp)
|
||||
for block in pcapng.FileScanner(fp):
|
||||
pass
|
||||
}
|
||||
close $fd
|
||||
|
||||
set pcap_file [exec find bin/fs -name nic_router.pcapng]
|
||||
exec test -s $pcap_file
|
||||
|
||||
# check generated trace by python script
|
||||
exec python [run_dir]/genode/check_pcapng.py $pcap_file
|
@ -0,0 +1,83 @@
|
||||
#include <util/string.h>
|
||||
#include <trace/policy.h>
|
||||
#include <trace_recorder_policy/ctf_stream0.h>
|
||||
#include <trace_recorder_policy/pcapng.h>
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Ctf;
|
||||
|
||||
enum { MAX_CAPTURE_LEN = 100 };
|
||||
|
||||
size_t max_event_size() {
|
||||
return Trace_recorder::Pcapng_event::max_size(MAX_CAPTURE_LEN); }
|
||||
|
||||
size_t trace_eth_packet(char *dst, char const *if_name, bool out, char *pkt_data, size_t pkt_len)
|
||||
{
|
||||
using namespace Pcapng;
|
||||
Trace_recorder::Pcapng_event *e =
|
||||
new (dst) Trace_recorder::Pcapng_event(Link_type::ETHERNET, if_name, out, pkt_len, pkt_data, MAX_CAPTURE_LEN);
|
||||
|
||||
return e->total_length();
|
||||
}
|
||||
|
||||
size_t checkpoint(char *dst, char const *name, unsigned long data, void *addr, unsigned char type)
|
||||
{
|
||||
size_t len = strlen(name) + 1;
|
||||
|
||||
new (dst) Checkpoint(name, len, data, addr, type);
|
||||
|
||||
return len + sizeof(Checkpoint);
|
||||
}
|
||||
|
||||
size_t log_output(char *dst, char const *log_message, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t rpc_call(char *dst, char const *rpc_name, Msgbuf_base const &)
|
||||
{
|
||||
size_t len = strlen(rpc_name) + 1;
|
||||
|
||||
new (dst) Rpc_call(rpc_name, len);
|
||||
|
||||
return len + sizeof(Rpc_call);
|
||||
}
|
||||
|
||||
size_t rpc_returned(char *dst, char const *rpc_name, Msgbuf_base const &)
|
||||
{
|
||||
size_t len = strlen(rpc_name) + 1;
|
||||
|
||||
new (dst) Rpc_returned(rpc_name, len);
|
||||
|
||||
return len + sizeof(Rpc_returned);
|
||||
}
|
||||
|
||||
size_t rpc_dispatch(char *dst, char const *rpc_name)
|
||||
{
|
||||
size_t len = strlen(rpc_name) + 1;
|
||||
|
||||
new (dst) Rpc_dispatch(rpc_name, len);
|
||||
|
||||
return len + sizeof(Rpc_dispatch);
|
||||
}
|
||||
|
||||
size_t rpc_reply(char *dst, char const *rpc_name)
|
||||
{
|
||||
size_t len = strlen(rpc_name) + 1;
|
||||
|
||||
new (dst) Rpc_reply(rpc_name, len);
|
||||
|
||||
return len + sizeof(Rpc_reply);
|
||||
}
|
||||
|
||||
size_t signal_submit(char *dst, unsigned const num)
|
||||
{
|
||||
new (dst) Signal_submit(num);
|
||||
|
||||
return sizeof(Signal_submit);
|
||||
}
|
||||
|
||||
size_t signal_receive(char *dst, Signal_context const & context, unsigned num)
|
||||
{
|
||||
new (dst) Signal_receive(num, (void*)&context);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
TARGET = ctf0_pcapng
|
||||
|
||||
TARGET_POLICY = ctf0_pcapng
|
||||
|
||||
include $(PRG_DIR)/../policy.inc
|
Loading…
Reference in New Issue
Block a user