* libdw/dwarf_begin_elf.c (dwarf_begin_elf): Init macro_lock.
* libdw/dwarf_end.c (cu_free): Free src_lock.
(dwarf_end): Free macro_lock.
* libdw/dwarf_getsrcfiles.c (dwarf_getsrcfiles): Use src_lock.
* libdw/dwarf_getsrclines.c (dwarf_getsrclines): Ditto.
* libdw/dwarf_macro_getsrclines.c (dwarf_macro_getsrclines): Use
macro_lock.
* libdw/libdwP.h (struct Dwarf): Define macro_lock.
(struct Dwarf_CU): Define src_lock.
* libdw/libdw_findcu.c (__libdw_intern_next_unit): Init src_lock.
Signed-off-by: Aaron Merey <amerey@redhat.com>
return NULL;
}
mutex_init (result->dwarf_lock);
+ mutex_init (result->macro_lock);
eu_search_tree_init (&result->cu_tree);
eu_search_tree_init (&result->tu_tree);
eu_search_tree_init (&result->split_tree);
Dwarf_Abbrev_Hash_free (&p->abbrev_hash);
rwlock_fini (p->abbrev_lock);
rwlock_fini (p->split_lock);
+ mutex_fini (p->src_lock);
/* Free split dwarf one way (from skeleton to split). */
if (p->unit_type == DW_UT_skeleton
free (dwarf->mem_tails);
pthread_rwlock_destroy (&dwarf->mem_rwl);
mutex_fini (dwarf->dwarf_lock);
+ mutex_fini (dwarf->macro_lock);
/* Free the pubnames helper structure. */
free (dwarf->pubnames_sets);
}
int res = -1;
+ struct Dwarf_CU *const cu = cudie->cu;
+ mutex_lock (cudie->cu->src_lock);
/* Get the information if it is not already known. */
- struct Dwarf_CU *const cu = cudie->cu;
if (cu->files == NULL)
{
/* For split units there might be a simple file table (without lines).
Dwarf_Off debug_line_offset;
if (__libdw_formptr (stmt_list, IDX_debug_line, DWARF_E_NO_DEBUG_LINE,
NULL, &debug_line_offset) == NULL)
- return -1;
+ {
+ mutex_unlock (cudie->cu->src_lock);
+ return -1;
+ }
res = __libdw_getsrcfiles (cu->dbg, debug_line_offset,
__libdw_getcompdir (cudie),
*nfiles = cu->files->nfiles;
}
- // XXX Eventually: unlocking here.
-
+ mutex_unlock (cudie->cu->src_lock);
return res;
}
INTDEF (dwarf_getsrcfiles)
return -1;
}
- /* Get the information if it is not already known. */
struct Dwarf_CU *const cu = cudie->cu;
+ mutex_lock (cu->src_lock);
+
+ /* Get the information if it is not already known. */
if (cu->lines == NULL)
{
/* For split units always pick the lines from the skeleton. */
*lines = cu->lines;
*nlines = cu->lines->nlines;
}
+
+ mutex_unlock (cu->src_lock);
return res;
}
__libdw_seterrno (DWARF_E_NO_DEBUG_LINE);
+ mutex_unlock (cu->src_lock);
return -1;
}
Dwarf_Off debug_line_offset;
if (__libdw_formptr (stmt_list, IDX_debug_line, DWARF_E_NO_DEBUG_LINE,
NULL, &debug_line_offset) == NULL)
- return -1;
+ {
+ mutex_unlock (cu->src_lock);
+ return -1;
+ }
if (__libdw_getsrclines (cu->dbg, debug_line_offset,
__libdw_getcompdir (cudie),
cu->address_size, &cu->lines, &cu->files) < 0)
- return -1;
+ {
+ mutex_unlock (cu->src_lock);
+ return -1;
+ }
}
else if (cu->lines == (void *) -1l)
- return -1;
+ {
+ mutex_unlock (cu->src_lock);
+ return -1;
+ }
*lines = cu->lines;
*nlines = cu->lines->nlines;
- // XXX Eventually: unlocking here.
-
+ mutex_unlock (cu->src_lock);
return 0;
}
INTDEF(dwarf_getsrclines)
/* macro is declared NN */
Dwarf_Macro_Op_Table *const table = macro->table;
+
+ mutex_lock (table->dbg->macro_lock);
if (table->files == NULL)
{
Dwarf_Off line_offset = table->line_offset;
{
*files = NULL;
*nfiles = 0;
+ mutex_unlock (table->dbg->macro_lock);
return 0;
}
}
if (table->files == (void *) -1)
- return -1;
+ {
+ mutex_unlock (table->dbg->macro_lock);
+ return -1;
+ }
*files = table->files;
*nfiles = table->files->nfiles;
+
+ mutex_unlock (table->dbg->macro_lock);
return 0;
}
pthread_rwlock_t mem_rwl;
/* Recursive mutex intended for setting/getting alt_dwarf, next_tu_offset,
- and next_cu_offset. Covers dwarf_getsrclines, dwarf_getsrcfiles and
- dwarf_macro_getsrcfiles. Should also be held when calling
+ and next_cu_offset. Should be held when calling
__libdw_intern_next_unit. */
mutex_define(, dwarf_lock);
+ /* Synchronize access to dwarf_macro_getsrcfiles. */
+ mutex_define(, macro_lock);
+
/* Internal memory handling. This is basically a simplified thread-local
reimplementation of obstacks. Unfortunately the standard obstack
implementation is not usable in libraries. */
Covers __libdw_find_split_unit. */
rwlock_define(, split_lock);
+ /* Synchronize access to the lines and files members.
+ Covers dwarf_getsrclines and dwarf_getsrcfiles. */
+ mutex_define(, src_lock);
+
/* Memory boundaries of this CU. */
void *startp;
void *endp;
eu_search_tree_init (&newp->locs_tree);
rwlock_init (newp->abbrev_lock);
rwlock_init (newp->split_lock);
+ mutex_init (newp->src_lock);
/* v4 debug type units have version == 4 and unit_type == DW_UT_type. */
if (debug_types)