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 @@
#include <block_session/connection.h>
#include <block/component.h>
#include <os/packet_allocator.h>
#include <os/server.h>
#include "chunk.h"
@ -165,10 +166,10 @@ class Driver : public Block::Driver
write(r->cli.block_number(), r->cli.block_count(),
r->buffer, r->cli);
} catch(Block::Driver::Request_congestion) {
Genode::warning("cli (", r->cli.block_number(),
" ", r->cli.block_count(),
") srv (", r->srv.block_number(),
" ", r->srv.block_count(), ")");
Genode::warning("cli (", r->cli.block_number(), " ",
r->cli.block_count(), ") "
"srv (", r->srv.block_number(), " ",
r->srv.block_count(), ")");
}
}
@ -215,7 +216,7 @@ class Driver : public Block::Driver
*/
void _request(Block::sector_t block_number,
Genode::size_t block_count,
char * const buffer,
char * const buffer,
Block::Packet_descriptor &packet)
{
Block::Packet_descriptor p_to_dev;

View File

@ -193,8 +193,8 @@ struct Clipboard::Main : Rom::Module::Read_policy, Rom::Module::Write_policy
if (_focused_domain.valid() && _domain(writer) == _focused_domain)
return true;
PWRN("unexpected attempt by '%s' to write to '%s'",
writer.label().string(), module.name().string());
warning("unexpected attempt by '", writer.label(), "' "
"to write to '", module.name(), "'");
return false;
}

View File

@ -12,13 +12,14 @@
*/
/* Genode includes */
#include <base/heap.h>
#include <os/path.h>
#include <file_system_session/connection.h>
#include <file_system/util.h>
#include <root/component.h>
#include <os/server.h>
#include <os/session_policy.h>
#include <base/printf.h>
#include <base/log.h>
/* Local includes */
#include "log_file.h"
@ -86,7 +87,7 @@ class Fs_log::Root_component :
&& policy.has_attribute("label_prefix")) {
if (!dir_path[1]) {
PERR("cannot merge an empty policy label");
Genode::error("cannot merge an empty policy label");
throw Root::Unavailable();
}
@ -151,7 +152,6 @@ class Fs_log::Root_component :
offset = _fs.status(handle).size;
} catch (File_system::Lookup_failed) {
PDBG("create");
handle = _fs.file(dir_handle, file_name,
File_system::WRITE_ONLY, true);
}
@ -162,22 +162,22 @@ class Fs_log::Root_component :
_log_files.insert(file);
} catch (Permission_denied) {
PERR("%s: permission denied", Path(file_name, dir_path).base());
error(Path(file_name, dir_path), ": permission denied");
} catch (No_space) {
PERR("file system out of space");
error("file system out of space");
} catch (Out_of_metadata) {
PERR("file system server out of metadata");
error("file system server out of metadata");
} catch (Invalid_name) {
PERR("%s: invalid path", Path(file_name, dir_path).base());
error(Path(file_name, dir_path), ": invalid path");
} catch (Name_too_long) {
PERR("%s: name too long", Path(file_name, dir_path).base());
error(Path(file_name, dir_path), ": name too long");
} catch (...) {
PERR("cannot open log file %s", Path(file_name, dir_path).base());
error("cannot open log file ", Path(file_name, dir_path));
throw;
}

View File

