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

@ -15,6 +15,7 @@
/* Genode includes */
#include <base/log.h>
#include <base/component.h>
#include <base/heap.h>
#include <base/attached_rom_dataspace.h>
#include <os/config.h>

View File

@ -48,7 +48,8 @@ void __wake_up(wait_queue_head_t *wq, bool all)
{
Wait_list *list = static_cast<Wait_list *>(wq->list);
if (!list) {
PWRN("wait_queue_head_t is empty, wq: %p called from: %p", wq, __builtin_return_address(0));
Genode::warning("wait_queue_head_t is empty, wq: ", wq, " "
"called from: ", __builtin_return_address(0));
return;
}
@ -72,7 +73,7 @@ void ___wait_event(wait_queue_head_t *wq)
{
Wait_list *list = static_cast<Wait_list *>(wq->list);
if (!list) {
PWRN("__wait_event(): empty list in wq: %p", wq);
Genode::warning("__wait_event():dd empty list in wq: ", wq);
init_waitqueue_head(wq);
list = static_cast<Wait_list *>(wq->list);
}

View File

@ -28,7 +28,7 @@ struct page *alloc_pages(gfp_t gfp_mask, unsigned int order)
page->paddr = Genode::Dataspace_client(ds_cap).phys_addr();
if (!page->addr) {
PERR("alloc_pages: %zu failed", size);
Genode::error("alloc_pages: ", size, " failed");
kfree(page);
return 0;
}

View File

@ -72,11 +72,11 @@ void mutex_lock(struct mutex *m)
void mutex_unlock(struct mutex *m)
{
if (m->state == MUTEX_UNLOCKED) {
PERR("Bug: multiple mutex unlock detected");
Genode::error("bug: multiple mutex unlock detected");
Genode::sleep_forever();
}
if (m->holder != Lx::scheduler().current()) {
PERR("Bug: mutex unlock by task not holding the mutex");
Genode::error("bug: mutex unlock by task not holding the mutex");
Genode::sleep_forever();
}

View File

@ -18,9 +18,11 @@
void *kmalloc(size_t size, gfp_t flags)
{
if (flags & __GFP_DMA)
PWRN("GFP_DMA memory (below 16 MiB) requested (%p)", __builtin_return_address(0));
Genode::warning("GFP_DMA memory (below 16 MiB) requested "
"(", __builtin_return_address(0), ")");
if (flags & __GFP_DMA32)
PWRN("GFP_DMA32 memory (below 4 GiB) requested (%p)", __builtin_return_address(0));
Genode::warning("GFP_DMA32 memory (below 4 GiB) requested"
"(", __builtin_return_address(0), ")");
void *addr = nullptr;
@ -29,7 +31,7 @@ void *kmalloc(size_t size, gfp_t flags)
: Lx::Malloc::mem().alloc(size);
if ((Genode::addr_t)addr & 0x3)
PERR("unaligned kmalloc %lx", (Genode::addr_t)addr);
Genode::error("unaligned kmalloc ", (Genode::addr_t)addr);
if (flags & __GFP_ZERO)
Genode::memset(addr, 0, size);
@ -68,8 +70,8 @@ void kfree(void const *p)
else if (Lx::Malloc::dma().inside((Genode::addr_t)p))
Lx::Malloc::dma().free(p);
else
PERR("%s: unknown block at %p, called from %p", __func__,
p, __builtin_return_address(0));
Genode::error(__func__, ": unknown block at ", p, ", "
"called from ", __builtin_return_address(0));
}
@ -82,7 +84,7 @@ static size_t _ksize(void *p)
else if (Lx::Malloc::dma().inside((Genode::addr_t)p))
size = Lx::Malloc::dma().size(p);
else
PERR("%s: unknown block at %p", __func__, p);
Genode::error(__func__, ": unknown block at ", p);
return size;
}

View File

@ -18,8 +18,8 @@
void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *w, int state)
{
if (!q) {
PWRN("prepare_to_wait: wait_queue_head_t is 0, ignore, called from: %p",
__builtin_return_address(0));
Genode::warning("prepare_to_wait: wait_queue_head_t is 0, ignore, "
"called from: ", __builtin_return_address(0));
return;
}
@ -39,8 +39,8 @@ void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *w, int state)
void finish_wait(wait_queue_head_t *q, wait_queue_t *w)
{
if (!q) {
PWRN("finish_wait: wait_queue_head_t is 0, ignore, called from: %p",
__builtin_return_address(0));
Genode::warning("finish_wait: wait_queue_head_t is 0, ignore, ",
"called from: ", __builtin_return_address(0));
return;
}

View File

@ -101,8 +101,8 @@ bool cancel_delayed_work_sync(struct delayed_work *dwork)
bool pending = cancel_delayed_work(dwork);
if (pending) {
PERR("WARN: delayed_work %p is executed directly in current '%s' routine",
dwork, Lx::scheduler().current()->name());
Genode::error("WARN: delayed_work ", dwork, " is executed directly in "
"current '", Lx::scheduler().current()->name(), "' routine");
dwork->work.func(&dwork->work);
}

View File

@ -1,23 +0,0 @@
/*
* \brief Debug utilities
* \author Sebastian Sumpf
* \author Josef Soentgen
* \author Norman Feske
* \date 2014-10-10
*/
/*
* Copyright (C) 2014-2016 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _LX_KIT__INTERNAL__DEBUG_H_
#define _LX_KIT__INTERNAL__DEBUG_H_
#ifndef PDBGV
#define PDBGV(...) do { if (verbose) PDBG(__VA_ARGS__); } while (0)
#endif
#endif /* _LX_KIT__INTERNAL__DEBUG_H_ */

View File

@ -25,7 +25,6 @@
#include <util/retry.h>
/* Linux emulation environment includes */
#include <lx_kit/internal/debug.h>
#include <lx_kit/internal/list.h>
#include <lx_kit/internal/io_port.h>
@ -136,22 +135,12 @@ class Lx::Pci_dev : public pci_dev, public Lx_kit::List<Pci_dev>::Element
if (res.type() == Device::Resource::MEMORY) flags |= IORESOURCE_MEM;
this->resource[i].flags = flags;
PDBGV("this=%p base: %x size: %x type: %u",
this, res.base(), res.size(), res.type());
/* request port I/O session */
if (res.type() == Device::Resource::IO) {
uint8_t const virt_bar = _client.phys_bar_to_virt(i);
_io_port.session(res.base(), res.size(), _client.io_port(virt_bar));
io = true;
PDBGV("I/O [%u-%u)",
res.base(), res.base() + res.size());
}
/* request I/O memory (write combined) */
if (res.type() == Device::Resource::MEMORY)
PDBGV("I/O memory [%x-%x)", res.base(),
res.base() + res.size());
}
/* enable bus master and io bits */

View File

@ -17,7 +17,7 @@
#define _LX_KIT__INTERNAL__TASK_H_
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <base/thread.h>
#include <base/sleep.h>
@ -89,7 +89,7 @@ class Lx::Task : public Lx_kit::List<Lx::Task>::Element
case STATE_WAIT_BLOCKED: return false;
}
PERR("state %d not handled by switch", _state);
Genode::error("state ", (int)_state, " not handled by switch");
Genode::sleep_forever();
}
@ -125,7 +125,7 @@ class Lx::Task : public Lx_kit::List<Lx::Task>::Element
if (_wait_le_enqueued && _wait_list == list) return;
if (_wait_le_enqueued) {
PERR("%p already queued in %p", this, _wait_list);
Genode::error(this, " already queued in ", _wait_list);
Genode::sleep_forever();
}
@ -137,12 +137,12 @@ class Lx::Task : public Lx_kit::List<Lx::Task>::Element
void wait_dequeue(List *list)
{
if (!_wait_le_enqueued) {
PERR("%p not queued", this);
Genode::error(this, " not queued");
Genode::sleep_forever();
}
if (_wait_list != list) {
PERR("especially not in list %p", list);
Genode::error("especially not in list ", list);
Genode::sleep_forever();
}
@ -218,7 +218,7 @@ class Lx::Task : public Lx_kit::List<Lx::Task>::Element
}
/* never reached */
PERR("Unexpected return of Task");
Genode::error("unexpected return of task");
Genode::sleep_forever();
}

