2014-05-12 13:09:12 +02:00
|
|
|
Valgrind Support
|
2013-09-30 14:07:10 +02:00
|
|
|
================
|
|
|
|
|
2014-02-10 15:28:55 +01:00
|
|
|
Rebuild your application using the all-valgrind target like this:
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2014-02-04 18:41:38 +01:00
|
|
|
make -B clean all-valgrind
|
2013-09-30 14:07:10 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
That way native will tell Valgrind about RIOT's stacks and prevent
|
|
|
|
Valgrind from reporting lots of false positives.
|
|
|
|
The debug information flag `-g` is not strictly necessary, but passing
|
|
|
|
it allows Valgrind to tell you precisely which code triggered the error.
|
2013-09-30 14:07:10 +02:00
|
|
|
|
2014-02-04 18:41:38 +01:00
|
|
|
To run your application run:
|
2013-10-24 12:58:28 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
make term-valgrind
|
2013-10-24 12:58:28 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
All this does is run your application under Valgrind.
|
|
|
|
Now Valgrind will print some information whenever it detects an
|
2014-02-04 18:41:38 +01:00
|
|
|
invalid memory access.
|
2013-10-24 12:58:28 +02:00
|
|
|
|
|
|
|
In order to debug the program when this occurs you can pass the
|
2014-05-12 13:09:12 +02:00
|
|
|
--db-attach parameter to Valgrind. E.g:
|
2013-10-24 12:58:28 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
valgrind --db-attach=yes ./bin/native/default.elf tap0
|
2013-10-24 12:58:28 +02:00
|
|
|
|
|
|
|
Now, you will be asked whether you would like to attach the running
|
|
|
|
process to gdb whenever a problem occurs.
|
|
|
|
|
|
|
|
In order for this to work under Linux 3.4 or newer, you might need to
|
|
|
|
disable the ptrace access restrictions:
|
|
|
|
As root call:
|
|
|
|
|
|
|
|
echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
2013-09-30 14:07:10 +02:00
|
|
|
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
Network Support
|
2013-09-30 14:07:10 +02:00
|
|
|
===============
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
If you compile RIOT for the native cpu and include the `native_net`
|
2013-06-26 23:29:09 +02:00
|
|
|
module, you need to specify a network interface like this:
|
2013-10-24 12:58:28 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
make term PORT=tap0
|
2013-06-26 23:29:09 +02:00
|
|
|
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
Setting Up A Tap Network
|
2013-06-26 23:29:09 +02:00
|
|
|
========================
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
There is a shellscript in RIOT/cpu/native called `tapsetup.sh` which you
|
2013-06-26 23:29:09 +02:00
|
|
|
can use to create a network of tap interfaces.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
To create a bridge and two (or count at your option) tap interfaces:
|
2013-10-24 12:58:28 +02:00
|
|
|
|
|
|
|
./tapsetup.sh create [count]
|
|
|
|
|
2013-06-26 23:29:09 +02:00
|
|
|
To delete the bridge and all tap interfaces:
|
2013-10-24 12:58:28 +02:00
|
|
|
|
|
|
|
./tapsetup.sh delete
|
2013-06-26 23:29:09 +02:00
|
|
|
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
OSX Tap Networking
|
2013-10-09 15:00:51 +02:00
|
|
|
==================
|
2013-06-26 23:29:09 +02:00
|
|
|
|
|
|
|
For tun/tap networking in OSX you will need:
|
|
|
|
http://tuntaposx.sourceforge.net/
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
For OSX there is a separate script called `tapsetup-osx.sh`.
|
2013-08-15 17:04:03 +02:00
|
|
|
Run it, (it instructs you to start the RIOT instances).
|
2014-05-12 13:09:12 +02:00
|
|
|
In contrast to Linux you will need to run `tapsetup-osx.sh delete`
|
|
|
|
after killing your instances and rerun `tapsetup-osx.sh create` before
|
2013-08-15 17:04:03 +02:00
|
|
|
restarting.
|
2013-08-18 20:34:53 +02:00
|
|
|
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
FreeBSD Tap Networking
|
|
|
|
======================
|
|
|
|
|
|
|
|
For FreeBSD there is a separate script called `tapsetup-freebsd.sh`.
|
|
|
|
|
|
|
|
|
|
|
|
Daemonization
|
2013-08-18 20:34:53 +02:00
|
|
|
=============
|
|
|
|
|
|
|
|
You can daemonize a riot process. This is useful for larger networks.
|
|
|
|
Valgrind will fork along with the riot process and dump its output in
|
|
|
|
the terminal.
|
|
|
|
|
|
|
|
Usage:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
./bin/native/default.elf -d
|
2013-08-18 20:34:53 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
Use UART redirection if you want to use a shell or get stderr/stdout
|
2013-08-18 20:34:53 +02:00
|
|
|
output with/from a daemonized process.
|
|
|
|
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
UART Redirection
|
2013-08-18 20:34:53 +02:00
|
|
|
================
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
You can redirect the processes' stdin/stdout/stderr by specifying
|
|
|
|
one or more options from below.
|
|
|
|
|
|
|
|
UNIX socket
|
|
|
|
-----------
|
2013-08-18 20:34:53 +02:00
|
|
|
|
|
|
|
To redirect stdio to a UNIX socket run:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
./bin/native/default.elf -u -d
|
2013-08-18 20:34:53 +02:00
|
|
|
RIOT pid: 18663
|
|
|
|
|
|
|
|
Attach this UNIX socket:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2013-08-18 20:34:53 +02:00
|
|
|
nc -U /tmp/riot.tty.18663
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
TCP socket
|
|
|
|
----------
|
2013-08-18 20:34:53 +02:00
|
|
|
To redirect stdio to a TCP socket:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
./bin/native/default.elf -t 4711 -d
|
2013-08-18 20:34:53 +02:00
|
|
|
RIOT pid: 18663
|
|
|
|
|
|
|
|
Attach this TCP socket:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2013-08-18 20:34:53 +02:00
|
|
|
nc localhost 4711
|
|
|
|
|
|
|
|
Stop the process:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2013-08-18 20:34:53 +02:00
|
|
|
kill 18663
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
File for stderr
|
|
|
|
---------------
|
2013-08-18 20:34:53 +02:00
|
|
|
To redirect stderr to a file:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
./bin/native/default.elf -d -e
|
2013-08-18 20:34:53 +02:00
|
|
|
RIOT pid: 18663
|
|
|
|
|
|
|
|
Read from it:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2013-08-18 20:34:53 +02:00
|
|
|
tail -f /tmp/riot.stderr.18663
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
File for stdout
|
|
|
|
---------------
|
2013-08-18 20:34:53 +02:00
|
|
|
To redirect stdout to a file:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-02-01 12:10:08 +01:00
|
|
|
./bin/native/default.elf -d -o
|
2013-08-18 20:34:53 +02:00
|
|
|
RIOT pid: 18663
|
|
|
|
|
|
|
|
Read from it:
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2013-08-18 20:34:53 +02:00
|
|
|
tail -f /tmp/riot.stdout.18663
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
|
|
|
|
Notes
|
|
|
|
-----
|
2013-08-18 20:34:53 +02:00
|
|
|
The stdout redirection only writes to file while no socket connection
|
|
|
|
is established.
|
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
Socket redirection is only available when the UART module has been
|
2013-08-18 20:34:53 +02:00
|
|
|
compiled in.
|
2014-04-04 08:21:23 +02:00
|
|
|
|
2014-05-12 13:09:12 +02:00
|
|
|
|
|
|
|
Compile Time Options
|
2014-04-04 08:21:23 +02:00
|
|
|
====================
|
|
|
|
|
|
|
|
Compile with
|
2014-05-12 13:09:12 +02:00
|
|
|
|
2014-04-04 08:21:23 +02:00
|
|
|
CFLAGS=-DNATIVE_AUTO_EXIT make
|
|
|
|
|
|
|
|
to exit the riot core after the last thread has exited.
|