@ -67,7 +67,7 @@ class Fs_log::Unlabeled_session_component : public Session_component
size_t write(Log_session::String const &msg)
{
if (!msg.valid_string()) {
PERR("corrupted string");
Genode::error("corrupted string");
return 0;
}
@ -104,7 +104,7 @@ class Fs_log::Labeled_session_component : public Session_component
size_t write(Log_session::String const &msg)
{
if (!msg.valid_string()) {
PERR("corrupted string");
Genode::error("corrupted string");
return 0;
}

View File

@ -20,6 +20,7 @@
#include <base/component.h>
#include <base/session_label.h>
#include <util/arg_string.h>
#include <base/heap.h>
#include <base/log.h>

View File

@ -35,7 +35,7 @@ class Backing_store
{
virtual void detach_block(UMD umd)
{
PWRN("this should never be called");
Genode::warning(__func__, " this should never be called");
}
};
@ -187,7 +187,6 @@ class Backing_store
/* skip blocks that are currently in the process of being assigned */
while (_curr_block()->user() == &_not_yet_assigned) {
PDBG("skipping not-yet assigned block");
_advance_curr_block();
}

View File

@ -14,7 +14,7 @@
/* Genode includes */
#include <base/allocator_avl.h>
#include <base/exception.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/stdint.h>
#include <block_session/connection.h>
#include <util/misc_math.h>
@ -63,12 +63,12 @@ namespace Iso {
_p = _source->get_acked_packet();
if (!_p.succeeded()) {
PERR("Could not read block %lu", blk_nr);
Genode::error("Could not read block ", blk_nr);
throw Io_error();
}
} catch (Block::Session::Tx::Source::Packet_alloc_failed) {
PERR("Packet overrun!");
Genode::error("packet overrun!");
_p = _source->get_acked_packet();
throw Io_error();
}
@ -331,9 +331,6 @@ namespace Iso {
Sector sec(blk_nr, 1);
Volume_descriptor *vol = sec.addr<Volume_descriptor *>();
if (verbose)
PDBG("Volume: type %u", vol->type());
if (vol->primary())
return vol->copy_root_record();
@ -353,8 +350,6 @@ namespace Iso {
if (!root)
throw Non_data_disc();
if (verbose)
PDBG("Good root");
return root;
}
@ -371,9 +366,6 @@ namespace Iso {
unsigned long blk_count;
unsigned long blk_nr = info->blk_nr() + (file_offset / Sector::blk_size());
if (verbose)
PDBG("Read blk %lu count %lu, file_offset: %08lx length %u", blk_nr, total_blk_count, file_offset, length);
while ((blk_count = min<unsigned long>(Sector::MAX_SECTORS, total_blk_count))) {
Sector sec(blk_nr, blk_count);
@ -440,7 +432,7 @@ namespace Iso {
Directory_record *tmp = sec.addr<Directory_record *>()->locate(level);
if (!tmp && i == Sector::to_blk(dir->data_length()) - 1) {
PERR("File not found: %s", path);
Genode::error("file not found: ", Genode::Cstring(path));
throw File_not_found();
}
@ -449,9 +441,6 @@ namespace Iso {
dir = tmp;
current_blk_nr = dir->blk_nr();
if (verbose)
PDBG("Found %s", level);
if (!dir->directory()) {
blk_nr = current_blk_nr;
data_length = dir->data_length();
@ -466,13 +455,10 @@ namespace Iso {
/* Warning: Don't access 'dir' after this point, since the sector is gone */
if (!blk_nr && !data_length) {
PERR("File not found: %s", path);
Genode::error("file not found: ", Genode::Cstring(path));
throw File_not_found();
}
if (verbose)
PDBG("Path: %s Block nr: %u Length: %u", path, blk_nr, data_length);
return new(env()->heap()) File_info(blk_nr, data_length);
}

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <base/sleep.h>
#include <base/rpc_server.h>
#include <cap_session/connection.h>
@ -106,12 +106,12 @@ namespace Iso {
Rom_component(char *path)
{
if ((_file = File::scan_cache(path))) {
PINF("cache hit for file %s", path);
Genode::log("cache hit for file ", Genode::Cstring(path));
return;
}
_file = new(env()->heap()) File(path);
PINF("request for file %s", path);
Genode::log("request for file ", Genode::Cstring(path));
File::cache()->insert(_file);
}
@ -140,7 +140,7 @@ namespace Iso {
strncpy(_path, label.last_element().string(), sizeof(_path));
if (verbose)
PDBG("Request for file %s lrn %zu", _path, strlen(_path));
Genode::log("Request for file ", Cstring(_path), " len ", strlen(_path));
try {
return new (md_alloc()) Rom_component(_path);

View File

@ -98,7 +98,7 @@ namespace Loader {
snprintf(args, sizeof(args), "ram_quota=4K, label=\"%s\"", name);
return static_cap_cast<Rom_session>(_local_rom_service.session(args, Affinity()));
} catch (Genode::Parent::Service_denied) {
PERR("Lookup for ROM module \"%s\" failed", name);
Genode::error("Lookup for ROM module \"", name, "\" failed");
throw;
}
}

View File

@ -121,13 +121,13 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
case Command::OP_TO_BACK:
{
PDBG("OP_TO_BACK not implemented");
Genode::warning("OP_TO_BACK not implemented");
return;
}
case Command::OP_BACKGROUND:
{
PDBG("OP_BACKGROUND not implemented");
Genode::warning("OP_BACKGROUND not implemented");
return;
}

View File

@ -73,7 +73,7 @@ namespace Genode {
Rom_dataspace_capability fg_dataspace()
{
if (!_fg.size() && !_bg_has_pending_data) {
PERR("Error: no data loaded");
Genode::error("no data loaded");
return Rom_dataspace_capability();
}

View File

@ -16,6 +16,7 @@
#include <base/heap.h>
#include <base/env.h>
#include <base/session_label.h>
#include <base/printf.h>
#include <root/component.h>
#include <os/server.h>
#include <os/attached_ram_dataspace.h>

View File

@ -12,6 +12,7 @@
*/
/* Genode includes */
#include <base/heap.h>
#include <root/component.h>
#include <os/server.h>
#include <os/attached_ram_dataspace.h>
@ -50,7 +51,7 @@ class Buffered_output
_buf[_index] = 0;
/* flush buffered characters to LOG */
Genode::printf(_buf);
Genode::log(Genode::Cstring(_buf));
/* reset */
_index = 0;
@ -67,9 +68,10 @@ class Buffered_output
for (unsigned i = 0; i < consume_bytes; i++) {
char const c = src[i];
_buf[_index++] = c;
if (c == '\n')
_flush();
else
_buf[_index++] = c;
}
if (_remaining_capacity() == 0)

View File

@ -133,12 +133,12 @@ class File_system::Directory : public Node
size_t read(char *dst, size_t len, seek_off_t seek_offset)
{
if (len < sizeof(Directory_entry)) {
PERR("read buffer too small for directory entry");
Genode::error("read buffer too small for directory entry");
return 0;
}
if (seek_offset % sizeof(Directory_entry)) {
PERR("seek offset not aligned to sizeof(Directory_entry)");
Genode::error("seek offset not aligned to sizeof(Directory_entry)");
return 0;
}

View File

@ -12,6 +12,7 @@
*/
/* Genode includes */
#include <base/heap.h>
#include <file_system/node_handle_registry.h>
#include <file_system_session/rpc_object.h>
#include <root/component.h>
@ -96,7 +97,7 @@ class File_system::Session_component : public Session_rpc_object
_process_packet_op(packet, *node);
}
catch (Invalid_handle) { PERR("Invalid_handle"); }
catch (Invalid_handle) { Genode::error("Invalid_handle"); }
/*
* The 'acknowledge_packet' function cannot block because we
@ -138,7 +139,7 @@ class File_system::Session_component : public Session_rpc_object
static void _assert_valid_path(char const *path)
{
if (!path || path[0] != '/') {
PWRN("malformed path '%s'", path);
Genode::warning("malformed path '", path, "'");
throw Lookup_failed();
}
}
@ -204,7 +205,7 @@ class File_system::Session_component : public Session_rpc_object
Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create)
{
PERR("%s not implemented", __func__);
Genode::error(__func__, " not implemented");
return Symlink_handle();
}
@ -270,19 +271,19 @@ class File_system::Session_component : public Session_rpc_object
return s;
}
PERR("%s for symlinks not implemented", __func__);
Genode::error(__func__, " for symlinks not implemented");
return Status();
}
void control(Node_handle, Control)
{
PERR("%s not implemented", __func__);
Genode::error(__func__, " not implemented");
}
void unlink(Dir_handle, Name const &)
{
PERR("%s not implemented", __func__);
Genode::error(__func__, " not implemented");
}
void truncate(File_handle file_handle, file_size_t size)
@ -297,7 +298,7 @@ class File_system::Session_component : public Session_rpc_object
void move(Dir_handle, Name const &, Dir_handle, Name const &)
{
PERR("%s not implemented", __func__);
Genode::error(__func__, " not implemented");
}
void sigh(Node_handle node_handle, Signal_context_capability sigh)
@ -310,7 +311,7 @@ class File_system::Session_component : public Session_rpc_object
* reminder because besides testing, there is currently no
* use-case.
*/
void sync(Node_handle) override { PWRN("sync() not implemented!"); }
void sync(Node_handle) override { Genode::warning("sync() not implemented!"); }
};
@ -353,7 +354,8 @@ class File_system::Root : public Root_component<Session_component>
* lookup, we remove all leading slashes.
*/
if (root[0] != '/') {
PERR("Root directory must start with / but is \"%s\"", root);
Genode::error("Root directory must start with / but is \"",
Genode::Cstring(root), "\"");
throw Root::Unavailable();
}
@ -363,7 +365,7 @@ class File_system::Root : public Root_component<Session_component>
if (*root_dir == 0)
root_dir = ".";
} catch (Xml_node::Nonexistent_attribute) {
PERR("Missing \"root\" attribute in policy definition");
Genode::error("missing \"root\" attribute in policy definition");
throw Root::Unavailable();
}
@ -373,7 +375,7 @@ class File_system::Root : public Root_component<Session_component>
writeable = policy.attribute_value("writeable", false);
} catch (Session_policy::No_policy_defined) {
PERR("Invalid session request, no matching policy");
Genode::error("invalid session request, no matching policy");
throw Root::Unavailable();
}
@ -383,7 +385,7 @@ class File_system::Root : public Root_component<Session_component>
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0);
if (!tx_buf_size) {
PERR("%s requested a session with a zero length transmission buffer", label.string());
Genode::error(label, " requested a session with a zero length transmission buffer");
throw Root::Invalid_args();
}
@ -393,8 +395,8 @@ class File_system::Root : public Root_component<Session_component>
*/
size_t session_size = sizeof(Session_component) + tx_buf_size;
if (max((size_t)4096, session_size) > ram_quota) {
PERR("insufficient 'ram_quota', got %zd, need %zd",
ram_quota, session_size);
Genode::error("insufficient 'ram_quota', "
"got ", ram_quota, ", need ", session_size);
throw Root::Quota_exceeded();
}
@ -402,7 +404,8 @@ class File_system::Root : public Root_component<Session_component>
return new (md_alloc())
Session_component(tx_buf_size, _ep, root_dir, writeable, *md_alloc());
} catch (Lookup_failed) {
PERR("Session root directory \"%s\" does not exist", root);
Genode::error("session root directory \"", Genode::Cstring(root), "\" "
"does not exist");
throw Root::Unavailable();
}
}

View File

@ -39,7 +39,13 @@
static bool verbose = false;
#define PLOGV(...) do { if (verbose) PLOG(__VA_ARGS__); } while (0)
template <typename... ARGS>
static inline void logv(ARGS&&... args)
{
if (verbose)
Genode::log(args...);
}
typedef Mixer::Channel Channel;
@ -235,7 +241,7 @@ class Audio_out::Mixer
});
});
});
} catch (...) { PWRN("could report current channels"); }
} catch (...) { Genode::warning("could report current channels"); }
}
/*
@ -426,12 +432,12 @@ class Audio_out::Mixer
v = default_node.attribute_value<long>("muted", 1);
_default_muted = v ;
PLOGV("default settings: out_volume: %d volume: %d muted: %d",
(int)(MAX_VOLUME*_default_out_volume),
(int)(MAX_VOLUME*_default_volume),
_default_muted);
logv("default settings: "
"out_volume: ", (int)(MAX_VOLUME*_default_out_volume), " "
"volume: ", (int)(MAX_VOLUME*_default_volume), " "
"muted: ", _default_muted);
} catch (...) { PWRN("could not read mixer default values"); }
} catch (...) { Genode::warning("could not read mixer default values"); }
}
/**
@ -470,9 +476,10 @@ class Audio_out::Mixer
session.volume = (float)ch.volume / MAX_VOLUME;
session.muted = ch.muted;
PLOGV("label: '%s' nr: %d vol: %d muted: %d",
ch.label.string(), (int)ch.number,
(int)(MAX_VOLUME*session.volume), ch.muted);
logv("label: '", ch.label, "' "
"nr: ", (int)ch.number, " "
"vol: ", (int)(MAX_VOLUME*session.volume), " "
"muted: ", ch.muted);
});
});
}
@ -482,13 +489,14 @@ class Audio_out::Mixer
_out_volume[i] = (float)ch.volume / MAX_VOLUME;
PLOGV("label: '%s' nr: %d vol: %d muted: %d",
"master", (int)ch.number,
(int)(MAX_VOLUME*_out_volume[i]), ch.muted);
logv("label: 'master' "
"nr: ", (int)ch.number, " "
"vol: ", (int)(MAX_VOLUME*_out_volume[i]), " "
"muted: ", ch.muted);
});
}
});
} catch (...) { PWRN("mixer channel_list was invalid"); }
} catch (...) { Genode::warning("mixer channel_list was invalid"); }
/*
* Report back any changes so a front-end can update its state
@ -557,10 +565,11 @@ class Audio_out::Mixer
session.volume = _default_volume;
session.muted = _default_muted;
PLOG("add label: \"%s\" channel: \"%s\" nr: %u volume: %d muted: %d",
session.label.string(), string_from_number(ch), ch,
(int)(MAX_VOLUME*session.volume), session.muted);
log("add label: \"", session.label, "\" "
"channel: \"", string_from_number(ch), "\" "
"nr: ", (int)ch, " "
"volume: ", (int)(MAX_VOLUME*session.volume), " "
"muted: %d", session.muted);
_channels[ch].insert(&session);
_report_channels();
@ -571,8 +580,9 @@ class Audio_out::Mixer
*/
void remove_session(Channel::Number ch, Session_elem &session)
{
PLOG("remove label: \"%s\" channel: \"%s\" nr: %u",
session.label.string(), string_from_number(ch), ch);
log("remove label: \"", session.label, "\" "
"channel: \"", string_from_number(ch), "\" "
"nr: ", (int)ch);
_channels[ch].remove(&session);
_report_channels();
@ -665,8 +675,8 @@ class Audio_out::Root : public Audio_out::Root_component
if ((ram_quota < session_size) ||
(sizeof(Stream) > ram_quota - session_size)) {
PERR("insufficient 'ram_quota', got %zu, need %zu",
ram_quota, sizeof(Stream) + session_size);
Genode::error("insufficient 'ram_quota', got ", ram_quota, ", "
"need ", sizeof(Stream) + session_size);
throw Root::Quota_exceeded();
}
@ -714,7 +724,6 @@ struct Server::Main
Main(Server::Entrypoint &ep) : ep(ep)
{
Genode::env()->parent()->announce(ep.manage(root));
PINF("--- Mixer started ---");
}
};