View File

@ -40,7 +40,6 @@ class Lx::Pci_dev_registry
void insert(Pci_dev *pci_dev)
{
PDBG("insert pci_dev %p", pci_dev);
_devs.insert(pci_dev);
}
@ -74,7 +73,8 @@ class Lx::Pci_dev_registry
return Genode::Io_mem_session_client(io_mem_cap).dataspace();
}
PERR("Device using i/o memory of address %lx is unknown", phys);
Genode::error("device using I/O memory of address ",
Genode::Hex(phys), " is unknown");
return Genode::Io_mem_dataspace_capability();
}
@ -88,7 +88,7 @@ class Lx::Pci_dev_registry
return value;
}
PWRN("I/O port(%u) read failed", port);
Genode::warning("I/O port(", port, ") read failed");
return (T)~0;
}
@ -100,7 +100,7 @@ class Lx::Pci_dev_registry
if (d->io_port().out<T>(port, value))
return;
PWRN("I/O port(%u) write failed", port);
Genode::warning("I/O port(", port, ") write failed");
}
};

View File

@ -13,7 +13,7 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
#include <base/log.h>
#include <base/snprintf.h>
#include <os/config.h>
#include <util/string.h>
@ -48,31 +48,33 @@ void __attribute__((constructor)) init_libc_lxip(void)
(Genode::strlen(netmask_str) != 0) ||
(Genode::strlen(gateway_str) != 0)) {
if (Genode::strlen(ip_addr_str) == 0) {
PERR("Missing \"ip_addr\" attribute. Ignoring network interface config.");
Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
} else if (Genode::strlen(netmask_str) == 0) {
PERR("Missing \"netmask\" attribute. Ignoring network interface config.");
Genode::error("missing \"netmask\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
} else if (Genode::strlen(gateway_str) == 0) {
PERR("Missing \"gateway\" attribute. Ignoring network interface config.");
Genode::error("missing \"gateway\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
}
} else
throw -1;
PDBG("static network interface: ip_addr=%s netmask=%s gateway=%s ",
ip_addr_str, netmask_str, gateway_str);
Genode::log("static network interface: ",
"ip_addr=", Genode::Cstring(ip_addr_str), " "
"netmask=", Genode::Cstring(netmask_str), " "
"gateway=", Genode::Cstring(gateway_str));
Genode::snprintf(address_buf, sizeof(address_buf), "%s::%s:%s:::off",
ip_addr_str, gateway_str, netmask_str);
address_config = address_buf;
}
catch (...) {
PINF("Using DHCP for interface configuration.");
Genode::log("Using DHCP for interface configuration.");
address_config = "dhcp";
}
PDBG("init_libc_lxip() address config=%s\n", address_config);
Genode::log("init_libc_lxip() address config=", address_config);
create_lxip_plugin(address_config);
}

