diff options
author | Petr Machata <pmachata@redhat.com> | 2009-05-05 16:40:09 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2009-05-05 16:40:09 +0200 |
commit | e2312613319efc397d2dc2285e84268b7b54dbb5 (patch) | |
tree | 2862cff76f10d6a0452e15b048bbe07c93a3946d /libdw | |
parent | 5e7f6f695bb91f1885e9ec0d8892533df7e3bcf8 (diff) | |
parent | 589b3d302f0d2b8dff71c64aff9e285d9005c2e2 (diff) | |
download | elfutils-e2312613319efc397d2dc2285e84268b7b54dbb5.tar.gz |
Merge commit 'origin/master' into pmachata/pending
Conflicts:
libdw/dwarf_error.c
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 63 | ||||
-rw-r--r-- | libdw/Makefile.am | 10 | ||||
-rw-r--r-- | libdw/dwarf.h | 49 | ||||
-rw-r--r-- | libdw/dwarf_error.c | 80 | ||||
-rw-r--r-- | libdw/dwarf_getattrs.c | 33 | ||||
-rw-r--r-- | libdw/dwarf_getsrclines.c | 6 | ||||
-rw-r--r-- | libdw/dwarf_haschildren.c | 4 | ||||
-rw-r--r-- | libdw/dwarf_ranges.c | 11 | ||||
-rw-r--r-- | libdw/libdwP.h | 49 |
9 files changed, 161 insertions, 144 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index fb1a8b0a..93a59673 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,8 +1,69 @@ +2009-04-15 Roland McGrath <roland@redhat.com> + + * dwarf.h (DW_CIE_ID): Removed. + (DW_CIE_ID_32, DW_CIE_ID_64): New constants replace it. + +2009-04-01 Roland McGrath <roland@redhat.com> + + * dwarf.h: Add DW_CFA_GNU_negative_offset_extended. + +2009-01-28 Roland McGrath <roland@redhat.com> + + * libdwP.h (struct Dwarf_Line_s): Move out of struct Dwarf_Lines_s + defn so C++ doesn't scope the name to not match the Dwarf_Line typedef. + + * libdwP.h (struct Dwarf_Files_s): Replace dbg field with cu field. + +2009-01-26 Roland McGrath <roland@redhat.com> + + * dwarf_ranges.c: Return 0 when no ranges or *_pc attrs at all. + +2009-01-25 Roland McGrath <roland@redhat.com> + + * dwarf_getattrs.c: Correctly skip attribute values when restarting. + +2009-01-23 Roland McGrath <roland@redhat.com> + + * Makefile.am ($(srcdir)/known-dwarf.h): Target renamed back. + Put these rules under if MAINTAINER_MODE. + +2009-01-22 Roland McGrath <roland@redhat.com> + + * dwarf.h: Add DW_OP_GNU_encoded_addr. + +2009-01-21 Roland McGrath <roland@redhat.com> + + * Makefile.am (CLEANFILES): Renamed to ... + (MOSTLYCLEANFILES): ... here. + (CLEANFILES): New variable, add known-dwarf.h. + +2009-01-17 Roland McGrath <roland@redhat.com> + + * Makefile.am (known-dwarf.h): Target renamed, not in $(srcdir). + Make it unconditional. + (BUILT_SOURCES): Updated. + + * dwarf.h: Add description comments for DW_LANG_* values. + + * Makefile.am [MAINTAINER_MODE] + ($(srcdir)/known-dwarf.h): New target. + (BUILT_SOURCES): Add it. + + * dwarf.h: Add DW_OP_GNU_push_tls_address, DW_OP_GNU_uninit. + +2009-01-10 Ulrich Drepper <drepper@redhat.com> + + * dwarf_error.c: Always use __thread. Remove all !USE_TLS code. + 2009-01-08 Roland McGrath <roland@redhat.com> * Makefile.am (libdw.so): Don't depend on $(zip_LIBS), just link it in. -2009-01-06 Roland McGrath <roland@redhat.com> +2008-01-06 Roland McGrath <roland@redhat.com> + + * libdwP.h (struct Dwarf_Abbrev): Change type of 'has_children' to bool. + Reorder members. + * dwarf_haschildren.c: Return -1 for error case, not 0. * Makefile.am (libdw.so): Link in $(zip_LIBS). diff --git a/libdw/Makefile.am b/libdw/Makefile.am index 56c7a2ff..e624ac10 100644 --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -85,6 +85,14 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ libdw_visit_scopes.c \ dwarf_entry_breakpoints.c +if MAINTAINER_MODE +BUILT_SOURCES = $(srcdir)/known-dwarf.h +MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h +$(srcdir)/known-dwarf.h: $(top_srcdir)/config/known-dwarf.awk $(srcdir)/dwarf.h + $(AWK) -f $^ > $@.new + mv -f $@.new $@ +endif + if !MUDFLAP libdw_pic_a_SOURCES = am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os) @@ -130,4 +138,4 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h EXTRA_DIST = libdw.map -CLEANFILES = $(am_libdw_pic_a_OBJECTS) *.gcno *.gcda libdw.so.$(VERSION) +MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) *.gcno *.gcda libdw.so.$(VERSION) diff --git a/libdw/dwarf.h b/libdw/dwarf.h index 091519c5..0546e3eb 100644 --- a/libdw/dwarf.h +++ b/libdw/dwarf.h @@ -1,5 +1,5 @@ /* This file defines standard DWARF types, structures, and macros. - Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008 Red Hat, Inc. + Copyright (C) 2000,2002,2005,2006,2007,2008,2009 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -432,6 +432,11 @@ enum DW_OP_call_frame_cfa = 0x9c,/* CFA as determined by CFI. */ DW_OP_bit_piece = 0x9d, /* ULEB128 size and ULEB128 offset in bits. */ + /* GNU extensions. */ + DW_OP_GNU_push_tls_address = 0xe0, + DW_OP_GNU_uninit = 0xf0, + DW_OP_GNU_encoded_addr = 0xf1, + DW_OP_lo_user = 0xe0, /* Implementation-defined range start. */ DW_OP_hi_user = 0xff /* Implementation-defined range end. */ }; @@ -515,25 +520,25 @@ enum /* DWARF language encodings. */ enum { - DW_LANG_C89 = 0x0001, - DW_LANG_C = 0x0002, - DW_LANG_Ada83 = 0x0003, - DW_LANG_C_plus_plus = 0x0004, - DW_LANG_Cobol74 = 0x0005, - DW_LANG_Cobol85 = 0x0006, - DW_LANG_Fortran77 = 0x0007, - DW_LANG_Fortran90 = 0x0008, - DW_LANG_Pascal83 = 0x0009, - DW_LANG_Modula2 = 0x000a, - DW_LANG_Java = 0x000b, - DW_LANG_C99 = 0x000c, - DW_LANG_Ada95 = 0x000d, - DW_LANG_Fortran95 = 0x000e, - DW_LANG_PL1 = 0x000f, - DW_LANG_Objc = 0x0010, - DW_LANG_ObjC_plus_plus = 0x0011, - DW_LANG_UPC = 0x0012, - DW_LANG_D = 0x0013, + DW_LANG_C89 = 0x0001, /* ISO C:1989 */ + DW_LANG_C = 0x0002, /* C */ + DW_LANG_Ada83 = 0x0003, /* ISO Ada:1983 */ + DW_LANG_C_plus_plus = 0x0004, /* ISO C++:1998 */ + DW_LANG_Cobol74 = 0x0005, /* ISO Cobol:1974 */ + DW_LANG_Cobol85 = 0x0006, /* ISO Cobol:1985 */ + DW_LANG_Fortran77 = 0x0007, /* ISO FORTRAN 77 */ + DW_LANG_Fortran90 = 0x0008, /* ISO Fortran 90 */ + DW_LANG_Pascal83 = 0x0009, /* ISO Pascal:1983 */ + DW_LANG_Modula2 = 0x000a, /* ISO Modula-2:1996 */ + DW_LANG_Java = 0x000b, /* Java */ + DW_LANG_C99 = 0x000c, /* ISO C:1999 */ + DW_LANG_Ada95 = 0x000d, /* ISO Ada:1995 */ + DW_LANG_Fortran95 = 0x000e, /* ISO Fortran 95 */ + DW_LANG_PL1 = 0x000f, /* ISO PL/1:1976 */ + DW_LANG_Objc = 0x0010, /* Objective-C */ + DW_LANG_ObjC_plus_plus = 0x0011, /* Objective-C++ */ + DW_LANG_UPC = 0x0012, /* Unified Parallel C */ + DW_LANG_D = 0x0013, /* D */ DW_LANG_lo_user = 0x8000, DW_LANG_Mips_Assembler = 0x8001, @@ -665,13 +670,15 @@ enum DW_CFA_MIPS_advance_loc8 = 0x1d, DW_CFA_GNU_window_save = 0x2d, DW_CFA_GNU_args_size = 0x2e, + DW_CFA_GNU_negative_offset_extended = 0x2f, DW_CFA_high_user = 0x3f }; /* ID indicating CIE as opposed to FDE in .debug_frame. */ enum { - DW_CIE_ID = 0xffffffff + DW_CIE_ID_32 = 0xffffffffU, /* In 32-bit format CIE header. */ + DW_CIE_ID_64 = 0xffffffffffffffffULL /* In 64-bit format CIE header. */ }; diff --git a/libdw/dwarf_error.c b/libdw/dwarf_error.c index ee1e7faa..86ff8213 100644 --- a/libdw/dwarf_error.c +++ b/libdw/dwarf_error.c @@ -1,5 +1,5 @@ /* Retrieve ELF descriptor used for DWARF access. - Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -58,46 +58,14 @@ #include "libdwP.h" -#ifdef USE_TLS /* The error number. */ static __thread int global_error; -#else -/* This is the key for the thread specific memory. */ -static tls_key_t key; - -/* The error number. Used in non-threaded programs. */ -static int global_error; -static bool threaded; -/* We need to initialize the thread-specific data. */ -once_define (static, once); - -/* The initialization and destruction functions. */ -static void init (void); -static void __attribute__ ((unused)) free_key_mem (void *mem); -#endif /* TLS */ int dwarf_errno (void) { - int result; - -#ifndef USE_TLS - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if (threaded) - { - /* We do not allocate memory for the data. It is only a word. - We can store it in place of the pointer. */ - result = (intptr_t) getspecific (key); - - setspecific (key, (void *) (intptr_t) DWARF_E_NOERROR); - return result; - } -#endif /* TLS */ - - result = global_error; + int result = global_error; global_error = DWARF_E_NOERROR; return result; } @@ -151,16 +119,6 @@ void __libdw_seterrno (value) int value; { -#ifndef USE_TLS - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if (threaded) - /* We do not allocate memory for the data. It is only a word. - We can store it in place of the pointer. */ - setspecific (key, (void *) (intptr_t) value); -#endif /* TLS */ - global_error = (value >= 0 && value < (int) nerrmsgs ? value : DWARF_E_UNKNOWN_ERROR); } @@ -170,19 +128,7 @@ const char * dwarf_errmsg (error) int error; { - int last_error; - -#ifndef USE_TLS - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if ((error == 0 || error == -1) && threaded) - /* We do not allocate memory for the data. It is only a word. - We can store it in place of the pointer. */ - last_error = (intptr_t) getspecific (key); - else -#endif /* TLS */ - last_error = global_error; + int last_error = global_error; if (error == 0) return last_error != 0 ? _(errmsgs[last_error]) : NULL; @@ -192,23 +138,3 @@ dwarf_errmsg (error) return _(errmsgs[error == -1 ? last_error : error]); } INTDEF(dwarf_errmsg) - - -#ifndef USE_TLS -/* Free the thread specific data, this is done if a thread terminates. */ -static void -free_key_mem (void *mem __attribute__ ((unused))) -{ - setspecific (key, NULL); -} - - -/* Initialize the key for the global variable. */ -static void -init (void) -{ - if (key_create (&key, free_key_mem) == 0) - /* Creating the key succeeded. */ - threaded = true; -} -#endif /* TLS */ diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c index 42f25ca0..051dc25f 100644 --- a/libdw/dwarf_getattrs.c +++ b/libdw/dwarf_getattrs.c @@ -1,5 +1,5 @@ /* Get attributes of the DIE. - Copyright (C) 2004, 2005, 2008 Red Hat, Inc. + Copyright (C) 2004, 2005, 2008, 2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -62,6 +62,9 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), if (die == NULL) return -1l; + if (unlikely (offset == 1)) + return 1; + const unsigned char *die_addr = die->addr; /* Get the abbreviation code. */ @@ -80,7 +83,8 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), } /* This is where the attributes start. */ - const unsigned char *attrp = die->abbrev->attrp + offset; + const unsigned char *attrp = die->abbrev->attrp; + const unsigned char *const offset_attrp = die->abbrev->attrp + offset; /* Go over the list of attributes. */ Dwarf *dbg = die->cu->dbg; @@ -108,16 +112,21 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), offset of an attribute. */ return 1l; - /* Fill in the rest. */ - attr.valp = (unsigned char *) die_addr; - attr.cu = die->cu; - - /* Now call the callback function. */ - if (callback (&attr, arg) != DWARF_CB_OK) - /* Return the offset of the start of the attribute, so that - dwarf_getattrs() can be restarted from this point if the - caller so desires. */ - return remembered_attrp - die->abbrev->attrp; + /* If we are not to OFFSET_ATTRP yet, we just have to skip + the values of the intervening attributes. */ + if (remembered_attrp >= offset_attrp) + { + /* Fill in the rest. */ + attr.valp = (unsigned char *) die_addr; + attr.cu = die->cu; + + /* Now call the callback function. */ + if (callback (&attr, arg) != DWARF_CB_OK) + /* Return the offset of the start of the attribute, so that + dwarf_getattrs() can be restarted from this point if the + caller so desires. */ + return remembered_attrp - die->abbrev->attrp; + } /* Skip over the rest of this attribute (if there is any). */ if (attr.form != 0) diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index 9b3c97af..fe0e67d6 100644 --- a/libdw/dwarf_getsrclines.c +++ b/libdw/dwarf_getsrclines.c @@ -1,5 +1,5 @@ /* Return line number information of CU. - Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc. + Copyright (C) 2004-2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -634,8 +634,8 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines) dirs[i] = dirarray[i]->dir; dirs[ndirlist] = NULL; - /* Remember the debugging descriptor. */ - files->dbg = dbg; + /* Remember the referring CU. */ + files->cu = cu; /* Make the file data structure available through the CU. */ cu->files = files; diff --git a/libdw/dwarf_haschildren.c b/libdw/dwarf_haschildren.c index fe431955..d9a47ad2 100644 --- a/libdw/dwarf_haschildren.c +++ b/libdw/dwarf_haschildren.c @@ -1,5 +1,5 @@ /* Return string associated with given attribute. - Copyright (C) 2003, 2005 Red Hat, Inc. + Copyright (C) 2003, 2005, 2008 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2003. @@ -77,7 +77,7 @@ dwarf_haschildren (die) if (unlikely (die->abbrev == DWARF_END_ABBREV)) { __libdw_seterrno (DWARF_E_INVALID_DWARF); - return 0; + return -1; } return die->abbrev->has_children; diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c index 89da0af4..1eef617b 100644 --- a/libdw/dwarf_ranges.c +++ b/libdw/dwarf_ranges.c @@ -1,5 +1,5 @@ /* Enumerate the PC ranges covered by a DIE. - Copyright (C) 2005, 2007 Red Hat, Inc. + Copyright (C) 2005, 2007, 2009 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -78,8 +78,9 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep, /* We have to look for a noncontiguous range. */ const Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_ranges]; - if (d == NULL) + if (d == NULL && offset != 0) { + no_ranges: __libdw_seterrno (DWARF_E_NO_DEBUG_RANGES); return -1; } @@ -90,13 +91,17 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep, Dwarf_Attribute *attr = INTUSE(dwarf_attr) (die, DW_AT_ranges, &attr_mem); if (attr == NULL) - return -1; + /* No PC attributes in this DIE at all, so an empty range list. */ + return 0; /* Must have the form data4 or data8 which act as an offset. */ Dwarf_Word start_offset; if (INTUSE(dwarf_formudata) (attr, &start_offset) != 0) return -1; + if (d == NULL) + goto no_ranges; + offset = start_offset; assert ((Dwarf_Word) offset == start_offset); diff --git a/libdw/libdwP.h b/libdw/libdwP.h index f805295f..1d5a9b27 100644 --- a/libdw/libdwP.h +++ b/libdw/libdwP.h @@ -1,5 +1,5 @@ /* Internal definitions for libdwarf. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. + Copyright (C) 2002-2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -194,12 +194,12 @@ struct Dwarf /* Abbreviation representation. */ struct Dwarf_Abbrev { + Dwarf_Off offset; + unsigned char *attrp; + unsigned int attrcnt; unsigned int code; unsigned int tag; - int has_children; - unsigned int attrcnt; - unsigned char *attrp; - Dwarf_Off offset; + bool has_children; }; #include "dwarf_abbrev_hash.h" @@ -208,7 +208,7 @@ struct Dwarf_Abbrev /* Files in line information records. */ struct Dwarf_Files_s { - Dwarf *dbg; + struct Dwarf_CU *cu; unsigned int ndirs; unsigned int nfiles; struct Dwarf_Fileinfo_s @@ -223,26 +223,27 @@ typedef struct Dwarf_Fileinfo_s Dwarf_Fileinfo; /* Representation of a row in the line table. */ -struct Dwarf_Lines_s - { - size_t nlines; - struct Dwarf_Line_s - { - Dwarf_Addr addr; - unsigned int file; - int line; - unsigned short int column; - unsigned int is_stmt:1; - unsigned int basic_block:1; - unsigned int end_sequence:1; - unsigned int prologue_end:1; - unsigned int epilogue_begin:1; - - Dwarf_Files *files; - } info[0]; - }; +struct Dwarf_Line_s +{ + Dwarf_Addr addr; + unsigned int file; + int line; + unsigned short int column; + unsigned int is_stmt:1; + unsigned int basic_block:1; + unsigned int end_sequence:1; + unsigned int prologue_end:1; + unsigned int epilogue_begin:1; + Dwarf_Files *files; +}; + +struct Dwarf_Lines_s +{ + size_t nlines; + struct Dwarf_Line_s info[0]; +}; /* Representation of address ranges. */ struct Dwarf_Aranges_s |