diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2025-01-01 21:40:05 -0800 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2025-01-02 15:46:48 -0800 |
commit | 63eb193ca47354cbdd0f9aa90fccc607510b302e (patch) | |
tree | 74af620675718c5b84a708a30466f64b94970831 /gprofng/src | |
parent | 74760497497d9912ac6437f16f8abdba87710a2c (diff) | |
download | binutils-63eb193ca47354cbdd0f9aa90fccc607510b302e.zip binutils-63eb193ca47354cbdd0f9aa90fccc607510b302e.tar.gz binutils-63eb193ca47354cbdd0f9aa90fccc607510b302e.tar.bz2 |
gprofng: remove the old archiver
The first versions of Performance Analyzer archived only function names.
This is no longer used. We need a real elf-file.
gprofng/ChangeLog
2025-01-01 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* src/LoadObject.cc: Remove LoadObject::read_archive.
* src/LoadObject.h: Likewise.
* src/data_pckts.h: Remove unused declarations.
* src/parse.cc (process_seg_map_cmd): Don't look for the old archive.
Diffstat (limited to 'gprofng/src')
-rw-r--r-- | gprofng/src/LoadObject.cc | 301 | ||||
-rw-r--r-- | gprofng/src/LoadObject.h | 1 | ||||
-rw-r--r-- | gprofng/src/data_pckts.h | 58 | ||||
-rw-r--r-- | gprofng/src/parse.cc | 9 |
4 files changed, 11 insertions, 358 deletions
diff --git a/gprofng/src/LoadObject.cc b/gprofng/src/LoadObject.cc index fdf2adb..1ca6ab6 100644 --- a/gprofng/src/LoadObject.cc +++ b/gprofng/src/LoadObject.cc @@ -714,36 +714,24 @@ LoadObject::read_stabs () return ARCHIVE_SUCCESS; else { - Arch_status st = ARCHIVE_WRONG_ARCH; Elf *elf = get_elf (); if (elf == NULL) { - if (read_archive () == 0) - st = ARCHIVE_SUCCESS; - else - { - char *msg = dbe_sprintf (GTXT ("*** Warning: Can't open file: %s"), - dbeFile->get_name ()); - warnq->append (new Emsg (CMSG_ERROR, msg)); - delete msg; - } + char *msg = dbe_sprintf (GTXT ("Can't open file: %s"), + dbeFile->get_name ()); + warnq->append (new Emsg (CMSG_ERROR, msg)); + delete msg; + return ARCHIVE_ERR_OPEN; } else if (checksum != 0 && checksum != elf->elf_checksum ()) { - if (read_archive () == 0) - st = ARCHIVE_SUCCESS; - else - { - char *msg = dbe_sprintf ( - GTXT ("*** Note: '%s' has an unexpected checksum value; perhaps it was rebuilt. File ignored"), - dbeFile->get_location ()); - commentq->append (new Emsg (CMSG_ERROR, msg)); - delete msg; - } + char *msg = dbe_sprintf (GTXT ("%s has an unexpected checksum value;" + "perhaps it was rebuilt. File ignored"), + dbeFile->get_location ()); + commentq->append (new Emsg (CMSG_ERROR, msg)); + delete msg; + return ARCHIVE_ERR_OPEN; } - if (st == ARCHIVE_SUCCESS) // An old archive is used - return st; - Stabs::Stab_status status = Stabs::DBGD_ERR_CANT_OPEN_FILE; char *location = dbeFile->get_location (true); if (location == NULL) @@ -784,273 +772,6 @@ LoadObject::read_stabs () return stabs_status; } -#define ARCH_STRLEN(s) ((strlen(s) + 4) & ~0x3 ) - -static int -offsetCmp (const void *a, const void *b) -{ - uint32_t o1 = ((inst_info_t *) a)->offset; - uint32_t o2 = ((inst_info_t *) b)->offset; - return o1 == o2 ? 0 : (o1 < o2 ? -1 : 1); -} - -int -LoadObject::read_archive () -{ - if (arch_name == NULL) - return 1; - Module *mod = NULL; - Function *func = NULL; - char *buf; - Data_window *dwin = new Data_window (arch_name); - if (dwin->not_opened ()) - { - delete dwin; - buf = dbe_sprintf (GTXT ("*** Warning: Error opening file for reading: %s: %s"), - arch_name, strerror (errno)); - warnq->append (new Emsg (CMSG_ERROR, buf)); - delete buf; - return 1; - } - dwin->need_swap_endian = need_swap_endian; - - // Prevent reading earlier archive files, which didn't support versioning. - int64_t offset = 0; - ARCH_common *cpkt = (ARCH_common*) dwin->bind (offset, sizeof (ARCH_common)); - uint16_t v16; - if (cpkt) - { - v16 = (uint16_t) cpkt->type; - if (dwin->decode (v16) != ARCH_SEGMENT) - cpkt = NULL; - } - if (cpkt == NULL) - { - buf = dbe_sprintf (GTXT ("archive file malformed %s"), arch_name); - warnq->append (new Emsg (CMSG_WARN, buf)); - delete buf; - return 1; - } - - char *msg = NULL; - unsigned long long pointer_invalid = 0; - for (int64_t last_offset = -5000;;) - { - cpkt = (ARCH_common*) dwin->bind (offset, sizeof (ARCH_common)); - if (cpkt == NULL) - break; - v16 = (uint16_t) cpkt->size; - uint32_t cpktsize = dwin->decode (v16); - cpkt = (ARCH_common*) dwin->bind (offset, cpktsize); - if ((cpkt == NULL) || (cpktsize == 0)) - { - buf = dbe_sprintf (GTXT ("archive file malformed %s"), arch_name); - warnq->append (new Emsg (CMSG_WARN, buf)); - delete buf; - break; - } - - // Update the progress bar - if (dbeSession->is_interactive () && ((offset - last_offset) >= 5000)) - { - last_offset = offset; - int percent = (int) (100.0 * offset / dwin->get_fsize ()); - if (msg == NULL) - msg = dbe_sprintf (GTXT ("Reading Load Object Data: %s"), name); - theApplication->set_progress (percent, (percent != 0) ? NULL : msg); - } - char *ptr = (char *) cpkt; - v16 = (uint16_t) cpkt->type; - switch (dwin->decode (v16)) - { - case ARCH_SEGMENT: - { - ARCH_segment *aseg = (ARCH_segment*) cpkt; - if (dwin->decode (aseg->version) != ARCH_VERSION) - { - buf = dbe_sprintf (GTXT ("Archive file version mismatch for %s"), arch_name); - warnq->append (new Emsg (CMSG_ERROR, buf)); - delete buf; - if (dbeSession->is_interactive ()) - theApplication->set_progress (0, ""); - return 1; - } - if (size == 0) - size = dwin->decode (aseg->textsz); - Platform_t pltf = (Platform_t) dwin->decode (aseg->platform); - if (pltf != Unknown) - { - platform = pltf; // override if known - wsize = (platform == Sparcv9 || platform == Amd64) ? W64 : W32; - } - break; - } - case ARCH_MSG: - { - ARCH_message *amsg = (ARCH_message*) cpkt; - buf = status_str ((Arch_status) dwin->decode (amsg->errcode)); - commentq->append (new Emsg (CMSG_ARCHIVE, buf)); - free (buf); - break; - } - case ARCH_INF: - { - ARCH_info *ainf = (ARCH_info*) cpkt; - Emsg *m = new Emsg (CMSG_ARCHIVE, (char*) (ainf + 1)); - commentq->append (m); - break; - } - case ARCH_MODULE: - { - ARCH_module *amod = (ARCH_module*) cpkt; - char *str = ((char*) amod) + sizeof (ARCH_module); - if (streq (str, SP_UNKNOWN_NAME) && - streq (str + ARCH_STRLEN (str), SP_UNKNOWN_NAME)) - { - mod = noname; - break; - } - mod = dbeSession->createModule (this, str); - mod->lang_code = (Sp_lang_code) dwin->decode (amod->lang_code); - mod->fragmented = dwin->decode (amod->fragmented); - str += ARCH_STRLEN (str); - mod->set_file_name (dbe_strdup (str)); - modules->put (get_basename (str), mod); - break; - } - case ARCH_FUNCTION: - { - if (mod == NULL) - break; - ARCH_function *afnc = (ARCH_function*) cpkt; - func = dbeSession->createFunction (); - func->img_offset = dwin->decode (afnc->offset); - func->size = dwin->decode (afnc->size); - func->save_addr = dwin->decode (afnc->save_addr) - - dwin->decode (afnc->offset); - func->module = mod; - func->set_name (((char*) afnc) + sizeof (ARCH_function)); - mod->functions->append (func); - functions->append (func); - break; - } - case ARCH_LDINSTR: - if (mod == NULL) - break; - Dprintf (DEBUG_LOADOBJ, "LDINSTR list for %s\n", mod->get_name ()); - if (mod->infoList == NULL) - mod->infoList = new Vector<inst_info_t*>; - for (memop_info_t *mp = (memop_info_t*) (ptr + sizeof (ARCH_aninfo)); - (char*) mp < ptr + cpktsize; mp++) - { - memop_info_t *memop = new memop_info_t; - memop->offset = dwin->decode (mp->offset); - memop->id = dwin->decode (mp->id); - memop->signature = dwin->decode (mp->signature); - memop->datatype_id = dwin->decode (mp->datatype_id); - mod->ldMemops.append (memop); - - inst_info_t *instop = new inst_info_t; - instop->type = CPF_INSTR_TYPE_LD; - instop->offset = memop->offset; - instop->memop = memop; - mod->infoList->incorporate (instop, offsetCmp); - Dprintf (DEBUG_LOADOBJ, - "ld: offset=0x%04x id=0x%08x sig=0x%08x dtid=0x%08x\n", - memop->offset, memop->id, memop->signature, - memop->datatype_id); - } - Dprintf (DEBUG_LOADOBJ, "LDINSTR list of %lld for %s\n", - (long long) mod->ldMemops.size (), mod->get_name ()); - break; - case ARCH_STINSTR: - if (mod == NULL) - break; - Dprintf (DEBUG_LOADOBJ, NTXT ("STINSTR list for %s\n"), mod->get_name ()); - if (mod->infoList == NULL) - mod->infoList = new Vector<inst_info_t*>; - for (memop_info_t *mp = (memop_info_t*) (ptr + sizeof (ARCH_aninfo)); - ((char *) mp) < ptr + cpktsize; mp++) - { - memop_info_t *memop = new memop_info_t; - memop->offset = dwin->decode (mp->offset); - memop->id = dwin->decode (mp->id); - memop->signature = dwin->decode (mp->signature); - memop->datatype_id = dwin->decode (mp->datatype_id); - mod->stMemops.append (memop); - - inst_info_t *instop = new inst_info_t; - instop->type = CPF_INSTR_TYPE_ST; - instop->offset = memop->offset; - instop->memop = memop; - mod->infoList->incorporate (instop, offsetCmp); - Dprintf (DEBUG_LOADOBJ, - "st: offset=0x%04x id=0x%08x sig=0x%08x dtid=0x%08x\n", - memop->offset, memop->id, memop->signature, - memop->datatype_id); - } - Dprintf (DEBUG_LOADOBJ, "STINSTR list of %lld for %s\n", - (long long) mod->stMemops.size (), mod->get_name ()); - break; - case ARCH_PREFETCH: - if (mod == NULL) - break; - Dprintf (DEBUG_LOADOBJ, "PFINSTR list for %s\n", mod->get_name ()); - if (mod->infoList == NULL) - mod->infoList = new Vector<inst_info_t*>; - for (memop_info_t *mp = (memop_info_t*) (ptr + sizeof (ARCH_aninfo)); - ((char*) mp) < ptr + cpkt->size; mp++) - { - memop_info_t *memop = new memop_info_t; - memop->offset = dwin->decode (mp->offset); - memop->id = dwin->decode (mp->id); - memop->signature = dwin->decode (mp->signature); - memop->datatype_id = dwin->decode (mp->datatype_id); - mod->pfMemops.append (memop); - - inst_info_t *instop = new inst_info_t; - instop->type = CPF_INSTR_TYPE_PREFETCH; - instop->offset = memop->offset; - instop->memop = memop; - mod->infoList->incorporate (instop, offsetCmp); - Dprintf (DEBUG_LOADOBJ, - "pf: offset=0x%04x id=0x%08x sig=0x%08x dtid=0x%08x\n", - memop->offset, memop->id, memop->signature, - memop->datatype_id); - } - Dprintf (DEBUG_LOADOBJ, "PFINSTR list of %lld for %s\n", - (long long) mod->pfMemops.size (), mod->get_name ()); - break; - case ARCH_BRTARGET: - if (mod == NULL) - break; - for (target_info_t *tp = (target_info_t*) (ptr + sizeof (ARCH_aninfo)); - ((char*) tp) < ptr + cpkt->size; tp++) - { - target_info_t *bTarget = new target_info_t; - bTarget->offset = dwin->decode (tp->offset); - mod->bTargets.append (bTarget); - } - Dprintf (DEBUG_LOADOBJ, "BRTARGET list of %lld for %s\n", - (long long) mod->infoList->size (), mod->get_name ()); - break; - default: - /* Check if the prointer is valid - should be even. */ - pointer_invalid = (unsigned long long) (offset + cpktsize) & 1; - break; // ignore unknown packets - } - if (pointer_invalid) - break; - offset += cpktsize; - } - delete msg; - delete dwin; - - if (dbeSession->is_interactive ()) - theApplication->set_progress (0, NTXT ("")); - return 0; -} - char * LoadObject::status_str (Arch_status rv, char */*arg*/) { diff --git a/gprofng/src/LoadObject.h b/gprofng/src/LoadObject.h index 990b8b0..14dfe26 100644 --- a/gprofng/src/LoadObject.h +++ b/gprofng/src/LoadObject.h @@ -202,7 +202,6 @@ private: HashMap<char*, Module*> *seg_modules_map; // to find a comparable module static int func_compare (const void *p1, const void *p2); - int read_archive (); void init_datatypes (); void update_datatypes (Module*, Vaddr, uint32_t datatype_id); }; diff --git a/gprofng/src/data_pckts.h b/gprofng/src/data_pckts.h index c25b48e..5152071 100644 --- a/gprofng/src/data_pckts.h +++ b/gprofng/src/data_pckts.h @@ -506,64 +506,6 @@ typedef struct unsigned int size : 16; } ARCH_common; -/* The maximum value that fits into ARCH_common.size */ -#define ARCH_MAX_SIZE 0xffff - -#define ARCH_SEGMENT ARCH_TYPE(SEGMENT, 0) - -typedef struct -{ - ARCH_common common; - int version; - uint32_t inode; - uint32_t textsz; /* text segment size */ - uint32_t platform; /* sparc, intel, etc. */ -} ARCH_segment; - -#define ARCH_MSG ARCH_TYPE(MSG, 0) - -typedef struct -{ - ARCH_common common; - uint32_t errcode; -} ARCH_message; - -#define ARCH_INF ARCH_TYPE(INF, 0) - -typedef struct -{ - ARCH_common common; -} ARCH_info; - -#define ARCH_MODULE ARCH_TYPE(MODULE, 0) - -typedef struct -{ - ARCH_common common; - unsigned int lang_code; - unsigned int fragmented; -} ARCH_module; - -#define ARCH_FUNCTION ARCH_TYPE(FUNCTION, 0) - -typedef struct -{ - ARCH_common common; - uint32_t offset; - uint32_t size; - uint32_t save_addr; -} ARCH_function; - -#define ARCH_LDINSTR ARCH_TYPE(LDINSTR, 0) -#define ARCH_STINSTR ARCH_TYPE(STINSTR, 0) -#define ARCH_PREFETCH ARCH_TYPE(PREFETCH, 0) -#define ARCH_BRTARGET ARCH_TYPE(BRTARGET, 0) - -typedef struct -{ - ARCH_common common; -} ARCH_aninfo; - #define ARCH_JCLASS_LOCATION ARCH_TYPE(JCLASS_LOCATION, 3) typedef struct diff --git a/gprofng/src/parse.cc b/gprofng/src/parse.cc index d14232e..953baf1 100644 --- a/gprofng/src/parse.cc +++ b/gprofng/src/parse.cc @@ -752,15 +752,6 @@ Experiment::process_seg_map_cmd (char */*cmd*/, hrtime_t ts, Vaddr vaddr, lo->dbeFile->sbuf.st_mtime = 0; // Don't check timestamps free (archName); } - else - { - archName = checkFileInArchive (nm, true); - if (archName) - { - lo->set_archname (archName); - lo->need_swap_endian = need_swap_endian; - } - } if (!dbeSession->archive_mode) lo->sync_read_stabs (); } |