View File

@ -20,7 +20,7 @@
/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/log.h>
/* Libc plugin includes */
#include <libc-plugin/fd_alloc.h>
@ -140,7 +140,7 @@ struct Plugin : Libc::Plugin
Plugin::Plugin(char const *address_config) : socketcall(Lxip::init(address_config))
{
PDBG("using the lxip libc plugin");
Genode::log("using the lxip libc plugin");
}
@ -260,7 +260,7 @@ int Plugin::fcntl(Libc::File_descriptor *sockfdo, int cmd, long val)
default:
PERR("unsupported fcntl() request: %d", cmd);
Genode::error("unsupported fcntl() request: ", cmd);
errno = ENOSYS;
return -1;
}
@ -308,8 +308,7 @@ int Plugin::getsockopt(Libc::File_descriptor *sockfdo, int level,
int optname, void *optval, socklen_t *optlen)
{
if (level != SOL_SOCKET) {
PERR("%s: Unsupported level %d, we only support SOL_SOCKET for now",
__func__, level);
Genode::error(__func__, ": Unsupported level ", level, ", we only support SOL_SOCKET for now");
errno = EBADF;
return -1;
}
@ -342,7 +341,7 @@ int Plugin::ioctl(Libc::File_descriptor *sockfdo, int request, char *argp)
default:
PERR("unsupported ioctl() request");
Genode::error("unsupported ioctl() request");
errno = ENOSYS;
return -1;
}
@ -497,8 +496,7 @@ int Plugin::setsockopt(Libc::File_descriptor *sockfdo, int level,
socklen_t optlen)
{
if (level != SOL_SOCKET) {
PERR("%s: Unsupported level %d, we only support SOL_SOCKET for now",
__func__, level);
Genode::error(__func__, ": Unsupported level ", level, ", we only support SOL_SOCKET for now");
errno = EBADF;
return -1;
}
@ -546,7 +544,7 @@ int Plugin::linux_family(const struct sockaddr *addr, socklen_t addrlen)
default:
PERR("Unsupported socket BSD-protocol %u\n", addr->sa_family);
Genode::error("unsupported socket BSD protocol ", addr->sa_family);
return 0;
}
@ -569,7 +567,7 @@ int Plugin::bsd_family(struct sockaddr *addr)
default:
PERR("Unsupported socket Linux-protocol %u\n", addr->sa_family);
Genode::error("unsupported socket Linux protocol ", addr->sa_family);
return 0;
}
}
@ -580,19 +578,19 @@ int Plugin::translate_msg_flags(int bsd_flags)
using namespace Lxip;
int f = 0;
if (bsd_flags & MSG_OOB) f |= LINUX_MSG_OOB;
if (bsd_flags & MSG_PEEK) f |= LINUX_MSG_PEEK;
if (bsd_flags & MSG_DONTROUTE) f |= LINUX_MSG_DONTROUTE;
if (bsd_flags & MSG_EOR) f |= LINUX_MSG_EOR;
if (bsd_flags & MSG_TRUNC) f |= LINUX_MSG_TRUNC;
if (bsd_flags & MSG_CTRUNC) f |= LINUX_MSG_CTRUNC;
if (bsd_flags & MSG_WAITALL) f |= LINUX_MSG_WAITALL;
if (bsd_flags & MSG_NOTIFICATION) PWRN("MSG_NOTIFICATION ignored");
if (bsd_flags & MSG_DONTWAIT) f |= LINUX_MSG_DONTWAIT;
if (bsd_flags & MSG_EOF) f |= LINUX_MSG_EOF;
if (bsd_flags & MSG_NBIO) PWRN("MSG_NBIO ignored");
if (bsd_flags & MSG_NOSIGNAL) f |= LINUX_MSG_NOSIGNAL;
if (bsd_flags & MSG_COMPAT) f |= LINUX_MSG_COMPAT;
if (bsd_flags & MSG_OOB) f |= LINUX_MSG_OOB;
if (bsd_flags & MSG_PEEK) f |= LINUX_MSG_PEEK;
if (bsd_flags & MSG_DONTROUTE) f |= LINUX_MSG_DONTROUTE;
if (bsd_flags & MSG_EOR) f |= LINUX_MSG_EOR;
if (bsd_flags & MSG_TRUNC) f |= LINUX_MSG_TRUNC;
if (bsd_flags & MSG_CTRUNC) f |= LINUX_MSG_CTRUNC;
if (bsd_flags & MSG_WAITALL) f |= LINUX_MSG_WAITALL;
if (bsd_flags & MSG_NOTIFICATION) Genode::warning("MSG_NOTIFICATION ignored");
if (bsd_flags & MSG_DONTWAIT) f |= LINUX_MSG_DONTWAIT;
if (bsd_flags & MSG_EOF) f |= LINUX_MSG_EOF;
if (bsd_flags & MSG_NBIO) Genode::warning("MSG_NBIO ignored");
if (bsd_flags & MSG_NOSIGNAL) f |= LINUX_MSG_NOSIGNAL;
if (bsd_flags & MSG_COMPAT) f |= LINUX_MSG_COMPAT;
return f;
}
@ -642,7 +640,7 @@ int Plugin::translate_ops_linux(int optname)
if (sockopts[i] == optname)
return i;
PERR("Unsupported sockopt %d\n", optname);
Genode::error("unsupported sockopt ", optname);
return -1;
}