View File

@ -125,7 +125,7 @@ void Nic::Loopback_component::_handle_packet_stream()
/* obtain packet */
Packet_descriptor const packet_from_client = _tx.sink()->get_packet();
if (!packet_from_client.size()) {
PWRN("received zero-size packet");
Genode::warning("received zero-size packet");
_rx.source()->release_packet(packet_to_client);
continue;
}
@ -170,8 +170,8 @@ class Nic::Root : public Genode::Root_component<Loopback_component>
*/
if (tx_buf_size + rx_buf_size < tx_buf_size ||
tx_buf_size + rx_buf_size > ram_quota - session_size) {
PERR("insufficient 'ram_quota', got %zd, need %zd",
ram_quota, tx_buf_size + rx_buf_size + session_size);
Genode::error("insufficient 'ram_quota', got ", ram_quota, ", "
"need ", tx_buf_size + rx_buf_size + session_size);
throw Root::Quota_exceeded();
}

View File

@ -16,6 +16,7 @@
#include <base/log.h>
#include <base/component.h>
#include <base/allocator_guard.h>
#include <base/heap.h>
#include <base/attached_ram_dataspace.h>
#include <base/attached_rom_dataspace.h>
#include <input/event.h>

View File

@ -18,6 +18,7 @@
#include <base/allocator_avl.h>
#include <base/signal.h>
#include <base/tslab.h>
#include <base/heap.h>
#include <util/list.h>
#include <block_session/connection.h>

