1179187Sjb/*- 2179187Sjb * Copyright (c) 2007 John Birrell (jb@freebsd.org) 3179187Sjb * All rights reserved. 4179187Sjb * 5179187Sjb * Redistribution and use in source and binary forms, with or without 6179187Sjb * modification, are permitted provided that the following conditions 7179187Sjb * are met: 8179187Sjb * 1. Redistributions of source code must retain the above copyright 9179187Sjb * notice, this list of conditions and the following disclaimer. 10179187Sjb * 2. Redistributions in binary form must reproduce the above copyright 11179187Sjb * notice, this list of conditions and the following disclaimer in the 12179187Sjb * documentation and/or other materials provided with the distribution. 13179187Sjb * 14179187Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15179187Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16179187Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17179187Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18179187Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19179187Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20179187Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21179187Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22179187Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23179187Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24179187Sjb * SUCH DAMAGE. 25179187Sjb * 26179187Sjb * $FreeBSD$ 27179187Sjb */ 28179187Sjb 29179187Sjb#include "_libdwarf.h" 30179187Sjb 31179187Sjbint 32179187Sjbdwarf_next_cu_header(Dwarf_Debug dbg, Dwarf_Unsigned *cu_header_length, 33179187Sjb Dwarf_Half *cu_version, Dwarf_Unsigned *cu_abbrev_offset, 34179187Sjb Dwarf_Half *cu_pointer_size, Dwarf_Unsigned *cu_next_offset, Dwarf_Error *error) 35179187Sjb{ 36179187Sjb Dwarf_CU next; 37179187Sjb 38179187Sjb if (error == NULL) 39179187Sjb return DWARF_E_ERROR; 40179187Sjb 41179187Sjb if (dbg == NULL || cu_header_length == NULL || cu_version == NULL || 42179187Sjb cu_abbrev_offset == NULL || cu_pointer_size == NULL || 43179187Sjb cu_next_offset == NULL) { 44179187Sjb DWARF_SET_ERROR(error, DWARF_E_ARGUMENT); 45179187Sjb return DWARF_E_ERROR; 46179187Sjb } 47179187Sjb 48179187Sjb if (dbg->dbg_cu_current == NULL) 49179187Sjb dbg->dbg_cu_current = STAILQ_FIRST(&dbg->dbg_cu); 50179187Sjb else if ((next = STAILQ_NEXT(dbg->dbg_cu_current, cu_next)) == NULL) { 51179187Sjb DWARF_SET_ERROR(error, DWARF_E_NO_ENTRY); 52179187Sjb return DWARF_E_NO_ENTRY; 53179187Sjb } else 54179187Sjb dbg->dbg_cu_current = next; 55179187Sjb 56179187Sjb if (dbg->dbg_cu_current == NULL) { 57179187Sjb DWARF_SET_ERROR(error, DWARF_E_NO_ENTRY); 58179187Sjb return DWARF_E_NO_ENTRY; 59179187Sjb } 60179187Sjb 61179187Sjb *cu_header_length = dbg->dbg_cu_current->cu_header_length; 62179187Sjb *cu_version = dbg->dbg_cu_current->cu_version; 63179187Sjb *cu_abbrev_offset = dbg->dbg_cu_current->cu_abbrev_offset; 64179187Sjb *cu_pointer_size = dbg->dbg_cu_current->cu_pointer_size; 65179187Sjb *cu_next_offset = dbg->dbg_cu_current->cu_next_offset; 66179187Sjb 67179187Sjb return DWARF_E_NONE; 68179187Sjb} 69