View File

@ -12,7 +12,7 @@
*/
/* Genode */
#include <base/printf.h>
#include <base/log.h>
#include <util/string.h>
@ -37,7 +37,7 @@ extern "C" char *getenv(const char *name)
#if 0
#include <base/env.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/snprintf.h>
#include <dataspace/client.h>
#include <timer_session/connection.h>
@ -143,7 +143,7 @@ long int strtol(const char *nptr, char **endptr, int base)
{
long res = 0;
if (base != 0 && base != 10) {
PERR("strtol: base of %d is not supported", base);
Genode::error("strtol: base of ", base, " is not supported");
return 0;
}
Genode::ascii_to(nptr, res);

View File

@ -13,7 +13,7 @@
/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/snprintf.h>
#include <util/list.h>
#include <util/string.h>
@ -52,7 +52,7 @@ extern "C" {
static const bool trace = true;
#define TRACE() \
do { if (trace) \
PDBG("called from: %p", __builtin_return_address(0)); \
Genode::log("called from: ", __builtin_return_address(0)); \
} while (0)
@ -168,7 +168,7 @@ ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags,
{
Socket *s = Socket_registry::find(sockfd);
if (!s) {
PERR("sockfd %d not in registry", sockfd);
Genode::error("sockfd ", sockfd, " not in registry");
errno = EBADF;
return -1;
}
@ -203,8 +203,8 @@ ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
}
if (msg->msg_iovlen > Wifi::Msghdr::MAX_IOV_LEN) {
PERR("%s: %d exceeds maximum iov length (%d)",
__func__, msg->msg_iovlen, Wifi::Msghdr::MAX_IOV_LEN);
Genode::error(__func__, ": ", msg->msg_iovlen, " exceeds maximum iov "
"length (", (int)Wifi::Msghdr::MAX_IOV_LEN, ")");
errno = EINVAL;
return -1;
}
@ -257,18 +257,18 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
}
if (msg->msg_iovlen > Wifi::Msghdr::MAX_IOV_LEN) {
PERR("%s: %d exceeds maximum iov length (%d)",
__func__, msg->msg_iovlen, Wifi::Msghdr::MAX_IOV_LEN);
Genode::error(__func__, ": ", msg->msg_iovlen, " exceeds maximum iov "
"length (", (int)Wifi::Msghdr::MAX_IOV_LEN, ")");
errno = EINVAL;
return -1;
}
if (msg->msg_controllen != 0) {
PERR("%s: msg_control not supported", __func__);
Genode::error(__func__, ": msg_control not supported");
errno = EINVAL;
return -1;
}
if (flags != 0) {
PERR("%s: flags not supported", __func__);
Genode::error(__func__, ": flags not supported");
errno = EOPNOTSUPP;
return -1;
}
@ -437,7 +437,7 @@ int fcntl(int fd, int cmd, ... /* arg */ )
return 0;
}
default:
PWRN("fcntl: unknown request: %d", cmd);
Genode::warning("fcntl: unknown request: ", cmd);
break;
}

View File

