dwarf_loc.c revision 49d3bc91e27cd871b950d56c01398fa2f2e12ab4
/*
Copyright (C) 2000,2003 Silicon Graphics, Inc. All Rights Reserved.
under the terms of version 2.1 of the GNU Lesser General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
USA.
Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
Mountain View, CA 94043, or:
For further information regarding this notice, see:
*/
#include "config.h"
#include "dwarf_incl.h"
#include "dwarf_loc.h"
/*
Given a Dwarf_Block that represents a location expression,
this function returns a pointer to a Dwarf_Locdesc struct
that has its ld_cents field set to the number of location
operators in the block, and its ld_s field pointing to a
contiguous block of Dwarf_Loc structs. However, the
ld_lopc and ld_hipc values are uninitialized. Returns
NULL on error. This function assumes that the length of
the block is greater than 0. Zero length location expressions
to represent variables that have been optimized away are
handled in the calling function.
*/
static Dwarf_Locdesc *
{
/* Size of the block containing the location expression. */
/* Sweeps the block containing the location expression. */
/* Current location operator. */
/* Offset of current operator from start of block. */
/* Operands of current location operator. */
/* Used to chain the Dwarf_Loc_Chain_s structs. */
/* Count of the number of location operators. */
/* Contiguous block of Dwarf_Loc's for Dwarf_Locdesc. */
/* Dwarf_Locdesc pointer to be returned. */
/* ***** BEGIN CODE ***** */
offset = 0;
op_count = 0;
operand1 = 0;
operand2 = 0;
op_count++;
loc_ptr++;
offset++;
curr_loc =
1);
return (NULL);
}
switch (atom) {
case DW_OP_reg0:
case DW_OP_reg1:
case DW_OP_reg2:
case DW_OP_reg3:
case DW_OP_reg4:
case DW_OP_reg5:
case DW_OP_reg6:
case DW_OP_reg7:
case DW_OP_reg8:
case DW_OP_reg9:
case DW_OP_reg10:
case DW_OP_reg11:
case DW_OP_reg12:
case DW_OP_reg13:
case DW_OP_reg14:
case DW_OP_reg15:
case DW_OP_reg16:
case DW_OP_reg17:
case DW_OP_reg18:
case DW_OP_reg19:
case DW_OP_reg20:
case DW_OP_reg21:
case DW_OP_reg22:
case DW_OP_reg23:
case DW_OP_reg24:
case DW_OP_reg25:
case DW_OP_reg26:
case DW_OP_reg27:
case DW_OP_reg28:
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
break;
case DW_OP_regx:
break;
case DW_OP_lit0:
case DW_OP_lit1:
case DW_OP_lit2:
case DW_OP_lit3:
case DW_OP_lit4:
case DW_OP_lit5:
case DW_OP_lit6:
case DW_OP_lit7:
case DW_OP_lit8:
case DW_OP_lit9:
case DW_OP_lit10:
case DW_OP_lit11:
case DW_OP_lit12:
case DW_OP_lit13:
case DW_OP_lit14:
case DW_OP_lit15:
case DW_OP_lit16:
case DW_OP_lit17:
case DW_OP_lit18:
case DW_OP_lit19:
case DW_OP_lit20:
case DW_OP_lit21:
case DW_OP_lit22:
case DW_OP_lit23:
case DW_OP_lit24:
case DW_OP_lit25:
case DW_OP_lit26:
case DW_OP_lit27:
case DW_OP_lit28:
case DW_OP_lit29:
case DW_OP_lit30:
case DW_OP_lit31:
break;
case DW_OP_addr:
break;
case DW_OP_const1u:
break;
case DW_OP_const1s:
break;
case DW_OP_const2u:
break;
case DW_OP_const2s:
break;
case DW_OP_const4u:
break;
case DW_OP_const4s:
break;
case DW_OP_const8u:
break;
case DW_OP_const8s:
break;
case DW_OP_constu:
break;
case DW_OP_consts:
break;
case DW_OP_fbreg:
break;
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
break;
case DW_OP_bregx:
/* uleb reg num followed by sleb offset */
break;
case DW_OP_dup:
case DW_OP_drop:
break;
case DW_OP_pick:
break;
case DW_OP_over:
case DW_OP_swap:
case DW_OP_rot:
case DW_OP_deref:
break;
case DW_OP_deref_size:
break;
case DW_OP_xderef:
break;
case DW_OP_xderef_size:
break;
case DW_OP_abs:
case DW_OP_and:
case DW_OP_div:
case DW_OP_minus:
case DW_OP_mod:
case DW_OP_mul:
case DW_OP_neg:
case DW_OP_not:
case DW_OP_or:
case DW_OP_plus:
break;
case DW_OP_plus_uconst:
break;
case DW_OP_shl:
case DW_OP_shr:
case DW_OP_shra:
case DW_OP_xor:
break;
case DW_OP_le:
case DW_OP_ge:
case DW_OP_eq:
case DW_OP_lt:
case DW_OP_gt:
case DW_OP_ne:
break;
case DW_OP_skip:
case DW_OP_bra:
break;
case DW_OP_piece:
break;
case DW_OP_nop:
break;
default:
return (NULL);
}
else {
}
}
return (NULL);
}
for (i = 0; i < op_count; i++) {
}
locdesc =
return (NULL);
}
return (locdesc);
}
/* Using a loclist offset to get the in-memory
address of .debug_loc data to read, returns the loclist
'header' info in return_block.
*/
static int
{
Dwarf_Addr start_addr = 0;
Dwarf_Addr end_addr = 0;
Dwarf_Half exprblock_size = 0;
/* We're at the end. No more present. */
return DW_DLV_NO_ENTRY;
}
/* If it goes past end, error */
return DW_DLV_ERROR;
}
if (start_addr == 0 && end_addr == 0) {
/* If start_addr and end_addr are 0, it's the end and no
exprblock_size field follows. */
exprblock_size = 0;
exprblock_off -= sizeof(Dwarf_Half);
} else if (start_addr == MAX_ADDR) {
/* end address is a base address, no exprblock_size field here
either */
exprblock_size = 0;
exprblock_off -= sizeof(Dwarf_Half);
} else {
/* exprblock_size can be zero, means no expression */
return DW_DLV_ERROR;
}
}
*lowpc = start_addr;
return DW_DLV_OK;
}
static int
{
int count = 0;
for (;;) {
Dwarf_Block b;
return res;
}
break;
}
count++;
}
*loclist_count = count;
return DW_DLV_OK;
}
/* Helper routine to avoid code duplication.
*/
static int
{
Dwarf_Debug dbg = 0;
Dwarf_Half form = 0;
int blkres;
return (DW_DLV_ERROR);
}
return (DW_DLV_ERROR);
}
return (DW_DLV_ERROR);
}
return blkres;
}
return DW_DLV_OK;
}
/* Helper routine to avoid code duplication.
*/
static int
Dwarf_Error * error)
{
int secload = 0;
return (blkres);
}
if (!dbg->de_debug_loc) {
return secload;
}
}
return DW_DLV_OK;
}
/* When llbuf (see dwarf_loclist_n) is partially set up
and an error is encountered, tear it down as it
won't be used.
*/
static void
{
int i;
for (i = 0; i < count; ++i) {
}
}
/*
Handles simple location entries and loclists.
Returns all the Locdesc's thru llbuf.
*/
int
Dwarf_Locdesc *** llbuf_out,
{
/*
Dwarf_Attribute that describes the DW_AT_location in die, if
present. */
/* Dwarf_Block that describes a single location expression. */
/* A pointer to the current Dwarf_Locdesc read. */
Dwarf_Locdesc *locdesc = 0;
Dwarf_Half form = 0;
Dwarf_Addr lowpc = 0;
Dwarf_Addr highpc = 0;
Dwarf_Signed listlen = 0;
Dwarf_Locdesc **llbuf = 0;
int blkres;
int setup_res;
/* ***** BEGIN CODE ***** */
return setup_res;
}
/* If this is a form_block then it's a location expression. If it's
DW_FORM_data4 or DW_FORM_data8 it's a loclist offset */
/* A reference to .debug_loc, with an offset in .debug_loc of a
loclist */
int off_res;
int count_res;
int loclist_count;
int lli;
error);
return off_res;
}
&loclist_count, error);
return count_res;
}
if (loclist_count == 0) {
return DW_DLV_NO_ENTRY;
}
llbuf = (Dwarf_Locdesc **)
if (!llbuf) {
return (DW_DLV_ERROR);
}
&lowpc,
&highpc,
return (blkres);
}
/* low level error already set: let it be passed back */
return (DW_DLV_ERROR);
}
/* Now get to next loclist entry offset. */
}
} else {
Dwarf_Block *tblock = 0;
return (blkres);
}
/* We copied tblock contents to the stack var, so can dealloc
tblock now. Avoids leaks. */
entry. */
lowpc = 0; /* HACK */
/* An empty location description (block length 0) means the
code generator emitted no variable, the variable was not
generated, it was unused or perhaps never tested after being
set. Dwarf2, section 2.4.1 In other words, it is not an
error, and we don't test for block length 0 specially here. */
/* low level error already set: let it be passed back */
return (DW_DLV_ERROR);
}
llbuf = (Dwarf_Locdesc **)
if (!llbuf) {
/* Free the locdesc we allocated but won't use. */
return (DW_DLV_ERROR);
}
}
*listlen_out = listlen;
return (DW_DLV_OK);
}
/*
Handles only a location expression.
If called on a loclist, just returns one of those.
Cannot not handle a real loclist.
It returns the location expression as a loclist with
a single entry.
See dwarf_loclist_n() which handles any number
of location list entries.
This is the original definition, and it simply
does not work for loclists. Kept for compatibility.
*/
int
Dwarf_Locdesc ** llbuf,
{
/*
Dwarf_Attribute that describes the DW_AT_location in die, if
present. */
/* Dwarf_Block that describes a single location expression. */
/* A pointer to the current Dwarf_Locdesc read. */
Dwarf_Locdesc *locdesc = 0;
Dwarf_Half form = 0;
Dwarf_Addr lowpc = 0;
Dwarf_Addr highpc = 0;
int blkres;
int setup_res;
/* ***** BEGIN CODE ***** */
return setup_res;
}
/* If this is a form_block then it's a location expression. If it's
DW_FORM_data4 or DW_FORM_data8 it's a loclist offset */
/* A reference to .debug_loc, with an offset in .debug_loc of a
loclist */
int off_res;
error);
return off_res;
}
/* With dwarf_loclist, just read a single entry */
&lowpc,
&highpc,
return (blkres);
}
} else {
Dwarf_Block *tblock = 0;
return (blkres);
}
/* We copied tblock contents to the stack var, so can dealloc
tblock now. Avoids leaks. */
lowpc = 0; /* HACK */
}
/* An empty location description (block length 0) means the code
generator emitted no variable, the variable was not generated,
it was unused or perhaps never tested after being set. Dwarf2,
section 2.4.1 In other words, it is not an error, and we don't
test for block length 0 specially here. FIXME: doing this once
/* low level error already set: let it be passed back */
return (DW_DLV_ERROR);
}
*listlen = 1;
return (DW_DLV_OK);
}
/* Usable to read a single loclist or to read a block of them
or to read an entire section's loclists.
*/
/*ARGSUSED*/ int
Dwarf_Error * error)
{
Dwarf_Block b;
int res;
if (!dbg->de_debug_loc) {
&dbg->de_debug_loc,
error);
return secload;
}
}
return res;
}
*hipc_offset = highpc;
*lopc_offset = lowpc;
return DW_DLV_OK;
}