View File

@ -178,7 +178,7 @@ struct Main
try {
if (use_file) {
Genode::log("Creating RAM-basd block device populated by file='",
(char const*)file, "' with block size ", block_size);
Genode::Cstring(file), "' with block size ", block_size);
return new (&alloc) Ram_blk(env, alloc, file, block_size);
} else {
Genode::log("Creating RAM-based block device with size ",

View File

@ -14,6 +14,7 @@
/* Genode includes */
#include <file_system/node_handle_registry.h>
#include <file_system_session/rpc_object.h>
#include <base/heap.h>
#include <root/component.h>
#include <os/attached_rom_dataspace.h>
#include <os/config.h>
@ -94,7 +95,7 @@ namespace File_system {
_process_packet_op(packet, *node);
}
catch (Invalid_handle) { PERR("Invalid_handle"); }
catch (Invalid_handle) { Genode::error("Invalid_handle"); }
/*
* The 'acknowledge_packet' function cannot block because we
@ -136,7 +137,7 @@ namespace File_system {
static void _assert_valid_path(char const *path)
{
if (!path || path[0] != '/') {
PWRN("malformed path '%s'", path);
Genode::warning("malformed path ''", path, "'");
throw Lookup_failed();
}
}
@ -459,10 +460,11 @@ namespace File_system {
session_root_dir->unlock();
}
} catch (Xml_node::Nonexistent_attribute) {
PERR("Missing \"root\" attribute in policy definition");
Genode::error("missing \"root\" attribute in policy definition");
throw Root::Unavailable();
} catch (Lookup_failed) {
PERR("Session root directory \"%s\" does not exist", root);
Genode::error("session root directory \"",
Genode::Cstring(root), "\" does not exist");
throw Root::Unavailable();
}
@ -472,7 +474,7 @@ namespace File_system {
writeable = policy.attribute_value("writeable", false);
} catch (Session_policy::No_policy_defined) {
PERR("Invalid session request, no matching policy");
Genode::error("invalid session request, no matching policy");
throw Root::Unavailable();
}
@ -482,7 +484,7 @@ namespace File_system {
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0);
if (!tx_buf_size) {
PERR("%s requested a session with a zero length transmission buffer", label.string());
Genode::error(label, " requested a session with a zero length transmission buffer");
throw Root::Invalid_args();
}
@ -492,8 +494,8 @@ namespace File_system {
*/
size_t session_size = sizeof(Session_component) + tx_buf_size;
if (max((size_t)4096, session_size) > ram_quota) {
PERR("insufficient 'ram_quota', got %zd, need %zd",
ram_quota, session_size);
Genode::error("insufficient 'ram_quota', got ", ram_quota, ", "
"need ", session_size);
throw Root::Quota_exceeded();
}
return new (md_alloc())
@ -548,13 +550,16 @@ struct Attribute_string
} else {
char type_name[16];
node.type_name(type_name, sizeof(type_name));
PWRN("missing \"%s\" attribute in <%s> node", attr, type_name);
Genode::warning("missing \"", attr, "\" attribute in "
"<", Genode::Cstring(type_name), "> node");
throw Genode::Xml_node::Nonexistent_attribute();
}
}
}
operator char * () { return buf; }
void print(Genode::Output &out) const { Genode::print(out, Genode::Cstring(buf)); }
};
@ -602,9 +607,9 @@ static void preload_content(Genode::Allocator &alloc,
dir.adopt_unsynchronized(file);
}
catch (Rom_connection::Rom_connection_failed) {
PWRN("failed to open ROM file \"%s\"", (char *)name); }
Genode::warning("failed to open ROM file \"", name, "\""); }
catch (Rm_session::Attach_failed) {
PWRN("Could not locally attach ROM file \"%s\"", (char *)name); }
Genode::warning("Could not locally attach ROM file \"", name, "\""); }
}
/*

View File

@ -137,7 +137,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
catch (Session_policy::No_policy_defined) { }
}
warning("no valid policy for ROM request '", rom_label.string(), "'");
warning("no valid policy for ROM request '", rom_label, "'");
throw Root::Invalid_args();
}

View File

@ -102,13 +102,12 @@ struct Main
}
catch (...) { }
log("Using file=", file, " as device with block size ",
blk_sz, ".");
log("Using file=", file, " as device with block size ", blk_sz, ".");
try {
return new (&heap) Rom_blk(env, file, blk_sz);
} catch(Rom_connection::Rom_connection_failed) {
error("Cannot open file ", file, ".");
error("cannot open file ", file);
}
throw Root::Unavailable();
}

View File

@ -191,8 +191,8 @@ class Rom_filter::Input_rom_registry
if (content_node.has_type(expected.string()))
return _query_value(input_node.sub_node(), content_node);
else
PWRN("top-level node <%s> missing in input ROM %s",
expected.string(), name().string());
Genode::warning("top-level node <", expected, "> "
"missing in input ROM ", name());
} catch (...) { }

View File

@ -266,7 +266,7 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml)
condition_satisfied = true;
}
catch (Input_rom_registry::Nonexistent_input_value) {
PWRN("could not obtain input value for input %s", input_name.string());
Genode::warning("could not obtain input value for input ", input_name);
}
}
@ -313,7 +313,7 @@ void Rom_filter::Main::_evaluate()
Xml_node output = Genode::config()->xml_node().sub_node("output");
if (!output.has_attribute("node")) {
PERR("missing 'node' attribute in '<output>' node");
Genode::error("missing 'node' attribute in '<output>' node");
return;
}

View File

@ -17,9 +17,10 @@
#include <root/component.h>
#include <dataspace/client.h>
#include <base/rpc_server.h>
#include <base/printf.h>
#include <base/log.h>
#include <base/env.h>
#include <base/sleep.h>
#include <base/heap.h>
#include <os/config.h>
#include <timer_session/connection.h>
#include <base/session_label.h>
@ -125,10 +126,10 @@ int main(int argc, char **argv)
try {
Rom_connection rom(name);
PINF("prefetching ROM file %s", name);
log("prefetching ROM module ", Cstring(name));
prefetch_dataspace(rom.dataspace());
} catch (...) {
PERR("could not open ROM file %s", name);
error("could not open ROM module ", Cstring(name));
}
/* proceed with next XML node */