@ -1,4 +1,4 @@
/**
/*
* \brief Dummy functions
* \author Sebastian Sumpf
* \date 2013-08-26
@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <base/sleep.h>
@ -28,40 +28,50 @@ enum {
#define DUMMY(retval, name) \
DUMMY name(void) { \
if (SHOW_DUMMY) \
PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \
return retval; \
}
if (SHOW_DUMMY) \
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"not implemented"); \
return retval; \
}
#define DUMMY_SKIP(retval, name) \
DUMMY name(void) { \
if (SHOW_SKIP) \
PLOG( #name " called (from %p) skipped", __builtin_return_address(0)); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"skipped"); \
return retval; \
}
#define DUMMY_RET(retval, name) \
DUMMY name(void) { \
if (SHOW_RET) \
PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"return ", retval); \
return retval; \
}
#define DUMMY_SHOW(retval, name) \
DUMMY name(void) { \
if (SHOW_SHOW) \
PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"return ", retval); \
return retval; \
}
#define DUMMY_STOP(retval, name) \
DUMMY name(void) { \
do { \
PWRN( #name " called (from %p) stopped", __builtin_return_address(0)); \
Genode::warning(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"stopped"); \
Genode::sleep_forever(); \
} while (0); \
return retval; \
}
}
/*

View File

@ -571,7 +571,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct io
__wsum next = csum_and_copy_from_user(iov->iov_base, kdata, copy_len, 0, &err);
if (err) {
PERR("%s: err: %d - sleeping", __func__, err);
Genode::error(__func__, ": err: ", err, " - sleeping");
Genode::sleep_forever();
}
@ -611,7 +611,7 @@ size_t csum_and_copy_to_iter(void *addr, size_t bytes, __wsum *csum, struct iov_
__wsum next = csum_and_copy_to_user(kdata, iov->iov_base, copy_len, 0, &err);
if (err) {
PERR("%s: err: %d - sleeping", __func__, err);
Genode::error(__func__, ": err: ", err, " - sleeping");
Genode::sleep_forever();
}

View File

@ -13,7 +13,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <nic/packet_allocator.h>
#include <nic_session/connection.h>
@ -140,7 +140,7 @@ void net_mac(void* mac, unsigned long size)
}
str[MAC_LEN] = 0;
PINF("Received mac: %s", str);
Genode::log("Received mac: ", Cstring(str));
}

View File

@ -14,7 +14,7 @@
/* Genode includes */
#include <base/env.h>
#include <base/signal.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/thread.h>
/* local includes */
@ -415,9 +415,6 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
void dispatch(unsigned num)
{
if (verbose)
PDBG("SOCKET dispatch %u", _call.opcode);
switch (_call.opcode) {
case OP_ACCEPT : _do_accept(); break;
@ -438,7 +435,7 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
default:
_handle.socket = 0;
PWRN("Unkown opcode: %u\n", _call.opcode);
Genode::warning("unkown opcode: ", (int)_call.opcode);
}
_unblock();

View File

@ -13,7 +13,7 @@
/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/tslab.h>
#include <os/server.h>
#include <timer_session/connection.h>
@ -233,7 +233,7 @@ class Lx::Timer
{
Context *ctx = _find_context(timer);
if (!ctx) {
PERR("schedule unknown timer %p", timer);
Genode::error("schedule unknown timer ", timer);
return -1; /* XXX better use 0 as rv? */
}

View File

@ -16,7 +16,7 @@
void tx_test() {
char *data = (char *)skb->data;
if (data[0x2a] == (char)0xaa && data[0x2b] == (char)0xbb) {
PDBG("Got server signal");
Genode::log("Got server signal");
static char data[1066];
static char header[] = {
0x00, 0x1c, 0x25, 0x9e, 0x92, 0x4a, 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01, 0x08, 0x00, 0x45, 0x00,

View File

@ -13,7 +13,6 @@
/* Genode includes */
#include <base/log.h>
#include <base/printf.h>
#include <base/sleep.h>
extern "C" {
@ -27,34 +26,41 @@ enum {
#define DUMMY(retval, name) \
DUMMY name(void) { \
if (SHOW_DUMMY) \
PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \
return retval; \
}
if (SHOW_DUMMY) \
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"not implemented"); \
return retval; \
}
#define DUMMY_SKIP(retval, name) \
DUMMY name(void) { \
if (SHOW_SKIP) \
Genode::log( #name " called (from ", __builtin_return_address(0), ") skipped"); \
return retval; \
}
#define DUMMY_STOP(retval, name) \
DUMMY name(void) { \
do { \
Genode::warning( #name " called (from ", __builtin_return_address(0), ") stopped"); \
Genode::sleep_forever(); \
} while (0); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"skipped"); \
return retval; \
}
#define DUMMY_RET(retval, name) \
DUMMY name(void) { \
if (SHOW_RET) \
Genode::warning( #name " called (from ", __builtin_return_address(0), ") return ", \
retval); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"return ", retval); \
return retval; \
}
#define DUMMY_STOP(retval, name) \
DUMMY name(void) { \
do { \
Genode::warning(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"stopped"); \
Genode::sleep_forever(); \
} while (0); \
return retval; \
}
/* return sucessful */
DUMMY_RET(0, netdev_kobject_init)

View File

@ -296,9 +296,6 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i)
iov++;
}
// PDBG("addr: %p bytes: %zu iov_base: %p iov_len: %zu len: %zu",
// addr, bytes, i->iov->iov_base, i->iov->iov_len, len);
return bytes;
}
@ -326,9 +323,6 @@ size_t copy_to_iter(void *addr, size_t bytes, struct iov_iter *i)
iov++;
}
// PDBG("addr: %p bytes: %zu iov_base: %p iov_len: %zu len: %zu",
// addr, bytes, i->iov->iov_base, i->iov->iov_len, len);
return bytes;
}

View File

@ -16,6 +16,7 @@
#include <base/log.h>
#include <base/rpc_server.h>
#include <base/snprintf.h>
#include <base/tslab.h>
#include <cap_session/connection.h>
#include <nic/xml_node.h>
#include <nic/component.h>

View File

@ -11,7 +11,7 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/printf.h>
#include <base/log.h>
extern "C" {
typedef long DUMMY;
@ -24,24 +24,30 @@ enum {
#define DUMMY(retval, name) \
DUMMY name(void) { \
if (SHOW_DUMMY) \
PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \
return retval; \
}
if (SHOW_DUMMY) \
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"not implemented"); \
return retval; \
}
#define DUMMY_SKIP(retval, name) \
DUMMY name(void) { \
if (SHOW_SKIP) \
PLOG( #name " called (from %p) skipped", __builtin_return_address(0)); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"skipped"); \
return retval; \
}
#define DUMMY_RET(retval, name) \
DUMMY name(void) { \
if (SHOW_RET) \
PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \
return retval; \
}
Genode::log(__func__, ": " #name " called " \
"(from ", __builtin_return_address(0), ") " \
"return ", retval); \
return retval; \
}
DUMMY(0, getprotobyname)
DUMMY(0, getprotobynumber)

