c - why is va_arg returning wrong data? -
i trying port embedded os new platform , facing problems filesystem component. stepped in code localize problem: function phone call relevant case is
// int64_t vnid = 1; // int32_t vid = 0; ... vnode = queue_lookup (& vnode_manager . vnode_list, vnode_id_inspector, vnid, vid);
and here queue_lookup declaration:
void * queue_lookup (queue_t * queue, queue_inspector_t inspector, ...) { bool result; va_list list, list_copy; queue_link_t * item = null; va_start (list, inspector); if (queue -> status != 0) { (item = queue -> head; item != null; item = item -> next) { result = false; va_copy (list_copy, list); result = inspector (item, list_copy); va_end (list_copy); if (result) break; } } va_end (list); homecoming item; }
and finally, here vnode_id_inspector declaration:
bool vnode_id_inspector (void * node, va_list list) { vnode_t vnode = node; int64_t vnid = va_arg (list, int64_t); int32_t vid = va_arg (list, int32_t); watch (bool) { ensure (vnode != null, false); homecoming vnode -> id == vnid && vnode -> volume -> id == vid; } }
now problem when phone call queue_lookup vnid=1 , vid=0, vnid=1 , vid=1145248 in vnode_id_inspector !
how can prepare issue minimum code alter possible ?
regards,
edit: add together debug info
(gdb) p vnode_manager . vnode_list $44 = {lock = 1, head = 0x167770, tail = 0x167770, status = 1} (gdb) p vnode_manager . vnode_list ->head $45 = (queue_link_t *) 0x167770 (gdb) p *(vnode_t)vnode_manager . vnode_list ->head $46 = {link = {next = 0x0}, id = 1, volume = 0x166370, destroy = false, usage_counter = 1, info = 0x166430} (gdb) p *(volume_t)((vnode_t)vnode_manager . vnode_list ->head)->volume $47 = {link = {next = 0x0}, id = 0, root_vnid = 1, lock = 0, host_volume = 0x0, host_vnid = -1, cmd = 0x13a768 <rootfs_cmd>, info = 0x1663d0}
i solved issue, there problem in stack alignment. fixed making adjustment in cpu_context_switch.s align stack 8bytes instead of 4bytes.
c operating-system filesystems embedded
No comments:
Post a Comment