View File

@ -20,7 +20,8 @@
#include <base/rpc_server.h>
#include <base/sleep.h>
#include <base/env.h>
#include <base/printf.h>
#include <base/heap.h>
#include <base/log.h>
#include <os/config.h>
#include <base/session_label.h>
@ -115,7 +116,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
}
if (!file_found) {
PERR("couldn't find file '%s', empty result", _filename);
Genode::error("couldn't find file '", _filename, "', empty result");
return Genode::Ram_dataspace_capability();
}
@ -127,7 +128,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
/* get content of file copied into dataspace and return */
_copy_content_to_dataspace(file_ds);
} catch (...) {
PERR("couldn't allocate memory for file, empty result\n");
Genode::error("couldn't allocate memory for file, empty result");
return file_ds;
}
@ -186,7 +187,7 @@ class Rom_root : public Genode::Root_component<Rom_session_component>
Session_label const label = label_from_args(args);
Session_label const module_name = label.last_element();
PINF("connection for module '%s' requested", module_name.string());
Genode::log("connection for module '", module_name, "' requested");
/* create new session for the requested file */
return new (md_alloc()) Rom_session_component(_tar_addr, _tar_size,
@ -225,7 +226,7 @@ int main(void)
config()->xml_node().sub_node("archive");
archive_node.attribute("name").value(tar_filename, sizeof(tar_filename));
} catch (...) {
PERR("Could not read 'filename' argument from config");
Genode::error("could not read 'filename' argument from config");
return -1;
}
@ -237,11 +238,11 @@ int main(void)
tar_base = env()->rm_session()->attach(tar_rom.dataspace());
tar_size = Dataspace_client(tar_rom.dataspace()).size();
} catch (...) {
PERR("Could not obtain tar archive from ROM service");
Genode::error("could not obtain tar archive from ROM service");
return -2;
}
PINF("using tar archive '%s' with size %zd", tar_filename, tar_size);
Genode::log("using tar archive '", Cstring(tar_filename), "' with size ", tar_size);
/* connection to capability service needed to create capabilities */
static Cap_connection cap;

View File

