summaryrefslogtreecommitdiff
path: root/usr/src/tools/ctf/dwarf/common/pro_macinfo.c
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2011-05-22 03:13:22 +0100
committerRichard Lowe <richlowe@richlowe.net>2011-06-29 19:12:22 -0400
commit77b6d4a80fc05587b08370de690c979abe2667d5 (patch)
treef00c511c215afecbbe09aac179e10839099358a6 /usr/src/tools/ctf/dwarf/common/pro_macinfo.c
parent9ecc7612020c1993e4dbadd3422a74b210279739 (diff)
downloadillumos-joyent-77b6d4a80fc05587b08370de690c979abe2667d5.tar.gz
dwarf: Upgrade to libdwarf-20110113
Diffstat (limited to 'usr/src/tools/ctf/dwarf/common/pro_macinfo.c')
-rw-r--r--usr/src/tools/ctf/dwarf/common/pro_macinfo.c324
1 files changed, 162 insertions, 162 deletions
diff --git a/usr/src/tools/ctf/dwarf/common/pro_macinfo.c b/usr/src/tools/ctf/dwarf/common/pro_macinfo.c
index aa89ebf75b..cfa820aee6 100644
--- a/usr/src/tools/ctf/dwarf/common/pro_macinfo.c
+++ b/usr/src/tools/ctf/dwarf/common/pro_macinfo.c
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of version 2.1 of the GNU Lesser General Public License
@@ -19,10 +19,10 @@
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,
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
USA.
- Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
+ Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
Mountain View, CA 94043, or:
http://www.sgi.com
@@ -44,11 +44,11 @@
#include "pro_macinfo.h"
/*
- I don't much like the error strings this generates, since
- like the rest of libdwarf they are simple strings with
- no useful numbers in them. But that's not something I can
- fix without more work than I have time for
- right now. davea Nov 94.
+ I don't much like the error strings this generates, since
+ like the rest of libdwarf they are simple strings with
+ no useful numbers in them. But that's not something I can
+ fix without more work than I have time for
+ right now. davea Nov 94.
*/
/* these are gross overestimates of the number of
@@ -64,67 +64,67 @@
static int
libdwarf_compose_begin(Dwarf_P_Debug dbg, int code,
- size_t maxlen, int *compose_error_type)
+ size_t maxlen, int *compose_error_type)
{
unsigned char *nextchar;
struct dw_macinfo_block_s *curblk = dbg->de_current_macinfo;
if (curblk == 0) {
- struct dw_macinfo_block_s *newb;
- size_t len;
-
- /* initial allocation */
- size_t blen = BASE_MACINFO_MALLOC_LEN;
-
- if (blen < maxlen) {
- blen = 2 * maxlen;
- }
- len = sizeof(struct dw_macinfo_block_s) + blen;
- newb =
- (struct dw_macinfo_block_s *) _dwarf_p_get_alloc(dbg, len);
- if (!newb) {
- *compose_error_type = DW_DLE_MACINFO_MALLOC_FAIL;
- return DW_DLV_ERROR;
- }
- newb->mb_data =
- (char *) newb + sizeof(struct dw_macinfo_block_s);
- newb->mb_avail_len = blen;
- newb->mb_used_len = 0;
- newb->mb_macinfo_data_space_len = blen;
- dbg->de_first_macinfo = newb;
- dbg->de_current_macinfo = newb;
- curblk = newb;
+ struct dw_macinfo_block_s *newb;
+ size_t len;
+
+ /* initial allocation */
+ size_t blen = BASE_MACINFO_MALLOC_LEN;
+
+ if (blen < maxlen) {
+ blen = 2 * maxlen;
+ }
+ len = sizeof(struct dw_macinfo_block_s) + blen;
+ newb =
+ (struct dw_macinfo_block_s *) _dwarf_p_get_alloc(dbg, len);
+ if (!newb) {
+ *compose_error_type = DW_DLE_MACINFO_MALLOC_FAIL;
+ return DW_DLV_ERROR;
+ }
+ newb->mb_data =
+ (char *) newb + sizeof(struct dw_macinfo_block_s);
+ newb->mb_avail_len = blen;
+ newb->mb_used_len = 0;
+ newb->mb_macinfo_data_space_len = blen;
+ dbg->de_first_macinfo = newb;
+ dbg->de_current_macinfo = newb;
+ curblk = newb;
} else if (curblk->mb_avail_len < maxlen) {
- struct dw_macinfo_block_s *newb;
- size_t len;
-
- /* no space left in block: allocate a new block */
- size_t blen =
- dbg->de_current_macinfo->mb_macinfo_data_space_len * 2;
- if (blen < maxlen) {
- blen = 2 * maxlen;
- }
- len = sizeof(struct dw_macinfo_block_s) + blen;
- newb =
- (struct dw_macinfo_block_s *) _dwarf_p_get_alloc(dbg, len);
- if (!newb) {
- *compose_error_type = DW_DLE_MACINFO_MALLOC_FAIL;
- return DW_DLV_ERROR;
- }
- newb->mb_data =
- (char *) newb + sizeof(struct dw_macinfo_block_s);
- newb->mb_avail_len = blen;
- newb->mb_used_len = 0;
- newb->mb_macinfo_data_space_len = blen;
- dbg->de_first_macinfo->mb_next = newb;
- dbg->de_current_macinfo = newb;
- curblk = newb;
+ struct dw_macinfo_block_s *newb;
+ size_t len;
+
+ /* no space left in block: allocate a new block */
+ size_t blen =
+ dbg->de_current_macinfo->mb_macinfo_data_space_len * 2;
+ if (blen < maxlen) {
+ blen = 2 * maxlen;
+ }
+ len = sizeof(struct dw_macinfo_block_s) + blen;
+ newb =
+ (struct dw_macinfo_block_s *) _dwarf_p_get_alloc(dbg, len);
+ if (!newb) {
+ *compose_error_type = DW_DLE_MACINFO_MALLOC_FAIL;
+ return DW_DLV_ERROR;
+ }
+ newb->mb_data =
+ (char *) newb + sizeof(struct dw_macinfo_block_s);
+ newb->mb_avail_len = blen;
+ newb->mb_used_len = 0;
+ newb->mb_macinfo_data_space_len = blen;
+ dbg->de_first_macinfo->mb_next = newb;
+ dbg->de_current_macinfo = newb;
+ curblk = newb;
}
/* now curblk has enough room */
dbg->de_compose_avail = curblk->mb_avail_len;
dbg->de_compose_used_len = curblk->mb_used_len;
nextchar =
- (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
+ (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
*nextchar = code;
dbg->de_compose_avail--;
++dbg->de_compose_used_len;
@@ -140,9 +140,9 @@ libdwarf_compose_add_string(Dwarf_P_Debug dbg, char *string, size_t len)
unsigned char *nextchar;
nextchar =
- (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
+ (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
- len += 1; /* count the null terminator */
+ len += 1; /* count the null terminator */
memcpy(nextchar, string, len);
dbg->de_compose_avail -= len;
@@ -152,7 +152,7 @@ libdwarf_compose_add_string(Dwarf_P_Debug dbg, char *string, size_t len)
}
static int
libdwarf_compose_add_line(Dwarf_P_Debug dbg,
- Dwarf_Unsigned line, int *compose_error_type)
+ Dwarf_Unsigned line, int *compose_error_type)
{
struct dw_macinfo_block_s *curblk = dbg->de_current_macinfo;
unsigned char *nextchar;
@@ -160,18 +160,18 @@ libdwarf_compose_add_line(Dwarf_P_Debug dbg,
int nbytes;
nextchar =
- (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
+ (unsigned char *) (curblk->mb_data + dbg->de_compose_used_len);
/* Put the created leb number directly into the macro buffer If
dbg->de_compose_avail is > INT_MAX this will not work as the
'int' will look negative to _dwarf_pro_encode_leb128_nm! */
res = _dwarf_pro_encode_leb128_nm(line, &nbytes,
- (char *) nextchar,
- (int) dbg->de_compose_avail);
+ (char *) nextchar,
+ (int) dbg->de_compose_avail);
if (res != DW_DLV_OK) {
- *compose_error_type = DW_DLE_MACINFO_INTERNAL_ERROR_SPACE;
- return DW_DLV_ERROR;
+ *compose_error_type = DW_DLE_MACINFO_INTERNAL_ERROR_SPACE;
+ return DW_DLV_ERROR;
}
dbg->de_compose_avail -= nbytes;
@@ -189,8 +189,8 @@ libdwarf_compose_complete(Dwarf_P_Debug dbg, int *compose_error_type)
struct dw_macinfo_block_s *curblk = dbg->de_current_macinfo;
if (dbg->de_compose_used_len > curblk->mb_macinfo_data_space_len) {
- *compose_error_type = DW_DLE_MACINFO_INTERNAL_ERROR_SPACE;
- return DW_DLV_ERROR;
+ *compose_error_type = DW_DLE_MACINFO_INTERNAL_ERROR_SPACE;
+ return DW_DLV_ERROR;
}
curblk->mb_avail_len = dbg->de_compose_avail;
curblk->mb_used_len = dbg->de_compose_used_len;
@@ -201,8 +201,8 @@ libdwarf_compose_complete(Dwarf_P_Debug dbg, int *compose_error_type)
int
dwarf_def_macro(Dwarf_P_Debug dbg,
- Dwarf_Unsigned line,
- char *macname, char *macvalue, Dwarf_Error * error)
+ Dwarf_Unsigned line,
+ char *macname, char *macvalue, Dwarf_Error * error)
{
size_t len;
size_t len2;
@@ -211,58 +211,58 @@ dwarf_def_macro(Dwarf_P_Debug dbg,
int compose_error_type;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (DW_DLV_ERROR);
}
if (macname == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
+ return (DW_DLV_ERROR);
}
len = strlen(macname) + 1;
if (len == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
+ return (DW_DLV_ERROR);
}
if (macvalue) {
- len2 = strlen(macvalue) + 1;
+ len2 = strlen(macvalue) + 1;
} else {
- len2 = 0;
- }
- length_est = COMMAND_LEN + LINE_LEN + len + len2 + 1; /* 1
- for
- space
- character
- we
- add */
+ len2 = 0;
+ }
+ length_est = COMMAND_LEN + LINE_LEN + len + len2 + 1; /* 1
+ for
+ space
+ character
+ we
+ add */
res = libdwarf_compose_begin(dbg, DW_MACINFO_define, length_est,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_add_line(dbg, line, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
libdwarf_compose_add_string(dbg, macname, len);
libdwarf_compose_add_string(dbg, " ", 1);
if (macvalue) {
- libdwarf_compose_add_string(dbg, " ", 1);
- libdwarf_compose_add_string(dbg, macvalue, len2);
+ libdwarf_compose_add_string(dbg, " ", 1);
+ libdwarf_compose_add_string(dbg, macvalue, len2);
}
res = libdwarf_compose_complete(dbg, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
int
dwarf_undef_macro(Dwarf_P_Debug dbg,
- Dwarf_Unsigned line,
- char *macname, Dwarf_Error * error)
+ Dwarf_Unsigned line,
+ char *macname, Dwarf_Error * error)
{
size_t len;
@@ -271,70 +271,70 @@ dwarf_undef_macro(Dwarf_P_Debug dbg,
int compose_error_type;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (DW_DLV_ERROR);
}
if (macname == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
+ return (DW_DLV_ERROR);
}
len = strlen(macname) + 1;
if (len == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
+ return (DW_DLV_ERROR);
}
length_est = COMMAND_LEN + LINE_LEN + len;
res = libdwarf_compose_begin(dbg, DW_MACINFO_undef, length_est,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_add_line(dbg, line, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
libdwarf_compose_add_string(dbg, macname, len);
res = libdwarf_compose_complete(dbg, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
int
dwarf_start_macro_file(Dwarf_P_Debug dbg,
- Dwarf_Unsigned fileindex,
- Dwarf_Unsigned linenumber, Dwarf_Error * error)
+ Dwarf_Unsigned fileindex,
+ Dwarf_Unsigned linenumber, Dwarf_Error * error)
{
size_t length_est;
int res;
int compose_error_type;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (DW_DLV_ERROR);
}
length_est = COMMAND_LEN + LINE_LEN + LINE_LEN;
res = libdwarf_compose_begin(dbg, DW_MACINFO_start_file, length_est,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_add_line(dbg, fileindex,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_add_line(dbg, linenumber,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
@@ -347,28 +347,28 @@ dwarf_end_macro_file(Dwarf_P_Debug dbg, Dwarf_Error * error)
int compose_error_type;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (DW_DLV_ERROR);
}
length_est = COMMAND_LEN;
res = libdwarf_compose_begin(dbg, DW_MACINFO_end_file, length_est,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_complete(dbg, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
int
dwarf_vendor_ext(Dwarf_P_Debug dbg,
- Dwarf_Unsigned constant,
- char *string, Dwarf_Error * error)
+ Dwarf_Unsigned constant,
+ char *string, Dwarf_Error * error)
{
size_t len;
size_t length_est;
@@ -376,35 +376,35 @@ dwarf_vendor_ext(Dwarf_P_Debug dbg,
int compose_error_type;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (DW_DLV_ERROR);
}
if (string == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_NULL);
+ return (DW_DLV_ERROR);
}
len = strlen(string) + 1;
if (len == 0) {
- _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, DW_DLE_MACINFO_STRING_EMPTY);
+ return (DW_DLV_ERROR);
}
length_est = COMMAND_LEN + LINE_LEN + len;
res = libdwarf_compose_begin(dbg, DW_MACINFO_vendor_ext, length_est,
- &compose_error_type);
+ &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
res = libdwarf_compose_add_line(dbg, constant, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
libdwarf_compose_add_string(dbg, string, len);
libdwarf_compose_complete(dbg, &compose_error_type);
if (res != DW_DLV_OK) {
- _dwarf_p_error(NULL, error, compose_error_type);
- return (DW_DLV_ERROR);
+ _dwarf_p_error(NULL, error, compose_error_type);
+ return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
@@ -413,7 +413,7 @@ dwarf_vendor_ext(Dwarf_P_Debug dbg,
int
_dwarf_pro_transform_macro_info_to_disk(Dwarf_P_Debug dbg,
- Dwarf_Error * error)
+ Dwarf_Error * error)
{
/* Total num of bytes in .debug_macinfo section. */
Dwarf_Unsigned mac_num_bytes;
@@ -433,36 +433,36 @@ _dwarf_pro_transform_macro_info_to_disk(Dwarf_P_Debug dbg,
/* Get the size of the debug_macinfo data */
mac_num_bytes = 0;
for (m_sect = dbg->de_first_macinfo; m_sect != NULL;
- m_sect = m_sect->mb_next) {
- mac_num_bytes += m_sect->mb_used_len;
+ m_sect = m_sect->mb_next) {
+ mac_num_bytes += m_sect->mb_used_len;
}
/* Tthe final entry has a type code of 0 to indicate It is final
for this CU Takes just 1 byte. */
mac_num_bytes += 1;
GET_CHUNK(dbg, dbg->de_elf_sects[DEBUG_MACINFO],
- macinfo, (unsigned long) mac_num_bytes, error);
+ macinfo, (unsigned long) mac_num_bytes, error);
if (macinfo == NULL) {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
}
macinfo_ptr = macinfo;
m_prev = 0;
for (m_sect = dbg->de_first_macinfo; m_sect != NULL;
- m_sect = m_sect->mb_next) {
- memcpy(macinfo_ptr, m_sect->mb_data, m_sect->mb_used_len);
- macinfo_ptr += m_sect->mb_used_len;
- if (m_prev) {
- _dwarf_p_dealloc(dbg, (Dwarf_Small *) m_prev);
- m_prev = 0;
- }
- m_prev = m_sect;
- }
- *macinfo_ptr = 0; /* the type code of 0 as last entry */
+ m_sect = m_sect->mb_next) {
+ memcpy(macinfo_ptr, m_sect->mb_data, m_sect->mb_used_len);
+ macinfo_ptr += m_sect->mb_used_len;
+ if (m_prev) {
+ _dwarf_p_dealloc(dbg, (Dwarf_Small *) m_prev);
+ m_prev = 0;
+ }
+ m_prev = m_sect;
+ }
+ *macinfo_ptr = 0; /* the type code of 0 as last entry */
if (m_prev) {
- _dwarf_p_dealloc(dbg, (Dwarf_Small *) m_prev);
- m_prev = 0;
+ _dwarf_p_dealloc(dbg, (Dwarf_Small *) m_prev);
+ m_prev = 0;
}
dbg->de_first_macinfo = NULL;