View File

@ -11,8 +11,11 @@
* under the terms of the GNU General Public License version 2.
*/
/* compiler includes */
#include <stdarg.h>
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
/* libc includes */
#include <sys/sockio.h>
@ -40,7 +43,7 @@ int ioctl(int fd, unsigned long request, ...)
switch (request) {
case SIOCGIFADDR:
PERR("ioctl: request SIOCGIFADDR not implemented.");
Genode::error("ioctl: request SIOCGIFADDR not implemented.");
return -1;
case SIOCGIFINDEX:
ifr->ifr_ifindex = 1;
@ -50,7 +53,7 @@ int ioctl(int fd, unsigned long request, ...)
return 0;
}
PWRN("ioctl: request %lu not handled by switch", request);
Genode::warning("ioctl: request ", request, " not handled by switch");
return -1;
}

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <os/attached_rom_dataspace.h>
#include <os/reporter.h>
#include <util/string.h>
@ -52,7 +52,8 @@ extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s)
struct wpa_ssid *wpa_ssid = wpa_s->current_ssid;
/* FIXME ssid may contain any characters, even NUL */
Genode::String<SSID_MAX_LEN> ssid((char const*)wpa_ssid->ssid, wpa_ssid->ssid_len);
Genode::String<SSID_MAX_LEN>
ssid(Genode::Cstring((char *)wpa_ssid->ssid, wpa_ssid->ssid_len));
char bssid_buf[MAC_STR_LEN];
mac2str(bssid_buf, wpa_s->bssid);
@ -63,7 +64,7 @@ extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s)
xml.attribute("state", "connected");
});
});
} catch (...) { PWRN("could not report connected state"); }
} catch (...) { Genode::warning("could not report connected state"); }
}
@ -76,7 +77,8 @@ extern "C" void wpa_report_disconnect_event(struct wpa_supplicant *wpa_s)
struct wpa_ssid *wpa_ssid = wpa_s->current_ssid;
/* FIXME ssid may contain any characters, even NUL */
Genode::String<SSID_MAX_LEN> ssid((char const*)wpa_ssid->ssid, wpa_ssid->ssid_len);
Genode::String<SSID_MAX_LEN>
ssid(Genode::Cstring((char *)wpa_ssid->ssid, wpa_ssid->ssid_len));
char bssid_buf[MAC_STR_LEN];
mac2str(bssid_buf, wpa_ssid->bssid);
@ -88,7 +90,7 @@ extern "C" void wpa_report_disconnect_event(struct wpa_supplicant *wpa_s)
});
});
} catch (...) { PWRN("could not report disconnected state"); }
} catch (...) { Genode::warning("could not report disconnected state"); }
}
@ -124,7 +126,8 @@ extern "C" void wpa_report_scan_results(struct wpa_supplicant *wpa_s)
char bssid_buf[MAC_STR_LEN];
mac2str(bssid_buf, bss->bssid);
Genode::String<SSID_MAX_LEN> ssid((char const*)bss->ssid, bss->ssid_len);
Genode::String<SSID_MAX_LEN>
ssid(Genode::Cstring((char *)bss->ssid, bss->ssid_len));
int quality = approximate_quality(bss);
@ -139,5 +142,5 @@ extern "C" void wpa_report_scan_results(struct wpa_supplicant *wpa_s)
});
}
});
} catch (...) { PWRN("could not report scan results"); }
} catch (...) { Genode::warning("could not report scan results"); }
}

View File

@ -57,7 +57,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc,
bool _alloc_block()
{
if (_index == ELEMENTS) {
PERR("Slab-backend exhausted!");
Genode::error("slab backend exhausted!");
return false;
}
@ -114,7 +114,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc,
done = _alloc_block();
if (!done) {
PERR("Backend allocator exhausted\n");
Genode::error("backend allocator exhausted");
return false;
}
@ -154,7 +154,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc,
return _base + i * V_BLOCK_SIZE + phys - _ds_phys[i];
}
PWRN("virt_addr(0x%lx) - no translation", phys);
Genode::warning("virt_addr(", Genode::Hex(phys), ") - no translation");
return 0;
}
@ -273,13 +273,14 @@ class Lx_kit::Malloc : public Lx::Malloc
msb = SLAB_STOP_LOG2;
if (msb > SLAB_STOP_LOG2) {
PERR("Slab too large %u reqested %zu cached %d", 1U << msb, size, _cached);
Genode::error("slab too large ",
1UL << msb, "reqested ", size, " cached ", (int)_cached);
return 0;
}
addr_t addr = _allocator[msb - SLAB_START_LOG2]->alloc();
if (!addr) {
PERR("Failed to get slab for %u", 1 << msb);
Genode::error("failed to get slab for ", 1 << msb);
return 0;
}
@ -320,7 +321,7 @@ class Lx_kit::Malloc : public Lx::Malloc
{
void *addr;
if (!_back_allocator.alloc(size, &addr)) {
PERR("Large back end allocation failed (%zu bytes)", size);
Genode::error("large back end allocation failed (", size, " bytes)");
return nullptr;
}

View File

@ -96,8 +96,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size,
if (r->phys_range(phys_addr, size)) {
void * const virt = (void *)(r->virt() + phys_addr - r->phys());
PLOG("ioremap: return sub range phys 0x%lx (size %lx) to virt 0x%lx",
(long)phys_addr, (long)size, (long)virt);
log("ioremap: return sub range phys ", Hex(phys_addr), " "
"(size ", size, ") to virt ", virt);
return virt;
}
}
@ -108,8 +108,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size,
size, offset);
if (!ds_cap.valid()) {
PERR("Failed to request I/O memory: [%lx,%lx)", phys_addr,
phys_addr + size);
error("failed to request I/O memory: ",
Hex_range<addr_t>(phys_addr, size));
return nullptr;
}
@ -119,8 +119,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size,
ranges.insert(io_mem);
PLOG("ioremap: mapped phys 0x%lx (size %lx) to virt 0x%lx",
(long)phys_addr, (long)size, (long)io_mem->virt());
log("ioremap: mapped phys ", Hex(phys_addr), " (size ", size, ") "
"to virt ", Hex(io_mem->virt()));
return (void *)io_mem->virt();
}