@ -57,7 +57,7 @@ namespace Genode {
size_t write(String const &string_buf)
{
if (!(string_buf.valid_string())) {
PERR("corrupted string");
Genode::error("corrupted string");
return 0;
}

View File

@ -70,8 +70,6 @@ namespace File_system {
*/
void discard_unsynchronized(Node *node)
{
/* PWRN("discard node '%s' from '%s'", node->name(), Node::name()); */
_entries.remove(node);
_num_entries--;
@ -165,14 +163,14 @@ namespace File_system {
size_t read(char *dst, size_t len, seek_off_t seek_offset)
{
if (len < sizeof(Directory_entry)) {
PERR("read buffer too small for directory entry");
Genode::error("read buffer too small for directory entry");
return 0;
}
seek_off_t index = seek_offset / sizeof(Directory_entry);
if (seek_offset % sizeof(Directory_entry)) {
PERR("seek offset not alighed to sizeof(Directory_entry)");
Genode::error("seek offset not alighed to sizeof(Directory_entry)");
return 0;
}

View File

@ -173,7 +173,7 @@ namespace File_system {
if (seek_offset + len >= Chunk_level_0::SIZE) {
len = (Chunk_level_0::SIZE-1) - seek_offset;
PERR("%s: size limit %d reached", name(), Chunk_level_0::SIZE);
Genode::error(name(), ": size limit ", (long)Chunk_level_0::SIZE, " reached");
}
_chunk.write(src, len, (size_t)seek_offset);

View File

@ -20,6 +20,7 @@
#include <os/server.h>
#include <os/session_policy.h>
#include <root/component.h>
#include <base/heap.h>
#include <timer_session/connection.h>
#include <trace_session/connection.h>
#include <util/list.h>
@ -34,9 +35,6 @@
#include <trace_files.h>
static bool const verbose = false;
#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__)
/**
* Return true if 'str' is a valid file name
*/
@ -261,8 +259,6 @@ class Trace_file_system
if (!manager)
return;
PDBGV("update events for subject:'%s'", subject->name());
Process_entry<512> process_entry;
while (!manager->last_entry()) {
@ -272,7 +268,7 @@ class Trace_file_system
continue;
try { subject->events_file.append(process_entry.data(), len); }
catch (...) { PERR("could not write entry"); }
catch (...) { Genode::error("could not write entry"); }
}
if (manager->last_entry()) {
@ -287,14 +283,12 @@ class Trace_file_system
*/
void _disable_tracing(Followed_subject *subject)
{
PDBGV("disable tracing of subject:'%s'", subject->name());
subject->active_file.set_inactive();
_trace.pause(subject->id());
_gather_events(subject);
try { subject->unmanage_trace_buffer(); }
catch (...) { PERR("trace buffer was not managed"); }
catch (...) { Genode::error("trace buffer was not managed"); }
_trace.free(subject->id());
}
@ -305,18 +299,15 @@ class Trace_file_system
*/
void _enable_tracing(Followed_subject *subject)
{
PDBGV("activate tracing of subject:'%s' with policy:'%u' and buffer_size:'%lu'",
subject->name(), subject->policy_id().id, subject->buffer_size_file.size());
try {
_trace.trace(subject->id().id, subject->policy_id().id,
subject->buffer_size_file.size());
try { subject->manage_trace_buffer(_trace.buffer(subject->id())); }
catch (...) { PERR("trace buffer is already managed"); }
catch (...) { Genode::error("trace buffer is already managed"); }
subject->active_file.set_active();
} catch (...) { PERR("could not enable tracing"); }
} catch (...) { Genode::error("could not enable tracing"); }
}
/**
@ -335,16 +326,13 @@ class Trace_file_system
Directory *child;
PDBGV("parent '%s' num_entries '%zu' lookup '%s'", parent.name(),
parent.num_entries(), walker.element());
try { child = _node_to_directory(parent.lookup(walker.element())); }
catch (File_system::Lookup_failed) {
try {
child = new (&_alloc) Directory(walker.element());
parent.adopt_unsynchronized(child);
} catch (...) {
PERR("could not create '%s'", walker.element());
Genode::error("could not create '", walker.element(), "'");
return 0;
}
}
@ -456,12 +444,12 @@ class Trace_file_system
size_t n = policy_file->read((char *)ram, policy_length, 0UL);
if (n != policy_length) {
PERR("error while copying policy content");
Genode::error("error while copying policy content");
} else { subject->policy_id(id); }
Genode::env()->rm_session()->detach(ram);
}
} catch (...) { PERR("could not allocate policy"); }
} catch (...) { Genode::error("could not allocate policy"); }
}
policy_changed = true;
@ -522,9 +510,6 @@ class Trace_file_system
Subject_info info = _trace.subject_info(subjects[i]);
Subject_info::State state = info.state();
PDBGV("subject:'%s.%u' state:'%u'", info.thread_name().string(),
subjects[i].id, state);
/* opt-out early */
switch (state) {
case Subject_info::State::INVALID:
@ -563,7 +548,7 @@ class Trace_file_system
Directory *parent = _find_parent_node(list, walker, _root_dir);
if (!parent) {
PERR("could not find parent node for label:'%s'", label);
Genode::error("could not find parent node for label:'", label, "'");
continue;
}
@ -598,7 +583,7 @@ class Trace_file_system
Util::Label_walker walker(label);
Directory *parent = _find_parent_node(list, walker, _root_dir);
if (!parent) {
PERR("could not find parent node on creation");
Genode::error("could not find parent node on creation");
continue;
}
@ -647,7 +632,6 @@ class File_system::Session_component : public Session_rpc_object
*/
void _fs_update(unsigned)
{
PDBGV("trace_fs update, limit:%d", _subject_limit);
_trace_fs->update(_subject_limit);
}
@ -699,7 +683,7 @@ class File_system::Session_component : public Session_rpc_object
_process_packet_op(packet, *node);
}
catch (Invalid_handle) { PERR("Invalid_handle"); }
catch (Invalid_handle) { Genode::error("Invalid_handle"); }
/*
* The 'acknowledge_packet' function cannot block because we
@ -741,7 +725,7 @@ class File_system::Session_component : public Session_rpc_object
static void _assert_valid_path(char const *path)
{
if (!path || path[0] != '/') {
PWRN("malformed path '%s'", path);
Genode::warning("malformed path '", path, "'");
throw Lookup_failed();
}
}
@ -827,7 +811,7 @@ class File_system::Session_component : public Session_rpc_object
Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create)
{
PWRN("symlinks not supported");
Genode::warning("symlinks not supported");
return Symlink_handle();
}
@ -867,7 +851,7 @@ class File_system::Session_component : public Session_rpc_object
try { node = _handle_registry.lookup(handle); }
catch (Invalid_handle) {
PERR("close() called with invalid handle");
Genode::error("close() called with invalid handle");
return;
}
@ -985,15 +969,16 @@ class File_system::Root : public Root_component<Session_component>
if (root[0] != '/')
throw Lookup_failed();
} catch (Xml_node::Nonexistent_attribute) {
PERR("Missing \"root\" attribute in policy definition");
Genode::error("Missing \"root\" attribute in policy definition");
throw Root::Unavailable();
} catch (Lookup_failed) {
PERR("Session root directory \"%s\" does not exist", root);
Genode::error("session root directory "
"\"", Genode::Cstring(root), "\" does not exist");
throw Root::Unavailable();
}
} catch (Session_policy::No_policy_defined) {
PERR("Invalid session request, no matching policy");
Genode::error("Invalid session request, no matching policy");
throw Root::Unavailable();
}
@ -1003,7 +988,7 @@ class File_system::Root : public Root_component<Session_component>
Arg_string::find_arg(args, "tx_buf_size").ulong_value(0);
if (!tx_buf_size) {
PERR("%s requested a session with a zero length transmission buffer", label.string());
Genode::error(label, " requested a session with a zero length transmission buffer");
throw Root::Invalid_args();
}
@ -1013,8 +998,8 @@ class File_system::Root : public Root_component<Session_component>
*/
size_t session_size = sizeof(Session_component) + tx_buf_size;
if (max((size_t)4096, session_size) > ram_quota) {
PERR("insufficient 'ram_quota', got %zd, need %zd",
ram_quota, session_size);
Genode::error("insufficient 'ram_quota', got ", ram_quota, ", "
"need ", session_size);
throw Root::Quota_exceeded();
}
return new (md_alloc())

View File

@ -323,7 +323,7 @@ namespace File_system {
size_t read(char *dst, size_t len, seek_off_t seek_offset)
{
if (len > 32) {
PERR("len:'%zu' to small", len);
Genode::error("len:'", len, "' to small");
return 0;
}

View File

@ -237,7 +237,7 @@ class Device_registry
Device_registry()
{
try { _init(); }
catch(...) { PERR("blk: config parsing error"); }
catch(...) { Genode::error("blk: config parsing error"); }
}
public:
@ -353,7 +353,7 @@ void Vmm::Block::_name(Vm_base * const vm)
strncpy((char *)_buf, dev->name(), _buf_size);
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
}
}
@ -366,7 +366,7 @@ void Vmm::Block::_block_count(Vm_base * const vm)
vm->smc_ret(dev->block_count());
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(0);
}
}
@ -380,7 +380,7 @@ void Vmm::Block::_block_size(Vm_base * const vm)
vm->smc_ret(dev->block_size());
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(0);
}
}
@ -394,7 +394,7 @@ void Vmm::Block::_queue_size(Vm_base * const vm)
vm->smc_ret(dev->session()->tx()->bulk_buffer_size());
return;
} catch (Device_registry::Bad_device_id) { PERR("Bad block device ID"); }
} catch (Device_registry::Bad_device_id) { Genode::error("bad block device ID"); }
vm->smc_ret(0);
}
@ -407,7 +407,7 @@ void Vmm::Block::_writeable(Vm_base * const vm)
vm->smc_ret(dev->writeable());
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(0);
}
}
@ -421,7 +421,7 @@ void Vmm::Block::_irq(Vm_base * const vm)
vm->smc_ret(dev->irq());
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(0);
}
}
@ -440,7 +440,7 @@ void Vmm::Block::_buffer(Vm_base * const vm)
buf_err |= buf_base < ram->base();
buf_err |= buf_top >= ram_top;
if (buf_err) {
PERR("Illegal block buffer constraints");
Genode::error("illegal block buffer constraints");
return;
}
addr_t const buf_off = buf_base - ram->base();
@ -472,15 +472,15 @@ void Vmm::Block::_new_request(Vm_base * const vm)
vm->smc_ret((long)addr, p.offset());
} catch (Request_cache::Full) {
PERR("Block request cache full");
Genode::error("block request cache full");
vm->smc_ret(0, 0);
} catch (::Block::Session::Tx::Source::Packet_alloc_failed) {
PERR("Failed to allocate packet for block request");
Genode::error("failed to allocate packet for block request");
vm->smc_ret(0, 0);
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(0, 0);
}
}
@ -513,10 +513,10 @@ void Vmm::Block::_submit_request(Vm_base * const vm)
dev->session()->tx()->submit_packet(p);
} catch (Oversized_request) {
PERR("Oversized block request");
Genode::error("oversized block request");
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
}
}
@ -556,11 +556,11 @@ void Vmm::Block::_collect_reply(Vm_base * const vm)
vm->smc_ret(1);
} catch (Oversized_request) {
PERR("Oversized block request");
Genode::error("oversized block request");
vm->smc_ret(-1);
} catch (Device_registry::Bad_device_id) {
PERR("Bad block device ID");
Genode::error("bad block device ID");
vm->smc_ret(-1);
}
}
@ -596,7 +596,7 @@ void Vmm::Block::handle(Vm_base * const vm)
case BUFFER: _buffer(vm); break;
case NAME: _name(vm); break;
default:
PERR("Unknown function %lu requested on VMM block", vm->smc_arg_1());
Genode::error("Unknown function ", vm->smc_arg_1(), " requested on VMM block");
break;
}
}

