X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsolib-frv.c;h=fdd4b3453057023755d155f11fa8f084dc36bf93;hb=abdb711e0855f0597a96db0486b598144b788212;hp=e11de253b06a656c5eb1f1c97c9288403950198d;hpb=af43057bafa7260dbcc453d2acc47eb63b974c50;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index e11de253b0..fdd4b34530 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -1,5 +1,5 @@ /* Handle FR-V (FDPIC) shared libraries for GDB, the GNU Debugger. - Copyright (C) 2004-2017 Free Software Foundation, Inc. + Copyright (C) 2004-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -204,13 +204,19 @@ struct ext_link_map struct lm_info_frv : public lm_info_base { + ~lm_info_frv () + { + xfree (this->map); + xfree (this->dyn_syms); + xfree (this->dyn_relocs); + } /* The loadmap, digested into an easier to use form. */ - struct int_elf32_fdpic_loadmap *map; + int_elf32_fdpic_loadmap *map = NULL; /* The GOT address for this link map entry. */ - CORE_ADDR got_value; + CORE_ADDR got_value = 0; /* The link map address, needed for frv_fetch_objfile_link_map(). */ - CORE_ADDR lm_addr; + CORE_ADDR lm_addr = 0; /* Cached dynamic symbol table and dynamic relocs initialized and used only by find_canonical_descriptor_in_load_object(). @@ -222,10 +228,9 @@ struct lm_info_frv : public lm_info_base supplied to the first call. Thus the caching of the dynamic symbols (dyn_syms) is critical for correct operation. The caching of the dynamic relocations could be dispensed with. */ - asymbol **dyn_syms; - arelent **dyn_relocs; - int dyn_reloc_count; /* Number of dynamic relocs. */ - + asymbol **dyn_syms = NULL; + arelent **dyn_relocs = NULL; + int dyn_reloc_count = 0; /* Number of dynamic relocs. */ }; /* The load map, got value, etc. are not available from the chain @@ -241,7 +246,7 @@ static int enable_break2 (void); /* Implement the "open_symbol_file_object" target_so_ops method. */ static int -open_symbol_file_object (void *from_ttyp) +open_symbol_file_object (int from_tty) { /* Unimplemented. */ return 0; @@ -372,7 +377,7 @@ frv_current_sos (void) if (got_addr != mgot) { int errcode; - char *name_buf; + gdb::unique_xmalloc_ptr name_buf; struct int_elf32_fdpic_loadmap *loadmap; struct so_list *sop; CORE_ADDR addr; @@ -390,7 +395,7 @@ frv_current_sos (void) } sop = XCNEW (struct so_list); - lm_info_frv *li = XCNEW (lm_info_frv); + lm_info_frv *li = new lm_info_frv; sop->lm_info = li; li->map = loadmap; li->got_value = got_addr; @@ -404,16 +409,16 @@ frv_current_sos (void) if (solib_frv_debug) fprintf_unfiltered (gdb_stdlog, "current_sos: name = %s\n", - name_buf); + name_buf.get ()); if (errcode != 0) warning (_("Can't read pathname for link map entry: %s."), safe_strerror (errcode)); else { - strncpy (sop->so_name, name_buf, SO_NAME_MAX_PATH_SIZE - 1); + strncpy (sop->so_name, name_buf.get (), + SO_NAME_MAX_PATH_SIZE - 1); sop->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; - xfree (name_buf); strcpy (sop->so_original_name, sop->so_name); } @@ -556,14 +561,13 @@ enable_break2 (void) mechanism to find the dynamic linker's base address. */ gdb_bfd_ref_ptr tmp_bfd; - TRY + try { tmp_bfd = solib_bfd_open (buf); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception &ex) { } - END_CATCH if (tmp_bfd == NULL) { @@ -764,8 +768,6 @@ frv_relocate_main_executable (void) int status; CORE_ADDR exec_addr, interp_addr; struct int_elf32_fdpic_loadmap *ldm; - struct cleanup *old_chain; - struct section_offsets *new_offsets; int changed; struct obj_section *osect; @@ -783,14 +785,12 @@ frv_relocate_main_executable (void) if (ldm == NULL) error (_("Unable to load the executable's loadmap.")); - if (main_executable_lm_info) - xfree (main_executable_lm_info); - main_executable_lm_info = XCNEW (lm_info_frv); + delete main_executable_lm_info; + main_executable_lm_info = new lm_info_frv; main_executable_lm_info->map = ldm; - new_offsets = XCNEWVEC (struct section_offsets, - symfile_objfile->num_sections); - old_chain = make_cleanup (xfree, new_offsets); + gdb::unique_xmalloc_ptr new_offsets + (XCNEWVEC (struct section_offsets, symfile_objfile->num_sections)); changed = 0; ALL_OBJFILE_OSECTIONS (symfile_objfile, osect) @@ -824,9 +824,7 @@ frv_relocate_main_executable (void) } if (changed) - objfile_relocate (symfile_objfile, new_offsets); - - do_cleanups (old_chain); + objfile_relocate (symfile_objfile, new_offsets.get ()); /* Now that symfile_objfile has been relocated, we can compute the GOT value and stash it away. */ @@ -859,14 +857,9 @@ frv_clear_solib (void) lm_base_cache = 0; enable_break2_done = 0; main_lm_addr = 0; - if (main_executable_lm_info != 0) - { - xfree (main_executable_lm_info->map); - xfree (main_executable_lm_info->dyn_syms); - xfree (main_executable_lm_info->dyn_relocs); - xfree (main_executable_lm_info); - main_executable_lm_info = 0; - } + + delete main_executable_lm_info; + main_executable_lm_info = NULL; } static void @@ -874,10 +867,7 @@ frv_free_so (struct so_list *so) { lm_info_frv *li = (lm_info_frv *) so->lm_info; - xfree (li->map); - xfree (li->dyn_syms); - xfree (li->dyn_relocs); - xfree (li); + delete li; } static void @@ -1157,9 +1147,6 @@ frv_fetch_objfile_link_map (struct objfile *objfile) struct target_so_ops frv_so_ops; -/* Provide a prototype to silence -Wmissing-prototypes. */ -extern initialize_file_ftype _initialize_frv_solib; - void _initialize_frv_solib (void) {