int main(int argc, char *argv[]) /* Process command line. */ { optionHash(&argc, argv); scale = optionFloat("scale", scale); maxGap = optionInt("maxGap", maxGap); near = optionInt("near", near); sampleList = optionVal("samples", cloneString(sampleList)); if (argc != 2) usage(); calcGap(argv[1]); return 0; }
/** * \internal Make sure the DBF table, which points to all the memory regions collected * by CCCPSE, is as compact as possible. The goal is to cut the number of ELF * Phdrs down as much as possible by merging adjoining memory regions. In order to do * this, it needs to mark each DBFITEM, which is in protected memory, SPK=0. This * function is therefore in SPK=0 for its duration, and restores SPK1 prior to return. * * \param[in] dbfHdr Address of the Java dump buffer as returned from CCCPSE. * * \return * The number of program headers after merge */ static uintptr_t adjustDBFTable(DBFHDR *dbfHdr) { DBFITEM *dbfTbl = (DBFITEM *) dbfHdr + 1; /* DBTI[0] starts right after dbfHdr */ DBFITEM *pred = dbfTbl; /* Predecessor DBTI */ /* * For first pass only, set pred = curr. We never want to address zero. * We'll use it only to test bitfields which aren't possible to be set * for the very first item. */ DBFITEM *curr = dbfTbl; /* Current DBTI under examination */ DBFITEM *succ = pred + 1; /* Successor DBTI */ DBFITEM *limit = dbfTbl + (dbfHdr->ijavcnt); /* DBTI[n+1] address */ uintptr_t phnum = 0; /* Number of expected Elf64_Phdrs */ uintptr_t wGap; /* ACCUMULATOR: total ibc gap */ void *wVstart; /* WORK: new p_vaddr */ IDATA chunkSize = 0L; /* Semi-permanent per set ... size */ IDATA totalIBCSize = 0L; /* Total sizes of all writeable sets */ KEY0(); /* JDB's in SPK=0, get auth to write it.*/ while (curr < limit) { memset(DBTITYPE, 0, sizeof(char) + (sizeof(DBTIGAP)));/* Clear DBTI tail */ calcGap(curr, succ, &wGap); /* Get GAP size. */ if (0 == wGap) { /* * This pair qualifies to be combined */ if (PSETSTRT || PSETMIDL) { CSETMIDL = TRUE; /* It is either mid-set ... */ } else { /* ... or starts a new set. */ CSETSTRT = TRUE; wVstart = DBTIVADDR; /* If it's a start, hold the start vaddr. */ chunkSize += DBTISIZ; DBTIGAP = wGap; } } else { /* * This pair does not qualify to be combined. Is it last in set, or is its * predecessor not part of this one? */ if (PSETMIDL || PSETSTRT) { /* It's the end of a set, so summarize */ CSETLAST = TRUE; /* the set's start adrs & size in this */ chunkSize += DBTISIZ; /* JDB index item, it's the one we'll */ DBTISIZ += chunkSize; /* be building the Elf64_Phdr from. */ chunkSize = 0L; DBTIVADDR = wVstart; /* Reset starting address & size */ wVstart = 0L; /* accumulators. */ } else { CSETSOLO = TRUE; /* This one is a standalone item. */ } /* * We will only write Elf64_Phdr items for those DBF items marked CSETLAST * or CSETSOLO. */ if (CSETLAST || CSETSOLO) { phnum += 1; /* We will write a Phdr because of this item*/ } } DBTIGAP = wGap; /* Save the gap for later analysis */ pred = curr; /* Advance our pair pointers */ curr = succ; succ += 1; } UNKEY(); /* Restore SPK=1 */ return phnum; /* Return revised count to caller. */ }