dwarf_print_lines.c revision 49d3bc91e27cd871b950d56c01398fa2f2e12ab4
/*
Copyright (C) 2000,2002,2004 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 <stdio.h>
#include <time.h>
#include "dwarf_line.h"
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
static void
print_line_header(void)
{
(" s b e\n"
" t l s\n"
" m c e\n"
" section op col t k q\n"
" offset code address file line umn ? ? ?\n");
}
static void
print_line_detail(char *prefix,
int opcode,
unsigned long long address,
unsigned long file,
unsigned long line,
unsigned long column,
{
printf("%-15s %2d 0x%08llx "
"%2lu %4lu %2lu %1d %1d %1d\n",
(int) opcode,
(long long) address,
(unsigned long) file,
(unsigned long) line,
(unsigned long) column,
}
/*
return DW_DLV_OK if ok. else DW_DLV_NO_ENTRY or DW_DLV_ERROR
*/
int
{
/*
This pointer is used to scan the portion of the .debug_line
section for the current cu. */
/*
This points to the last byte of the .debug_line portion for the
current cu. */
/*
This points to the end of the statement program prologue for the
current cu, and serves to check that the prologue was correctly
decoded. */
/*
Pointer to a DW_AT_stmt_list attribute in case it exists in the
die. */
/* Pointer to DW_AT_comp_dir attribute in die. */
/* Pointer to name of compilation directory. */
/*
Offset into .debug_line specified by a DW_AT_stmt_list
attribute. */
/* These are the fields of the statement program header. */
/* These are the state machine state variables. */
/*
This is the current opcode read from the statement program. */
/*
Pointer to a Dwarf_Line_Context_s structure that contains the
context such as file names and include directories for the set
of lines being generated. */
/*
These variables are used to decode leb128 numbers. Leb128_num
holds the decoded number, and leb128_length is its length in
bytes. */
/*
This is the operand of the latest fixed_advance_pc extended
opcode. */
/* This is the length of an extended opcode instr. */
int local_length_size;
/*REFERENCED*/ /* Not used in this instance of the macro */
int local_extension_size;
/* The Dwarf_Debug this die belongs to. */
int resattr;
int lres;
int res;
/* ***** BEGIN CODE ***** */
res =
&dbg->de_debug_line,
error);
return res;
}
return resattr;
}
return lres;
}
return (DW_DLV_ERROR);
}
/*
If die has DW_AT_comp_dir attribute, get the string that names
the compilation directory. */
if (resattr == DW_DLV_ERROR) {
return resattr;
}
int cres;
char *cdir;
if (cres == DW_DLV_ERROR) {
return cres;
}
}
}
/*
Following is a straightforward decoding of the statement
program prologue information. */
/* READ_AREA_LENGTH updates line_ptr for consumed bytes */
return (DW_DLV_ERROR);
}
printf("total line info length %ld bytes, "
"line offset 0x%llx %lld\n",
(long) total_length,
(long long) line_offset, (long long) line_offset);
printf("compilation_directory %s\n",
line_ptr, sizeof(Dwarf_Half));
line_ptr += sizeof(Dwarf_Half);
if (version != CURRENT_VERSION_STAMP) {
return (DW_DLV_ERROR);
}
printf(" min instruction length %d\n",
(int) minimum_instruction_length);
opcode_length = (Dwarf_Small *)
for (i = 1; i < opcode_base; i++) {
printf(" opcode[%d] length %d\n", (int) i,
(int) opcode_length[i]);
}
while ((*(char *) line_ptr) != '\0') {
printf(" include dir[%d] %s\n",
(int) include_directories_count, line_ptr);
}
line_ptr++;
file_entry_count = 0;
while (*(char *) line_ptr != '\0') {
printf(" file[%d] %s\n",
(int) file_entry_count, (char *) line_ptr);
{
newline */
}
printf(" file length %ld 0x%lx\n",
}
line_ptr++;
return (DW_DLV_ERROR);
}
/* Set up context structure for this set of lines. */
if (line_context == NULL) {
return (DW_DLV_ERROR);
}
printf(" statement prog offset in section: %lld 0x%llx\n",
(long long) (line_ptr - orig_line_ptr),
(long long) (line_ptr - orig_line_ptr));
/* Initialize the state machine. */
address = 0;
file = 1;
line = 1;
column = 0;
basic_block = false;
end_sequence = false;
/* Start of statement program. */
while (line_ptr < line_ptr_end) {
int type;
line_ptr++;
/* 'type' is the output */
if (type == LOP_DISCARD) {
/* do nothing, necessary ops done */
} else if (type == LOP_SPECIAL) {
/* This op code is a special op in the object, no matter
that it might fall into the standard op range in this
compile Thatis, these are special opcodes between
special_opcode_base and MAX_LINE_OP_CODE. (including
special_opcode_base and MAX_LINE_OP_CODE) */
char special[50];
(opcode / line_range);
basic_block = false;
} else if (type == LOP_STANDARD) {
switch (opcode) {
case DW_LNS_copy:{
if (opcode_length[DW_LNS_copy] != 0) {
return (DW_DLV_ERROR);
}
print_line_detail("DW_LNS_copy",
basic_block = false;
break;
}
case DW_LNS_advance_pc:{
return (DW_DLV_ERROR);
}
printf("DW_LNS_advance_pc val %lld 0x%llx\n",
(long long) (Dwarf_Word) utmp2,
(long long) (Dwarf_Word) utmp2);
address =
address +
break;
}
case DW_LNS_advance_line:{
return (DW_DLV_ERROR);
}
printf("DW_LNS_advance_line val %lld 0x%llx\n",
(long long) advance_line,
(long long) advance_line);
break;
}
case DW_LNS_set_file:{
return (DW_DLV_ERROR);
}
break;
}
case DW_LNS_set_column:{
return (DW_DLV_ERROR);
}
printf("DW_LNS_set_column val %lld 0x%llx\n",
break;
}
case DW_LNS_negate_stmt:{
if (opcode_length[DW_LNS_negate_stmt] != 0) {
return (DW_DLV_ERROR);
}
printf("DW_LNS_negate_stmt\n");
break;
}
case DW_LNS_set_basic_block:{
if (opcode_length[DW_LNS_set_basic_block] != 0) {
return (DW_DLV_ERROR);
}
printf("DW_LNS_set_basic_block\n");
basic_block = true;
break;
}
case DW_LNS_const_add_pc:{
(opcode / line_range);
printf("DW_LNS_const_add_pc new address 0x%llx\n",
(long long) address);
break;
}
case DW_LNS_fixed_advance_pc:{
return (DW_DLV_ERROR);
}
line_ptr, sizeof(Dwarf_Half));
line_ptr += sizeof(Dwarf_Half);
printf("DW_LNS_fixed_advance_pc val %lld 0x%llx"
" new address 0x%llx\n",
(long long) fixed_advance_pc,
(long long) fixed_advance_pc,
(long long) address);
break;
}
}
} else if (type == LOP_EXTENDED) {
line_ptr++;
switch (ext_opcode) {
case DW_LNE_end_sequence:{
end_sequence = true;
print_line_detail("DW_LNE_end_sequence extended",
address = 0;
file = 1;
line = 1;
column = 0;
basic_block = false;
end_sequence = false;
break;
}
case DW_LNE_set_address:{
printf("DW_LNE_set_address address 0x%llx\n",
(long long) address);
} else {
return (DW_DLV_ERROR);
}
break;
}
case DW_LNE_define_file:{
tlm =
{
/* ctime supplies newline */
printf(" last time 0x%x %s",
}
printf(" file length %ld 0x%lx\n",
break;
}
default:{
return (DW_DLV_ERROR);
}
}
}
}
return (DW_DLV_OK);
}
/*
Caller passes in compilation unit DIE.
*/
int
{
int res;
return res;
}
return res;
}