View File

@ -62,7 +62,7 @@ class Mmu
Genode::addr_t _supersection(Genode::addr_t fe, Genode::addr_t va)
{
PWRN("Not implemented yet!");
Genode::warning(__func__, " not implemented yet!");
return 0;
}

View File

@ -15,6 +15,7 @@
#define _SRC__SERVER__VMM__INCLUDE__VM_H_
/* Genode includes */
#include <base/printf.h>
#include <dataspace/client.h>
#include <io_mem_session/connection.h>
#include <rom_session/connection.h>

View File

@ -28,7 +28,7 @@ void Serial::_push(char const c)
void Serial::_flush()
{
_push(0);
printf("[vm] %s\n", local_addr<char>());
log("[vm] ", local_addr<char const>());
_off = 0;
}
@ -48,7 +48,7 @@ void Serial::handle(Vm_base * const vm)
switch (vm->smc_arg_1()) {
case SEND: _send(vm); break;
default:
PERR("Unknown function %lu requested on VMM serial", vm->smc_arg_1());
Genode::error("Unknown function ", vm->smc_arg_1(), " requested on VMM serial");
break;
}
}

View File

@ -71,7 +71,7 @@ class Vmm::Vmm : public Thread_deprecated<8192>
case SERIAL: _serial.handle(_vm); break;
case BLOCK: _block.handle(_vm); break;
default:
PERR("Unknown hypervisor call!");
Genode::error("unknown hypervisor call!");
_vm->dump();
};
}
@ -88,7 +88,7 @@ class Vmm::Vmm : public Thread_deprecated<8192>
switch (_vm->state()->cpu_exception) {
case Cpu_state::DATA_ABORT:
if (!_handle_data_abort()) {
PERR("Could not handle data-abort will exit!");
Genode::error("could not handle data-abort will exit!");
return false;
}
break;
@ -96,7 +96,7 @@ class Vmm::Vmm : public Thread_deprecated<8192>
_handle_hypervisor_call();
break;
default:
PERR("Curious exception occured");
Genode::error("curious exception occured");
_vm->dump();
return false;
}
@ -118,7 +118,7 @@ class Vmm::Vmm : public Thread_deprecated<8192>
if (_handle_vm())
_vm->run();
} else {
PWRN("Invalid context");
Genode::warning("invalid context");
continue;
}
on_vmm_exit();
@ -146,7 +146,7 @@ int main()
KERNEL_OFFSET, MACH_TYPE_QSB);
static Vmm::Vmm vmm(&vm);
PINF("Start virtual machine ...");
Genode::log("Start virtual machine ...");
vmm.start();
sleep_forever();

