Commit 89ad825d authored by Bernhard Link's avatar Bernhard Link

print raw data of unsupported or unknown requests and of unexpected replies

parent 1f2f1c8a
2009-07-02
* print raw data of unsupported or unknown requests and of
unexpected replies.
2009-06-29
* remove unecessary output of spaces for ft_IF,...
2009-06-28
......
......@@ -1345,6 +1345,7 @@ void replyInternAtom(struct connection *c,bool *ignore UNUSED,bool *dontremove U
const struct request *requests;
size_t num_requests;
const struct parameter *unexpected_reply;
static inline void free_expectedreplylist(struct expectedreply *r) {
......@@ -1407,22 +1408,27 @@ static inline void print_client_request(struct connection *c,bool bigrequest) {
else
ignore = r->request_func(c,true,bigrequest,NULL);
if( !ignore ) {
const char *name;
name = r->name;
if( name == NULL )
name = "UNKNOWN";
assert( r->parameters != NULL);
if( extensionname[0] == '\0' )
startline(c, TO_SERVER, "%04x:%3u: Request(%hhu): %s ",
(unsigned int)(c->seq),c->clientignore,
req, r->name
req, name
);
else
startline(c, TO_SERVER, "%04x:%3u: %s-Request(%hhu,%hhu): %s ",
(unsigned int)(c->seq),
c->clientignore,
extensionname, req, subreq,
r->name
name
);
if( r->parameters != NULL )
print_parameters(c,c->clientbuffer,len,r->parameters, bigrequest, &stack);
else
fputs("obsolete without parameter description\n",out);
print_parameters(c, c->clientbuffer, len,
r->parameters, bigrequest, &stack);
if( r->request_func != NULL )
(void)r->request_func(c,false,bigrequest,NULL);
putc('\n',out);
......@@ -1475,9 +1481,16 @@ static inline void print_server_reply(struct connection *c) {
replyto->from->reply_func(c,&ignore,&dontremove,replyto->datatype,replyto->data);
if( !ignore ) {
startline(c, TO_CLIENT, "%04x:%u: Reply to %s: ", seq, (unsigned int)c->serverignore,replyto->from->name);
print_parameters(c,
c->serverbuffer,len,replyto->from->answers,false,&stack);
const char *name = replyto->from->name;
if( name == NULL )
name = "UNKNOWN";
startline(c, TO_CLIENT, "%04x:%u: Reply to %s: ",
seq,
(unsigned int)c->serverignore,
name);
print_parameters(c, c->serverbuffer, len,
replyto->from->answers, false, &stack);
putc('\n',out);
}
if( !dontremove ) {
......@@ -1490,8 +1503,11 @@ static inline void print_server_reply(struct connection *c) {
return;
}
}
startline(c, TO_CLIENT, "%04x:%u: unexpected reply\n",
seq, c->serverignore);
startline(c, TO_CLIENT, "%04x:%u: unexpected Reply: ",
seq, (unsigned int)c->serverignore);
print_parameters(c, c->serverbuffer, len,
unexpected_reply, false, &stack);
putc('\n',out);
}
const char * const *errors;
......
......@@ -129,6 +129,7 @@ extern const const char * const *errors;
extern size_t num_errors;
extern const struct extension *extensions;
extern size_t num_extensions;
extern const struct parameter *unexpected_reply;
bool requestQueryExtension(struct connection *c, bool pre, bool bigrequest UNUSED, struct expectedreply *reply);
bool requestInternAtom(struct connection *c, bool pre, bool bigrequest UNUSED, struct expectedreply *reply);
......
......@@ -648,6 +648,19 @@ REQUEST ChangeWindowAttributes
12 value-list LISTofWindowAttributes
END
# This is used for all UNKNOWN or unsupported requests:
templateREQUEST unknown
0 opcode CARD8
1 opcode2 CARD8
4 unparsed-data LISTofCARD8
END
# reply to an UNKNOWN, UNSUPPORTED or unexpected reply
templateRESPONSE unknown
0 data1 CARD8
1 data2 CARD8
8 unparsed-data LISTofCARD8
END
templateREQUEST WINDOW
4 window WINDOW
END
......
......@@ -1272,7 +1272,12 @@ static void parse_request(struct parser *parser, bool template) {
return;
}
if( request->request != NULL ) {
error(parser, "Multiple definition of '%s::request::%s'!",
error(parser, "Multiple definition of request '%s::%s'!",
parser->current->namespace->name,
name);
}
if( request->unsupported ) {
error(parser, "Unexpected definition of unsupported request '%s::%s'!",
parser->current->namespace->name,
name);
}
......@@ -1322,7 +1327,12 @@ static void parse_response(struct parser *parser, bool template) {
name);
}
if( request->response != NULL ) {
error(parser, "Multiple definition of '%s::response::%s'!",
error(parser, "Multiple definition of response '%s::%s'!",
parser->current->namespace->name,
name);
}
if( request->unsupported ) {
error(parser, "Unexpected definition of unsupported response '%s::%s'!",
parser->current->namespace->name,
name);
}
......@@ -2211,7 +2221,7 @@ static const void *variable_finalize(struct parser *parser, struct variable *v)
assert( v->type != v->type );
}
static const struct request *finalize_requests(struct parser *parser, struct namespace *ns) {
static const struct request *finalize_requests(struct parser *parser, struct namespace *ns, const struct parameter *unknownrequest, const struct parameter *unknownresponse) {
struct request *rs;
const struct request *f;
int i;
......@@ -2223,10 +2233,25 @@ static const struct request *finalize_requests(struct parser *parser, struct nam
}
for( i = 0 ; i < ns->num_requests ; i++ ) {
rs[i].name = ns->requests[i].name;
rs[i].parameters = variable_finalize(parser,
ns->requests[i].request);
rs[i].answers = variable_finalize(parser,
ns->requests[i].response);
if( ns->requests[i].unsupported ) {
assert( ns->requests[i].request == NULL);
rs[i].parameters = unknownrequest;
} else {
assert( ns->requests[i].request != NULL);
rs[i].parameters = variable_finalize(parser,
ns->requests[i].request);
}
if( ns->requests[i].has_response ) {
if( ns->requests[i].unsupported ) {
assert( ns->requests[i].response == NULL);
rs[i].answers = unknownresponse;
} else {
assert( ns->requests[i].response != NULL);
rs[i].answers = variable_finalize(parser,
ns->requests[i].response);
}
} else
assert( ns->requests[i].response == NULL);
if( !ns->requests[i].special )
continue;
assert( rs[i].name != NULL );
......@@ -2284,6 +2309,8 @@ void finalize_everything(struct parser *parser) {
struct extension *es, *e;
size_t count = 0;
struct namespace *ns, *core = NULL;
struct variable *v;
const struct parameter *unknownrequest, *unknownresponse;
if( parser->error )
return;
......@@ -2316,46 +2343,55 @@ void finalize_everything(struct parser *parser) {
parser->error = true;
return;
}
v = find_variable(parser, vt_request, "core::unknown");
unknownrequest = variable_finalize(parser, v);
v = find_variable(parser, vt_response, "core::unknown");
unknownresponse = variable_finalize(parser, v);
unexpected_reply = unknownresponse;
if( parser->error )
return;
if( count == 0 ) {
num_extensions = count;
extensions = NULL;
return;
} else {
es = calloc(count, sizeof(struct extension));
if( es == NULL ) {
oom(parser);
return;
}
e = es;
for( ns = parser->namespaces ; ns != NULL ; ns = ns->next ) {
if( ns->extension == NULL )
continue;
e->name = string_add(ns->extension);
if( e->name == NULL )
parser->error = true;
e->namelen = strlen(ns->extension);
e->numsubrequests = ns->num_requests;
e->subrequests = finalize_requests(parser, ns,
unknownrequest, unknownresponse);
e->numevents = ns->num_events;
e->events = finalize_events(parser, ns);
e->numerrors = ns->num_errors;
e->errors = finalize_data(ns->errors,
ns->num_errors*sizeof(const char*),
__alignof__(const char*));
if( e->errors == NULL )
parser->error = true;
e++;
}
assert( (size_t)(e-es) == count );
extensions = finalize_data(es, count*sizeof(struct extension),
__alignof__(struct extension));
free(es);
if( extensions == NULL ) {
oom(parser);
return;
}
num_extensions = count;
}
es = calloc(count, sizeof(struct extension));
if( es == NULL ) {
oom(parser);
return;
}
e = es;
for( ns = parser->namespaces ; ns != NULL ; ns = ns->next ) {
if( ns->extension == NULL )
continue;
e->name = string_add(ns->extension);
if( e->name == NULL )
parser->error = true;
e->namelen = strlen(ns->extension);
e->numsubrequests = ns->num_requests;
e->subrequests = finalize_requests(parser, ns);
e->numevents = ns->num_events;
e->events = finalize_events(parser, ns);
e->numerrors = ns->num_errors;
e->errors = finalize_data(ns->errors,
ns->num_errors*sizeof(const char*),
__alignof__(const char*));
if( e->errors == NULL )
parser->error = true;
e++;
}
assert( (size_t)(e-es) == count );
extensions = finalize_data(es, count*sizeof(struct extension),
__alignof__(struct extension));
free(es);
if( extensions == NULL ) {
oom(parser);
return;
}
num_extensions = count;
requests = finalize_requests(parser, core);
requests = finalize_requests(parser, core, unknownrequest, unknownresponse);
num_requests = core->num_requests;
events = finalize_events(parser, core);
num_events = core->num_events;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment