Commit c76ac46c authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

show: protobuf -- Fix rendering of repeated messages

Repeated custom entries are presented as an array
of pointers in the memory, so once we fetch the
first entry we are to continue iterating pointers
instead.

Before

	| vmas: {
	|         start: 0x00000000400000
	|         end: 0x00000000406000
	|         pgoff: 0000000000000000
	|         shmid: 0x0000000000000b
	|         prot: 0x5
	|         flags: 0x2
	|         status: 0x41
	|         fd: 0xffffffffffffffff
	| }
	| :{
	|         start: 0x00000000462d00
	|         end: 0000000000000000
	|         pgoff: 0000000000000000
	|         shmid: 0x00000000605000
	|         prot: 0x606000
	|         flags: 0
	|         status: 0x5000
	|         fd: 0x0000000000000b
	|         madv: 0x00000000000041
	| }

After

	| vmas: {
	|         start: 0x00000000400000
	|         end: 0x00000000406000
	|         pgoff: 0000000000000000
	|         shmid: 0x0000000000000b
	|         prot: 0x5
	|         flags: 0x2
	|         status: 0x41
	|         fd: 0xffffffffffffffff
	| }
	| :{
	|         start: 0x00000000605000
	|         end: 0x00000000606000
	|         pgoff: 0x00000000005000
	|         shmid: 0x0000000000000b
	|         prot: 0x1
	|         flags: 0x2
	|         status: 0x41
	|         fd: 0xffffffffffffffff
	| }
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0b98d87b
...@@ -160,7 +160,6 @@ static int show_bytes(pb_pr_field_t *field) ...@@ -160,7 +160,6 @@ static int show_bytes(pb_pr_field_t *field)
static size_t pb_show_prepare_field_context(const ProtobufCFieldDescriptor *fd, static size_t pb_show_prepare_field_context(const ProtobufCFieldDescriptor *fd,
pb_pr_ctl_t *ctl) pb_pr_ctl_t *ctl)
{ {
pb_pr_field_t *field = &ctl->cur;
size_t fsize = 0; size_t fsize = 0;
switch (fd->type) { switch (fd->type) {
...@@ -184,8 +183,6 @@ static size_t pb_show_prepare_field_context(const ProtobufCFieldDescriptor *fd, ...@@ -184,8 +183,6 @@ static size_t pb_show_prepare_field_context(const ProtobufCFieldDescriptor *fd,
break; break;
case PROTOBUF_C_TYPE_MESSAGE: case PROTOBUF_C_TYPE_MESSAGE:
ctl->arg = (void *)fd->descriptor; ctl->arg = (void *)fd->descriptor;
if (field->data)
field->data = (void *)(*(long *)field->data);
case PROTOBUF_C_TYPE_STRING: case PROTOBUF_C_TYPE_STRING:
fsize = sizeof (void *); fsize = sizeof (void *);
break; break;
...@@ -349,7 +346,7 @@ static pb_pr_show_t get_show_function(const ProtobufCFieldDescriptor *fd, pb_pr_ ...@@ -349,7 +346,7 @@ static pb_pr_show_t get_show_function(const ProtobufCFieldDescriptor *fd, pb_pr_
return get_pb_show_function(fd->type, fd->label); return get_pb_show_function(fd->type, fd->label);
} }
static void pb_show_repeated(pb_pr_ctl_t *ctl, int nr_fields, pb_pr_show_t show, static void pb_show_repeated(const ProtobufCFieldDescriptor *fd, pb_pr_ctl_t *ctl, int nr_fields, pb_pr_show_t show,
size_t fsize) size_t fsize)
{ {
pb_pr_field_t *field = &ctl->cur; pb_pr_field_t *field = &ctl->cur;
...@@ -361,6 +358,23 @@ static void pb_show_repeated(pb_pr_ctl_t *ctl, int nr_fields, pb_pr_show_t show, ...@@ -361,6 +358,23 @@ static void pb_show_repeated(pb_pr_ctl_t *ctl, int nr_fields, pb_pr_show_t show,
return; return;
} }
if (fd->type == PROTOBUF_C_TYPE_MESSAGE) {
void *p = field->data;
field->count = nr_fields;
field->data = (void *)(*(long *)p);
done = show(field);
if (done)
return;
for (p += fsize, counter = 0; counter < nr_fields - 1; counter++, p += fsize) {
pr_msg(":");
field->data = (void *)(*(long *)p);
show(field);
}
return;
}
field->count = nr_fields; field->count = nr_fields;
done = show(field); done = show(field);
if (done) if (done)
...@@ -384,7 +398,7 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, ...@@ -384,7 +398,7 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd,
show = get_show_function(fd, ctl); show = get_show_function(fd, ctl);
pb_show_repeated(ctl, nr_fields, show, pb_show_prepare_field_context(fd, ctl)); pb_show_repeated(fd, ctl, nr_fields, show, pb_show_prepare_field_context(fd, ctl));
if (ctl->single_entry) if (ctl->single_entry)
pr_msg("\n"); pr_msg("\n");
......
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