improve debug

This commit is contained in:
Wim Taymans 2019-07-17 15:29:18 +02:00
parent 22b67cc95d
commit 53d3d5cb0c
6 changed files with 28 additions and 18 deletions

View file

@ -130,7 +130,7 @@ static int port_use_buffers(void *data,
struct pw_node *node = port->node;
int res, i;
pw_log_debug(NAME " %p: port %p", p->node->node, port);
pw_log_debug(NAME " %p: port %p %p %d", p->node->node, port, buffers, n_buffers);
if (n_buffers > 0) {
for (i = 0; i < PORT_BUFFERS; i++)

View file

@ -116,6 +116,7 @@ process_messages(struct client_data *data)
struct pw_core *core = client->core;
const struct pw_protocol_native_message *msg;
struct pw_resource *resource;
int res;
core->current_client = client;
@ -135,16 +136,17 @@ process_messages(struct client_data *data)
msg->opcode, msg->id);
if (debug_messages) {
fprintf(stderr, "<<<<<<<<< in: id:%d op:%d size:%d\n", msg->id, msg->opcode, msg->size);
fprintf(stderr, "<<<<<<<<< in: id:%d op:%d size:%d seq:%d\n",
msg->id, msg->opcode, msg->size, msg->seq);
spa_debug_pod(0, NULL, (struct spa_pod *)msg->data);
}
resource = pw_client_find_resource(client, msg->id);
if (resource == NULL) {
pw_log_error("protocol-native %p: unknown resource %u",
client->protocol, msg->id);
pw_log_error("protocol-native %p: unknown resource %u op:%u",
client->protocol, msg->id, msg->opcode);
pw_resource_error(client->core_resource,
-EINVAL, "unknown resource %u", msg->id);
-EINVAL, "unknown resource %u op:%u", msg->id, msg->opcode);
continue;
}
@ -153,8 +155,10 @@ process_messages(struct client_data *data)
goto invalid_method;
demarshal = marshal->method_demarshal;
if (!demarshal[msg->opcode].func)
if (!demarshal[msg->opcode].func) {
res = -ENOENT;
goto invalid_message;
}
permissions = pw_resource_get_permissions(resource);
required = demarshal[msg->opcode].permissions | PW_PERM_X;
@ -167,7 +171,7 @@ process_messages(struct client_data *data)
continue;
}
if (demarshal[msg->opcode].func(resource, msg) < 0)
if ((res = demarshal[msg->opcode].func(resource, msg)) < 0)
goto invalid_message;
}
done:
@ -175,15 +179,17 @@ done:
return;
invalid_method:
pw_log_error("protocol-native %p: invalid method %u on resource %u",
client->protocol, msg->opcode, msg->id);
pw_resource_error(resource, -EINVAL, "invalid method %u", msg->opcode);
pw_log_error("protocol-native %p: invalid method id:%u op:%u",
client->protocol, msg->id, msg->opcode);
pw_resource_error(resource, -EINVAL, "invalid method id:%u op:%u",
msg->id, msg->opcode);
pw_client_destroy(client);
goto done;
invalid_message:
pw_log_error("protocol-native %p: invalid message received %u %u",
client->protocol, msg->id, msg->opcode);
pw_resource_error(resource, -EINVAL, "invalid message %u", msg->opcode);
pw_log_error("protocol-native %p: invalid message received id:%u op:%u (%s)",
client->protocol, msg->id, msg->opcode, spa_strerror(res));
pw_resource_error(resource, res, "invalid message received id:%u op:%u (%s)",
msg->id, msg->opcode, spa_strerror(res));
spa_debug_pod(0, NULL, (struct spa_pod *)msg->data);
pw_client_destroy(client);
goto done;

View file

@ -416,7 +416,8 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
buf->n_fds += buf->msg.n_fds;
if (debug_messages) {
fprintf(stderr, ">>>>>>>>> out: id:%d op:%d size:%d\n", buf->msg.id, buf->msg.opcode, size);
fprintf(stderr, ">>>>>>>>> out: id:%d op:%d size:%d seq:%d\n",
buf->msg.id, buf->msg.opcode, size, buf->msg.seq);
spa_debug_pod(0, NULL, SPA_MEMBER(p, HDR_SIZE, struct spa_pod));
}

View file

@ -546,7 +546,7 @@ static int core_method_demarshal_destroy(void *object, const struct pw_protocol_
SPA_POD_Int(&id)) < 0)
return -EINVAL;
pw_log_debug("client %p: destroy resource %d", client, id);
pw_log_debug("client %p: destroy resource %u", client, id);
if ((r = pw_client_find_resource(client, id)) == NULL)
goto no_resource;
@ -554,9 +554,9 @@ static int core_method_demarshal_destroy(void *object, const struct pw_protocol_
return pw_resource_notify(resource, struct pw_core_proxy_methods, destroy, 0, r);
no_resource:
pw_log_error("client %p: can't find resouce %d", client, id);
pw_resource_error(resource, -EINVAL, "unknown resource %d", id);
return -EINVAL;
pw_log_error("client %p: unknown resouce %u op:%u", client, id, msg->opcode);
pw_resource_error(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode);
return 0;
}
static int registry_method_marshal_add_listener(void *object,

View file

@ -64,6 +64,7 @@ struct node_data {
static void resource_destroy(void *data)
{
struct node_data *nd = data;
pw_log_debug("node %p", nd);
spa_hook_remove(&nd->resource_listener);
if (nd->node)
pw_node_destroy(nd->node);
@ -77,6 +78,7 @@ static const struct pw_resource_events resource_events = {
static void node_destroy(void *data)
{
struct node_data *nd = data;
pw_log_debug("node %p", nd);
spa_list_remove(&nd->link);
spa_hook_remove(&nd->node_listener);
nd->node = NULL;

View file

@ -912,6 +912,7 @@ static void output_remove(struct pw_link *this, struct pw_port *port)
static void on_port_destroy(struct pw_link *this, struct pw_port *port)
{
pw_log_debug("link %p: port %p", this, port);
pw_link_emit_port_unlinked(this, port);
pw_link_update_state(this, PW_LINK_STATE_UNLINKED, NULL);