int pt_phdr_p = 0;
/* Get required auxv elements from target. */
- if (target_auxv_search (¤t_target, AT_PHDR, &at_phdr) <= 0)
+ if (target_auxv_search (current_top_target (), AT_PHDR, &at_phdr) <= 0)
return 0;
- if (target_auxv_search (¤t_target, AT_PHENT, &at_phent) <= 0)
+ if (target_auxv_search (current_top_target (), AT_PHENT, &at_phent) <= 0)
return 0;
- if (target_auxv_search (¤t_target, AT_PHNUM, &at_phnum) <= 0)
+ if (target_auxv_search (current_top_target (), AT_PHNUM, &at_phnum) <= 0)
return 0;
if (!at_phdr || !at_phnum)
return 0;
gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ());
/* Fetch the list of shared libraries. */
- gdb::unique_xmalloc_ptr<char> svr4_library_document
- = target_read_stralloc (¤t_target, TARGET_OBJECT_LIBRARIES_SVR4,
+ gdb::optional<gdb::char_vector> svr4_library_document
+ = target_read_stralloc (current_top_target (), TARGET_OBJECT_LIBRARIES_SVR4,
annex);
- if (svr4_library_document == NULL)
+ if (!svr4_library_document)
return 0;
- return svr4_parse_libraries (svr4_library_document.get (), list);
+ return svr4_parse_libraries (svr4_library_document->data (), list);
}
#else
struct svr4_info *info = get_svr4_info ();
struct probe_and_action *pa;
enum probe_action action;
- struct cleanup *old_chain, *usm_chain;
+ struct cleanup *old_chain;
struct value *val = NULL;
CORE_ADDR pc, debug_base, lm = 0;
struct frame_info *frame = get_current_frame ();
so we can guarantee that the dynamic linker's sections are in the
section map. We can therefore inhibit section map updates across
these calls to evaluate_argument and save a lot of time. */
- inhibit_section_map_updates (current_program_space);
- usm_chain = make_cleanup (resume_section_map_updates_cleanup,
- current_program_space);
+ {
+ scoped_restore inhibit_updates
+ = inhibit_section_map_updates (current_program_space);
- TRY
- {
- val = pa->prob->evaluate_argument (1, frame);
- }
- CATCH (ex, RETURN_MASK_ERROR)
- {
- exception_print (gdb_stderr, ex);
- val = NULL;
- }
- END_CATCH
+ TRY
+ {
+ val = pa->prob->evaluate_argument (1, frame);
+ }
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ exception_print (gdb_stderr, ex);
+ val = NULL;
+ }
+ END_CATCH
- if (val == NULL)
- {
- do_cleanups (old_chain);
- return;
- }
+ if (val == NULL)
+ {
+ do_cleanups (old_chain);
+ return;
+ }
- debug_base = value_as_address (val);
- if (debug_base == 0)
- {
- do_cleanups (old_chain);
- return;
- }
+ debug_base = value_as_address (val);
+ if (debug_base == 0)
+ {
+ do_cleanups (old_chain);
+ return;
+ }
- /* Always locate the debug struct, in case it moved. */
- info->debug_base = 0;
- if (locate_base (info) == 0)
- {
- do_cleanups (old_chain);
- return;
- }
+ /* Always locate the debug struct, in case it moved. */
+ info->debug_base = 0;
+ if (locate_base (info) == 0)
+ {
+ do_cleanups (old_chain);
+ return;
+ }
- /* GDB does not currently support libraries loaded via dlmopen
- into namespaces other than the initial one. We must ignore
- any namespace other than the initial namespace here until
- support for this is added to GDB. */
- if (debug_base != info->debug_base)
- action = DO_NOTHING;
+ /* GDB does not currently support libraries loaded via dlmopen
+ into namespaces other than the initial one. We must ignore
+ any namespace other than the initial namespace here until
+ support for this is added to GDB. */
+ if (debug_base != info->debug_base)
+ action = DO_NOTHING;
- if (action == UPDATE_OR_RELOAD)
- {
- TRY
- {
- val = pa->prob->evaluate_argument (2, frame);
- }
- CATCH (ex, RETURN_MASK_ERROR)
- {
- exception_print (gdb_stderr, ex);
- do_cleanups (old_chain);
- return;
- }
- END_CATCH
+ if (action == UPDATE_OR_RELOAD)
+ {
+ TRY
+ {
+ val = pa->prob->evaluate_argument (2, frame);
+ }
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ exception_print (gdb_stderr, ex);
+ do_cleanups (old_chain);
+ return;
+ }
+ END_CATCH
- if (val != NULL)
- lm = value_as_address (val);
+ if (val != NULL)
+ lm = value_as_address (val);
- if (lm == 0)
- action = FULL_RELOAD;
- }
+ if (lm == 0)
+ action = FULL_RELOAD;
+ }
- /* Resume section map updates. */
- do_cleanups (usm_chain);
+ /* Resume section map updates. Closing the scope is
+ sufficient. */
+ }
if (action == UPDATE_OR_RELOAD)
{
struct obj_section *os;
sym_addr = gdbarch_addr_bits_remove
- (target_gdbarch (), gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
- sym_addr,
- ¤t_target));
+ (target_gdbarch (),
+ gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
+ sym_addr,
+ current_top_target ()));
/* On at least some versions of Solaris there's a dynamic relocation
on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if
/* If we were not able to find the base address of the loader
from our so_list, then try using the AT_BASE auxilliary entry. */
if (!load_addr_found)
- if (target_auxv_search (¤t_target, AT_BASE, &load_addr) > 0)
+ if (target_auxv_search (current_top_target (), AT_BASE, &load_addr) > 0)
{
int addr_bit = gdbarch_addr_bit (target_gdbarch ());
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
- ¤t_target);
+ current_top_target ());
svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr);
return 1;
}
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
- ¤t_target);
+ current_top_target ());
svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr);
return 1;
}
if ((bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0)
return 0;
- if (target_auxv_search (¤t_target, AT_ENTRY, &entry_point) <= 0)
+ if (target_auxv_search (current_top_target (), AT_ENTRY, &entry_point) <= 0)
return 0;
exec_displacement = entry_point - bfd_get_start_address (exec_bfd);
/* Strip modifies the flags and alignment of PT_GNU_RELRO.
CentOS-5 has problems with filesz, memsz as well.
+ Strip also modifies memsz of PT_TLS.
See PR 11786. */
- if (phdr2[i].p_type == PT_GNU_RELRO)
+ if (phdr2[i].p_type == PT_GNU_RELRO
+ || phdr2[i].p_type == PT_TLS)
{
Elf32_External_Phdr tmp_phdr = *phdrp;
Elf32_External_Phdr tmp_phdr2 = *phdr2p;
/* Strip modifies the flags and alignment of PT_GNU_RELRO.
CentOS-5 has problems with filesz, memsz as well.
+ Strip also modifies memsz of PT_TLS.
See PR 11786. */
- if (phdr2[i].p_type == PT_GNU_RELRO)
+ if (phdr2[i].p_type == PT_GNU_RELRO
+ || phdr2[i].p_type == PT_TLS)
{
Elf64_External_Phdr tmp_phdr = *phdrp;
Elf64_External_Phdr tmp_phdr2 = *phdr2p;