View File

@ -13,6 +13,7 @@
/* Genode includes */
#include <file_system_session/rpc_object.h>
#include <base/heap.h>
#include <ram_session/connection.h>
#include <root/component.h>
#include <vfs/dir_file_system.h>
@ -39,7 +40,7 @@ namespace Vfs_server {
{
try { return Genode::config()->xml_node().sub_node("vfs"); }
catch (...) {
Genode::error("vfs not configured");
Genode::error("VFS not configured");
Genode::env()->parent()->exit(~0);
Genode::sleep_forever();
}

View File

@ -111,7 +111,7 @@ struct Vfs_server::Symlink : Node
size_t write(Vfs::File_system &vfs, char const *src, size_t len, seek_off_t seek_offset)
{
/* ensure symlink gets something null-terminated */
Genode::String<MAX_PATH_LEN> target(src, len);
Genode::String<MAX_PATH_LEN> target(Genode::Cstring(src, len));
if (vfs.symlink(target.string(), path()) == Directory_service::SYMLINK_OK)
return 0;

View File

@ -165,7 +165,7 @@ class Vm {
Exception() : Exception("undefined") {}
void print() { PERR("%s", _buf); }
void print() { Genode::error(Genode::Cstring(_buf)); }
};
@ -177,7 +177,9 @@ class Vm {
_ram(RAM_ADDRESS, ram_size, (Genode::addr_t)_vm_ram.local_addr<void>()),
_state((State*)Genode::env()->rm_session()->attach(_vm_con.cpu_state()))
{
PINF("ram is at %lx", Genode::Dataspace_client(_vm_ram.cap()).phys_addr());
Genode::log("ram is at ",
Genode::Hex(Genode::Dataspace_client(_vm_ram.cap()).phys_addr()));
_vm_con.exception_handler(sig_cap);
_vm_con.attach(_vm_ram.cap(), RAM_ADDRESS);
_vm_con.attach_pic(0x2C002000);
@ -203,7 +205,7 @@ class Vm {
_state->gic_lr[2] = 0;
_state->gic_lr[3] = 0;
PINF("ready to run");
Genode::log("ready to run");
}
void run() { if (_active) _vm_con.run(); }
@ -366,12 +368,14 @@ class Vmm
if (reg) reg = reg->find_by_encoding(Iss::mask_encoding(v));
if (!reg) {
PERR("Unknown cp15 access @ ip=%08lx:", state->ip);
PERR("%s: c15 %d r%d c%d c%d %d",
Iss::Direction::get(v) ? "read" : "write",
Iss::Opcode1::get(v), Iss::Register::get(v),
Iss::Crn::get(v), Iss::Crm::get(v),
Iss::Opcode2::get(v));
Genode::error("unknown cp15 access @ ip=", state->ip, ":");
Genode::error(Iss::Direction::get(v) ? "read" : "write",
": "
"c15 ", Iss::Opcode1::get(v), " "
"r", Iss::Register::get(v), " "
"c", Iss::Crn::get(v), " "
"c", Iss::Crm::get(v), " ",
Iss::Opcode2::get(v));
return false;
}
@ -379,8 +383,8 @@ class Vmm
*(state->r(Iss::Register::get(v))) = reg->read(state);
} else { /* write access */
if (!reg->writeable()) {
PERR("Writing to cp15 register %s not allowed!",
reg->name());
Genode::error("writing to cp15 register ",
reg->name(), " not allowed!");
return false;
}
reg->write(state, *(state->r(Iss::Register::get(v))));
@ -814,7 +818,7 @@ class Vmm
_irqs[irq].cpu_state = Irq::PENDING;
if (_irqs[irq].distr_state == Irq::DISABLED) {
PWRN("Disabled irq %u injected", irq);
Genode::warning("disabled irq ", irq, " injected");
return;
}
@ -1316,7 +1320,7 @@ int main()
static Vmm vmm;
try {
PINF("Start virtual machine ...");
Genode::log("Start virtual machine ...");
vmm.run();
} catch(Vm::Exception &e) {
e.print();