base: avoid use of deprecated base/printf.h

Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.

While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).

To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.

Issue #1987
This commit is contained in:
Norman Feske
2016-07-13 19:07:09 +02:00
committed by Christian Helmuth
parent a5d3aa8373
commit 17c79a9e23
699 changed files with 5156 additions and 5865 deletions

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
/* NOVA includes */
#include <nova/syscalls.h>
@ -55,8 +55,7 @@ void Cap_range::inc(unsigned id)
}
if (failure)
PERR("cap reference counting error - reference overflow of cap=%lx",
_base + id);
error("cap reference counting error - reference overflow of cap=", _base + id);
}
@ -82,8 +81,9 @@ void Cap_range::dec(unsigned const id_start, bool revoke, unsigned num_log_2)
}
if (failure)
PERR("cap reference counting error - one counter of cap range %lx+%x "
"has been already zero", _base + id_start, 1 << num_log_2);
error("cap reference counting error - one counter of cap ",
"range ", _base + id_start, "+", 1 << num_log_2, " "
"has been already zero");
}

View File

@ -11,8 +11,6 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
/* base-internal includes */
#include <base/internal/capability_data.h>

View File

@ -14,7 +14,7 @@
/* Genode includes */
#include <base/ipc.h>
#include <base/thread.h>
#include <base/printf.h>
#include <base/log.h>
/* base-internal includes */
#include <base/internal/ipc.h>
@ -51,7 +51,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
/* the protocol value is unused as the badge is delivered by the kernel */
if (!copy_msgbuf_to_utcb(utcb, snd_msg, 0)) {
PERR("could not setup IPC");
error("could not setup IPC");
throw Ipc_error();
}

View File

@ -14,7 +14,6 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/rpc_server.h>
#include <base/env.h>
@ -94,8 +93,7 @@ void Rpc_entrypoint::_dissolve(Rpc_object_base *obj)
utcb->msg[0] = 0xdead;
utcb->set_msg_word(1);
if (uint8_t res = call(_cap.local_name()))
PERR("%8p - could not clean up entry point of thread 0x%p - res %u",
utcb, this->utcb(), res);
error(utcb, " - could not clean up entry point of thread ", this->utcb(), " - res ", res);
}
@ -140,7 +138,7 @@ void Rpc_entrypoint::_activation_entry()
/* in case of a portal cleanup call we are done here - just reply */
if (ep._cap.local_name() == (long)id_pt) {
if (!rcv_window.prepare_rcv_window(utcb))
PWRN("out of capability selectors for handling server requests");
warning("out of capability selectors for handling server requests");
ep._rcv_buf.reset();
reply(utcb, exc, ep._snd_buf);
@ -153,8 +151,7 @@ void Rpc_entrypoint::_activation_entry()
/* atomically lookup and lock referenced object */
auto lambda = [&] (Rpc_object_base *obj) {
if (!obj) {
PERR("could not look up server object, return from call id_pt=%lx",
id_pt);
error("could not look up server object, return from call id_pt=", id_pt);
return;
}
@ -166,7 +163,7 @@ void Rpc_entrypoint::_activation_entry()
ep.apply(id_pt, lambda);
if (!rcv_window.prepare_rcv_window(*(Nova::Utcb *)ep.utcb()))
PWRN("out of capability selectors for handling server requests");
warning("out of capability selectors for handling server requests");
ep._rcv_buf.reset();
reply(utcb, exc, ep._snd_buf);
@ -238,7 +235,7 @@ Rpc_entrypoint::~Rpc_entrypoint()
typedef Object_pool<Rpc_object_base> Pool;
Pool::remove_all([&] (Rpc_object_base *obj) {
PWRN("Object pool not empty in %s", __func__);
warning("object pool not empty in ", __func__);
_dissolve(obj);
});

View File

@ -14,6 +14,7 @@
/* Genode includes */
#include <base/signal.h>
#include <base/log.h>
#include <base/trace/events.h>
/* NOVA includes */
@ -40,8 +41,7 @@ void Signal_transmitter::submit(unsigned cnt)
if (res == NOVA_OK)
return;
PDBG("submitting signal failed - error %u - context=0x%lx", res,
_context.local_name());
warning("submitting signal failed - error ", res, " - context=", _context);
_context = Signal_context_capability();
}

View File

@ -15,7 +15,7 @@
/* Genode includes */
#include <base/thread.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/sleep.h>
#include <base/env.h>
#include <base/rpc_client.h>
@ -47,8 +47,8 @@ void Thread::_thread_start()
Thread::myself()->entry();
} catch (...) {
try {
PERR("Thread '%s' died because of an uncaught exception",
Thread::myself()->name().string());
error("Thread '", Thread::myself()->name(), "' "
"died because of an uncaught exception");
} catch (...) {
/* die in a noisy way */
nova_die();