trace: add 'extract' command

Add a 'trace extract' command that hides the gdb magic and is
future-proof when we change the trace transport protocol.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Fix regression in early output to stdout

Output to stdout normally goes to file descriptor 1. However, during
early boot, before the console is opened on file descriptor 1, we also
want printf() to work. So this case is specially treated in
libc/stdio/__stdout_write.cc, where in this early case, we used debug_write
directly, instead of write to the file descriptor.

However, recent patches changed debug_write to write to a memory buffer,
instead of to screen (unless "--verbose" option is given to the loader).
This made early printf() break too.

This patch changes __stdout_write to use console::write(), not
debug_write(). To use console::write(), I had to convert that source
file to C++.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader.cc: make error messages visible

Since recently, debug() messages are by default not visible. This means
they are not a good way to print error messages :-)

This patch fixes two error messages from loader.cc, that were no longer
visible. For example, "scripts/run.py -e xyz" completed without any message
instead of telling the user that "xyz" doesn't exist.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader: Bring back OSv version at boot

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Revert "conf: make release build use -O3"

This reverts commit 4af010f18bd9656cf021303ab2c4f86a155e3212.

This change causes OSv to abort when JVM is started with
the following options:

 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

Result:

ERROR: transport error 202: setsockopt TCPNODELAY failed: Protocol not available
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted

I think it's best to revert it until the root cause is solved.

See issue #167

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mgmt.git: boot message cleanups

Take the latest mgmt.git which has fixes to make OSv boot less verbose.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
README: Replace debugging sections with links to Wiki

OSv debugging and trace analysis are much better covered in the Wiki
pages.  Replace the text in README with links to the more up-to-date
Wiki.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
devfs: Remove "device not found" printout

OpenJDK looks up "/dev/urandom" at startup but works just fine without
it.  There's no need to display an error message in OSv if that happens.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader: Remove copyright statement from boot log

Remove the copyright statement from boot log but keep the OSv version
banner there to tidy up boot.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: Add pthread_attr_getstacksize()

Add pthread_attr_getstacksize() in preparation for fixing RLIMIT_STACK.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Use pthread stack info for RLIMIT_STACK

Currently, RLIMIT_STACK is 64 KB.  This is too small for the JVM which
limits stack size to RLIMIT_STACK if a VMA range that covers address
found in '__libc_stack_end' in /proc/self/maps.

In preparation for procfs support, switch to pthread_attr_getstacksize()
for RLIMIT_STACK;

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: 'struct file' to VOP_READ

Add 'struct file' to VOP_READ API. This is needed for procfs which
generates file contents at open() time and read() must operate on it,
not the vnode.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: procfs support

Add procfs_maps() function to core/mmu.cc that returns all the VMAs
formatted for Linux compatible "/proc/<pid>/maps" file.

This will be called by the procfs filesystem.

Limitations:

  * Shared mappings are not identified as such.
  * File-backed mmap offset, device, inode, and pathname are not
    reported.
  * Special region names such as [heap] and [stack] are not reported.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
proc filesystem

This patch adds a simple Linux compatible procfs filesystem.  It
currently implements a "/proc/self/maps" file which is looked up by
OpenJDK during startup.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: mount procfs at boot

Add a '/proc' directory to OSv image and mount procfs on it.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: miscs-procfs.so

Add a simple manual test case for checking "/proc/self/maps" output.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>