View File

@ -1,5 +1,5 @@
/*
* \brief Linux kit memory allocator
* \brief Linux kit printf backend
* \author Sebastian Sumpf
* \date 2016-04-20
*/
@ -11,10 +11,6 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/console.h>
#include <base/printf.h>
/* local includes */
#include <lx_emul.h>
@ -26,7 +22,6 @@ namespace Lx {
extern "C" int stdout_write(const char *s);
static const bool verbose_console = false;
/**
* Format string command representation
@ -347,7 +342,7 @@ class Lx::Console
switch (cmd.type) {
case Format_command::INT:
if (cmd.length == Format_command::LONG_LONG)
_out_signed<long long>(numeric_arg, cmd.base);
else
@ -434,8 +429,6 @@ class Lx::Console
void lx_printf(char const *fmt, ...)
{
if (verbose_console)
PDBG("[%p] %s", __builtin_return_address(0), fmt);
va_list va;
va_start(va, fmt);
Lx::Console::c().vprintf(fmt, va);

View File

@ -16,13 +16,12 @@
/* Genode includes */
#include <base/env.h>
#include <base/lock.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/sleep.h>
#include <base/thread.h>
#include <timer_session/connection.h>
/* Linux emulation environment includes */
#include <lx_kit/internal/debug.h>
#include <lx_kit/scheduler.h>
#include <lx_kit/timer.h>
@ -84,7 +83,6 @@ class Lx_kit::Scheduler : public Lx::Scheduler
void entry()
{
PWRN("Scheduler::Logger is up");
_timer.msleep(1000 * _interval);
while (true) {
_scheduler.log_state("LOGGER");
@ -108,7 +106,7 @@ class Lx_kit::Scheduler : public Lx::Scheduler
Lx::Task *current() override
{
if (!_current) {
PERR("BUG: _current is zero!");
Genode::error("BUG: _current is zero!");
Genode::sleep_forever();
}
@ -168,7 +166,7 @@ class Lx_kit::Scheduler : public Lx::Scheduler
}
if (!at_least_one) {
PWRN("schedule() called without runnable tasks");
Genode::warning("schedule() called without runnable tasks");
log_state("SCHEDULE");
}
@ -181,9 +179,11 @@ class Lx_kit::Scheduler : public Lx::Scheduler
unsigned i;
Lx::Task *t;
for (i = 0, t = _present_list.first(); t; t = t->next(), ++i) {
Genode::printf("%s [%u] prio: %u state: %s%u%s %s\n",
prefix, i, t->priority(), _state_color(t->state()),
t->state(), _ansi_esc_reset(), t->name());
Genode::log(prefix, " [", i, "] "
"prio: ", (int)t->priority(), " "
"state: ", _state_color(t->state()), (int)t->state(),
_ansi_esc_reset(), " ",
t->name());
}
}
};
@ -202,7 +202,8 @@ Lx::Task::Task(void (*func)(void*), void *arg, char const *name,
scheduler.add(this);
if (verbose)
PDBG("name: '%s' func: %p arg: %p prio: %u t: %p", name, func, arg, priority, this);
Genode::log("name: '", name, "' " "func: ", func, " "
"arg: ", arg, " prio: ", (int)priority, " t: ", this);
}

View File

@ -250,7 +250,7 @@ class Lx_kit::Timer : public Lx::Timer
{
Context *ctx = _find_context(timer);
if (!ctx) {
PERR("schedule unknown timer %p", timer);
Genode::error("schedule unknown timer ", timer);
return -1; /* XXX better use 0 as rv? */
}

View File

@ -168,5 +168,5 @@ Lx::Work * Lx::Work::alloc_work_queue(Genode::Allocator *alloc, char const *name
void Lx::Work::free_work_queue(Lx::Work *w)
{
PERR("%s: IMPLEMENT ME", __func__);
Genode::error(__func__, ": IMPLEMENT ME");
}

View File

@ -1,4 +1,4 @@
/**
/*
* \brief PL2303-USB-UART driver that exposes a terminal session
* \author Sebastian Sumpf
* \date 2014-12-17
@ -11,6 +11,7 @@
* under the terms of the GNU General Public License version 2.
*/
#include <base/heap.h>
#include <os/attached_ram_dataspace.h>
#include <os/ring_buffer.h>
#include <os/server.h>
@ -18,7 +19,6 @@
#include <terminal_session/terminal_session.h>
#include <usb/usb.h>
constexpr bool verbose = false;
namespace Terminal {
class Main;
@ -111,7 +111,7 @@ struct Usb::Pl2303_driver : Completion
for (int i = 0; i < p.transfer.actual_size; i++)
ring_buffer.add(data[i]);
} catch (Ring_buffer::Overflow) {
PWRN("Pl2303 buffer overflow");
Genode::warning("Pl2303 buffer overflow");
}
/* submit back to device (async) */
@ -155,9 +155,9 @@ struct Usb::Pl2303_driver : Completion
enum { BUF = 128 };
char buffer[BUF];
PINF("PL2303 controller: ready");
PINF("Manufacturer : %s", device.manufactorer_string.to_char(buffer, BUF));
PINF("Product : %s", device.product_string.to_char(buffer, BUF));
Genode::log("PL2303 controller: ready");
Genode::log("Manufacturer : ", Cstring(device.manufactorer_string.to_char(buffer, BUF)));
Genode::log("Product : ", Cstring(device.product_string.to_char(buffer, BUF)));
Interface &iface = device.interface(0);
iface.claim();
@ -183,17 +183,9 @@ struct Usb::Pl2303_driver : Completion
/* set baud rate to 115200 */
pl2303_config *cfg = (pl2303_config *)iface.content(p);
if (verbose)
PDBG("GET_LINE %u %u %u %u\n",
cfg->baud, cfg->stop_bits, cfg->parity, cfg->data_bits);
pl2303_config cfg_new;
*cfg = cfg_new;
if (verbose)
PDBG("SET_LINE %u %u %u %u\n",
cfg_new.baud, cfg_new.stop_bits, cfg_new.parity, cfg_new.data_bits);
iface.control_transfer(p, 0x21, 0x20, 0, 0, 100);
iface.release(p);
@ -217,13 +209,8 @@ struct Usb::Pl2303_driver : Completion
*/
void state_change(unsigned)
{
if (connection.plugged()) {
if (verbose)
PDBG("Device: Plugged");
if (connection.plugged())
init();
}
else if (verbose)
PDBG("Device: Unplugged");
}
/**

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
/* libc includes */
#include <sys/types.h>
@ -35,7 +35,6 @@ static void serve(int fd) {
/* Read the data from the port, blocking if nothing yet there.
We assume the request (the part we care about) is in one packet */
buflen = recv(fd, buf, 1024, 0);
// PLOG("Packet received!");
/* Ignore all receive errors */
if (buflen > 0) {
@ -49,8 +48,6 @@ static void serve(int fd) {
buf[3] == ' ' &&
buf[4] == '/' ) {
// PLOG("Will send response");
/* Send http header */
send(fd, http_html_hdr, sizeof(http_html_hdr), 0);
@ -65,35 +62,35 @@ int main()
{
int s;
PLOG("Create new socket ...");
Genode::log("create new socket ...");
if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
PERR("No socket available!");
Genode::error("no socket available!");
return -1;
}
PLOG("Now, I will bind ...");
Genode::log("Now, I will bind ...");
struct sockaddr_in in_addr;
in_addr.sin_family = AF_INET;
in_addr.sin_port = htons(80);
in_addr.sin_addr.s_addr = INADDR_ANY;
if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
PERR("bind failed!");
Genode::error("bind failed!");
return -1;
}
PLOG("Now, I will listen ...");
Genode::log("Now, I will listen ...");
if(listen(s, 5)) {
PERR("listen failed!");
Genode::error("listen failed!");
return -1;
}
PLOG("Start the server loop ...");
Genode::log("Start the server loop ...");
while(true) {
struct sockaddr addr;
socklen_t len = sizeof(addr);
int client = accept(s, &addr, &len);
if(client < 0) {
PWRN("Invalid socket from accept!");
Genode::warning("invalid socket from accept!");
continue;
}
serve(client);

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
/* libc includes */
#include <sys/types.h>
@ -27,23 +27,23 @@ int main(void)
{
int s;
PLOG("Create new socket ...");
Genode::log("Create new socket ...");
if((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
PERR("No socket available!");
Genode::error("no socket available!");
return -1;
}
PLOG("Now, I will bind ...");
Genode::log("Now, I will bind ...");
struct sockaddr_in in_addr;
in_addr.sin_family = AF_INET;
in_addr.sin_port = htons(1337);
in_addr.sin_addr.s_addr = INADDR_ANY;
if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
PERR("bind failed!");
Genode::error("bind failed!");
return -1;
}
PLOG("Start the server loop ...");
Genode::log("Start the server loop ...");
while(true) {
struct sockaddr_in addr;
addr.sin_family = AF_INET;
@ -55,18 +55,18 @@ int main(void)
ssize_t n = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&addr, &len);
if (n == 0) {
PWRN("Invalid request!");
Genode::warning("Invalid request!");
continue;
}
if (n < 0) {
PERR("Error %lld", n);
Genode::error("Error ", n);
break;
}
PLOG("Received %lld bytes", n);
Genode::log("Received ", n, " bytes");
n = sendto(s, buf, n, 0, (struct sockaddr*)&addr, len);
PLOG("Send %lld bytes back", n);
Genode::log("Send ", n, " bytes back");
}
return 0;
}