home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-29 | 57.7 KB | 2,790 lines |
- head 1.18;
- branch ;
- access ;
- symbols ;
- locks ediger:1.18;
- comment @@;
-
-
- 1.18
- date 94.05.29.15.00.14; author ediger; state Exp;
- branches ;
- next 1.17;
-
- 1.17
- date 94.05.28.16.17.55; author ediger; state Exp;
- branches ;
- next 1.16;
-
- 1.16
- date 94.05.26.21.21.06; author ediger; state Exp;
- branches ;
- next 1.15;
-
- 1.15
- date 94.05.23.20.32.13; author ediger; state Exp;
- branches ;
- next 1.14;
-
- 1.14
- date 94.05.17.23.09.48; author ediger; state Exp;
- branches ;
- next 1.13;
-
- 1.13
- date 94.05.10.22.41.07; author ediger; state Exp;
- branches ;
- next 1.12;
-
- 1.12
- date 94.05.04.11.19.58; author ediger; state Exp;
- branches ;
- next 1.11;
-
- 1.11
- date 94.05.03.10.20.01; author ediger; state Exp;
- branches ;
- next 1.10;
-
- 1.10
- date 94.05.01.17.32.57; author ediger; state Exp;
- branches ;
- next 1.9;
-
- 1.9
- date 94.02.07.21.37.17; author ediger; state Exp;
- branches ;
- next 1.8;
-
- 1.8
- date 94.01.30.21.30.19; author ediger; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 94.01.30.16.27.34; author ediger; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 94.01.01.23.02.22; author ediger; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 93.12.31.17.32.28; author ediger; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 93.12.31.16.58.01; author ediger; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 93.12.30.19.01.37; author ediger; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 93.12.19.14.31.43; author ediger; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 93.12.19.12.57.04; author ediger; state Exp;
- branches ;
- next ;
-
-
- desc
- @A Subclass of View that knows somewhat about Mach-O files,
- and how to show a graphic representation of a Mach-O file in core.
- @
-
-
- 1.18
- log
- @zero out a memory allocation to make it clear it's unused
- @
- text
- @
- #import <MachOView.h>
-
- /* $Log: MachOView.m,v $
- Revision 1.17 94/05/28 16:17:55 ediger
- finally got section names to draw acceptably.
-
- Revision 1.16 94/05/26 21:21:06 ediger
- correct address bracket zooming, hi and lo address bracket checking
-
- Revision 1.15 94/05/23 20:32:13 ediger
- lot's o' stuff to do address bracket zoom-in
-
- Revision 1.14 94/05/17 23:09:48 ediger
- support for stacking of zoomed address ranges, changed types of
- some instance vars from id to pointer to that kind of object.
-
- Revision 1.13 94/05/10 22:41:07 ediger
- support for displaying a "zooming box" by mouse drag
-
- Revision 1.12 94/05/04 11:19:58 ediger
- rearrange drawSelf:: to be a bit more modular
-
- Revision 1.10 94/05/01 17:32:57 ediger
- efficiency improvements
-
- Revision 1.9 94/02/07 21:37:17 ediger
- Use of memory-mapped file object to manage file mapping,
- add display of segment names and use of matrix of buttons
- for choices of what to display.
-
- Revision 1.7 94/01/30 16:27:34 ediger
- mostly correct address spacing
-
- Revision 1.6 94/01/01 23:02:22 ediger
- broke address label spacing calcs into separate method.
-
- Revision 1.5 93/12/31 17:32:28 ediger
- better address label spacing
-
- Revision 1.3 93/12/30 19:01:37 ediger
- support for showing upper and lower addresses
- of memory mapped segments.
-
- Revision 1.2 93/12/19 14:31:43 ediger
- corrected scaling and inclusion of mapped segments of library files
-
- Revision 1.1 93/12/19 12:57:04 ediger
- Initial revision
-
- */
-
- @@implementation MachOView
-
- static char rcsident[] = "$Id: MachOView.m,v 1.17 94/05/28 16:17:55 ediger Exp Locker: ediger $";
-
- #undef DEBUG
- #ifdef DEBUG
- #define D(c) c
- #define ENTER(m) fprintf(stderr, "enter %s\n", m);
- #define EXIT(m) fprintf(stderr, "exit %s\n", m);
- #else
- #define D(c)
- #define ENTER(m)
- #define EXIT(m)
- #endif
-
- //M+ -findSizes
- // PURPOSE:
- // Sort through the addresses of the mapped segments in the Mach-O file
- // to be represented, determining the high address, low address, and
- // the number of bytes used in the address space.
- //
- // EDITORIAL:
- // Should only be called after using MachOFile instance var to
- // open or re-open the Mach-O file being represented.
- //M-
- - findSizes
- {
- int iSegments, iCC;
- unsigned long ulBaseAddr, ulUpperAddr;
- char bvBuf[64];
-
- ENTER("- findSizes");
-
- loAddr = (unsigned long)-1; /* cheat */
- sumAddr = hiAddr = 0;
-
- iSegments = [theFile mappedSegments];
-
- for (iCC = 0; iCC < iSegments; ++iCC)
- { id oSegment = [theFile mappedSegment:iCC];
-
- ulBaseAddr = [oSegment getBaseAddress];
- if (loAddr > ulBaseAddr) loAddr = ulBaseAddr;
- ulUpperAddr = [oSegment getUpperAddress];
- if (hiAddr < ulUpperAddr) hiAddr = ulUpperAddr;
- sumAddr += (ulUpperAddr - ulBaseAddr);
- }
-
- sprintf(bvBuf, "0x%x", loAddr);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", hiAddr);
- [maxAddress setStringValue:bvBuf];
-
- EXIT("- findSizes");
- return self;
- }
-
- //M+ -(char *)fileType
- //M-
- - (char *)fileType
- {
- return [theFile fileType];
- }
-
- //M+ -openFileNamed:(char *)fileName
- //
- //M-
- - openFileNamed:(char *)fileName
- {
- ENTER("- openFileNamed:");
- assert(NULL != fileName);
-
- [self freeInternals];
-
- currentFileName = strcpy(malloc(strlen(fileName) + 1), fileName);
-
- mappedFile = [[[MappedFile alloc] init] filename:currentFileName];
- if (mappedFile == NULL || [mappedFile map] == FALSE)
- { [cpuType setStringValue:"Problem opening"];
- [cpuSubtype setStringValue:currentFileName];
-
- } else {
- theFile = [[[MachOFile alloc]init]
- fillFromAddress:[mappedFile address]];
- if (NULL == theFile)
- { [cpuType setStringValue:"Not a"];
- [cpuSubtype setStringValue:"Mach-O file"];
- } else {
- int iSegments = [theFile mappedSegments];
- addressMap = (struct addressMapping *)malloc(
- iSegments * sizeof(struct addressMapping));
- bzero(addressMap, iSegments * sizeof(struct addressMapping));
- [cpuType setStringValue:[theFile cpuType]];
- [cpuSubtype setStringValue:[theFile cpuSubtype]];
- [[self findSizes] display];
- }
- }
-
- EXIT("- openFileNamed:");
- return self;
- }
-
- //M+ -toggleScaling:sender
- // Action called by clicking on a button. Changes the "toScale" instance
- // variable, and calls -display, to reflect the change.
- //M-
- - toggleScaling:sender
- {
- if (toScale)
- {
- toScale = FALSE;
- showSectionNames = FALSE;
- [showSectionsButton setEnabled:NO];
- [showSectionsButton setIntValue:0];
-
- } else {
- toScale = TRUE;
- [showSectionsButton setEnabled:YES];
- [showSectionsButton setIntValue:0];
- }
-
- [self display];
-
- return self;
- }
-
-
- //M+ -toggleAddresses:sender
- // Action called by clicking on a button. Changes the "showAddresses"
- // instance variable, and calls -display, to reflect the change.
- //M-
- - toggleAddresses:sender
- {
- if (showAddresses)
- showAddresses = FALSE;
- else
- showAddresses = TRUE;
-
- [self display];
-
- return self;
- }
-
- //M+ -toggleNames:sender
- // Action called by clicking on a button. Changes the "showNames"
- // instance variable, and calls -display, to reflect the change.
- //M-
- - toggleNames:sender
- {
- if (showNames)
- showNames = FALSE;
- else
- showNames = TRUE;
-
- [self display];
-
- return self;
- }
-
- //M+ -toggleThreads:sender
- // Action called by clicking on a button. Changes the "showThreads"
- // instance variable, and calls -display, to reflect the change.
- //M-
- - toggleThreads:sender
- {
- if (showThreads)
- showThreads = FALSE;
- else
- showThreads = TRUE;
-
- [self display];
-
- return self;
- }
-
- //M+ -toggleSections:sender
- // Action called by clicking on a button. Changes the "showSectionNames"
- // instance variable, and calls -display, to reflect the change.
- //M-
- - toggleSections:sender
- {
- int iSegments, iCC;
-
- if (showSectionNames)
- showSectionNames = FALSE;
- else
- showSectionNames = TRUE;
-
- iSegments = [theFile mappedSegments];
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- int i;
- SegmentCommand *oSegment = [theFile mappedSegment:iCC];
- int iSection = [oSegment numberOfSections];
- struct section *spSection = [oSegment getSection:0];
-
- if (iSection > 0)
- {
- if (addressMap[iCC].sectionMap == NULL)
- addressMap[iCC].sectionMap =
- (struct sectionNameMapping *)malloc(
- iSection*sizeof(struct sectionNameMapping));
-
- assert(addressMap[iCC].sectionMap != NULL);
-
- for (i = 0; i < iSection; ++i)
- {
- addressMap[iCC].sectionMap[i].sectionName
- = spSection[i].sectname;
- addressMap[iCC].sectionMap[i].sectionAddress
- = spSection[i].addr;
- }
-
- } else
- addressMap[iCC].sectionMap = NULL;
- }
-
- [self display];
-
- return self;
- }
-
- //M+ -toggleLibraries:sender
- // PURPOSE:
- // Action called by clicking on a button. Changes the "showLibraries"
- // instance variable, and calls -display, to reflect the change.
- // EDITORIAL:
- // Somewhat more elaborate than the other -toggle* methods, since the
- // Mach-O file object instance variable gets completely redone. This
- // may be a case of bad design of the MachOFile object percolating up
- // to here.
- //M-
- - toggleLibraries:sender;
- {
- if (theFile != NULL)
- [theFile free];
- theFile = [[MachOFile alloc] init];
-
- if (NULL != addressMap)
- {
- int iSegments = [theFile mappedSegments];
- while (--iSegments > -1)
- if (addressMap[iSegments].sectionMap)
- free(addressMap[iSegments].sectionMap);
-
- free(addressMap);
- addressMap = NULL;
- }
-
- if (showLibraries)
- {
- showLibraries = FALSE;
- [theFile unconsiderMappedFiles];
- } else {
- showLibraries = TRUE;
- [theFile considerMappedFiles];
- }
-
- [theFile fillFromAddress:[mappedFile address]];
-
- addressMap = (struct addressMapping *)malloc(
- [theFile mappedSegments] * sizeof(struct addressMapping));
- bzero(addressMap, [theFile mappedSegments] * sizeof(struct addressMapping));
-
- // since the MachOFile object has been redone, zoom state is meaningless.
- if (NULL != zoomStack)
- {
- void *vp;
-
- while ((vp = [zoomStack pop]) != NULL)
- free(vp);
- }
- [unzoomButton setEnabled:NO];
- [zoomButton setEnabled:NO];
-
- [[self findSizes] display];
-
- return self;
- }
-
- //M+ -windowWillClose:sender
- // PURPOSE:
- // Ditch any memory-consuming instance vars when the window closes.
- // EDITORIAL:
- // one of the Window delegate methods
- //M-
- - windowWillClose:sender
- {
- ENTER("- windowWillClose:");
- [self freeInternals];
- [zoomStack free];
- EXIT("- windowWillClose:");
- return self;
- }
-
- //M+ -rescale
- // PURPOSE:
- // calculate the scaling instance vars
- //M-
- - rescale
- {
- float ht;
- ENTER("- rescale");
-
- ht = NX_HEIGHT(&bounds) - 25.0;
-
- scaleSlope = ht/(float)(hiAddr - loAddr);
- scaleYintercept = 5.0 - scaleSlope*(float)loAddr;
-
- smashedSlope = ht/(float)sumAddr;
- smashedYintercept = 0.0;
-
- EXIT("- rescale");
- return self;
- }
-
-
- //M+ -initFrame:(const NXRect *)frameRect
- // PURPOSE:
- // Set a bunch of instance variables to some sensible values.
- //
- // EDITORIAL:
- // Override of a View method
- //M-
- - initFrame:(const NXRect *)frameRect
- {
- ENTER("- initFrame:");
- [super initFrame:frameRect];
-
- toScale = TRUE;
- showLibraries = FALSE;
- showAddresses = TRUE;
- showNames = TRUE;
- showThreads = TRUE;
- showSectionNames = FALSE;
-
- currentFileName = NULL;
- addressMap = NULL;
- mappedFile = NULL;
- theFile = NULL;
- zoomStack = [[Queue alloc] init];
-
- theFont = [Font newFont:"Courier" size:(float)(LABEL_HT - LABEL_LEADING)
- matrix:NX_IDENTITYMATRIX];
-
-
- EXIT("- initFrame:");
- return self;
- }
-
- //M+ -drawSelf:(NXRect *)rects :(int)rectCount
- //
- // EDITORIAL:
- // Override of a View method.
- // This is way too complicated.
- //M-
- - drawSelf:(NXRect *)rects :(int)rectCount
- {
- int iSegments, iCC;
- float xCoord, yCoord, yLast;
- ENTER("- drawSelf::");
-
- [self rescale];
-
- // make background white and lines black
- PSsetgray(NX_WHITE);
- NXRectFill(&bounds);
- PSsetgray(NX_BLACK);
- NXFrameRect(&bounds);
- PSsetgray(NX_BLACK);
-
- PSnewpath();
- PSsetlinewidth(LINE_WDTH);
-
- [theFont set];
-
- iSegments = [theFile mappedSegments];
-
- if (iSegments == 0)
- return self;
-
- /* stagger the lines representing memory allocations */
- xCoord = NX_WIDTH(&bounds)/2.0 - ((float)iSegments/2.0)*LINE_STAGGER;
- yCoord = VERT_MARGIN;
- yLast = [[theFile mappedSegment:iSegments - 1] getBaseAddress] - 1.0;
-
- /* count down so that the "not to scale" bit works */
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- id oSegment = [theFile mappedSegment:iCC];
- unsigned long ulBaseAddr = [oSegment getBaseAddress];
- unsigned long ulUpperAddr = [oSegment getUpperAddress];
-
- if (ulBaseAddr > hiAddr)
- break; // don't need to check any higher
-
- if (
- (ulUpperAddr <= hiAddr && ulBaseAddr >= loAddr) ||
- (ulUpperAddr >= loAddr && ulBaseAddr < loAddr) ||
- (ulUpperAddr > hiAddr && ulBaseAddr < hiAddr)
- )
- {
-
- addressMap[iCC].baseAddress
- = (loAddr < ulBaseAddr)?ulBaseAddr:loAddr;
- addressMap[iCC].endAddress
- = (hiAddr > ulUpperAddr)?ulUpperAddr:hiAddr;
-
- if (showNames)
- addressMap[iCC].segmentName = [oSegment commandName];
-
- if (toScale)
- {
- addressMap[iCC].yCoordBase =
- (loAddr < ulBaseAddr)?
- scaleSlope*(float)ulBaseAddr + scaleYintercept
- : scaleSlope*(float)loAddr + scaleYintercept
- ;
- addressMap[iCC].yCoordTop =
- (hiAddr > ulUpperAddr) ?
- scaleSlope*(float)ulUpperAddr + scaleYintercept
- : scaleSlope*(float)hiAddr + scaleYintercept
- ;
-
- PSmoveto(xCoord, addressMap[iCC].yCoordBase);
-
- PSlineto(xCoord, addressMap[iCC].yCoordTop);
-
- } else {
-
- if (ulBaseAddr != yLast)
- PSmoveto(xCoord, yCoord + SEGMENT_GAP);
- else
- PSmoveto(xCoord, yCoord);
-
- if (ulBaseAddr != yLast)
- addressMap[iCC].yCoordBase = yCoord + SEGMENT_GAP;
- else
- addressMap[iCC].yCoordBase = yCoord;
-
- if (ulUpperAddr <= hiAddr && ulBaseAddr >= loAddr)
- yCoord += smashedSlope * (float)(ulUpperAddr - ulBaseAddr)
- + smashedYintercept;
- else if (ulUpperAddr >= loAddr && ulBaseAddr < loAddr)
- yCoord += smashedSlope * (float)(ulUpperAddr - loAddr)
- + smashedYintercept;
- else if (ulUpperAddr > hiAddr && ulBaseAddr < hiAddr)
- yCoord += smashedSlope * (float)(hiAddr - ulBaseAddr)
- + smashedYintercept;
-
- PSlineto(xCoord, yCoord);
-
- addressMap[iCC].yCoordTop = yCoord;
-
- yLast = ulUpperAddr;
- }
-
- /* stagger to the right, on the way up */
- xCoord += LINE_STAGGER;
-
- }
- }
-
- PSstroke();
-
- if (yLooping)
- {
- // draw on the box marking the zooming zone
- drawBox(sFirstMouseDown.x, sFirstMouseDown.y,
- sMouseDown.x, sMouseDown.y);
- } else {
- [zoomButton setEnabled:NO];
- }
-
- /* label the ends of each memory segment with its address */
- if (TRUE == showAddresses)
- [self drawAddresses];
-
- /* label the middle of each memory segment with its name */
- if (TRUE == showNames)
- [self drawSegmentNames];
-
- /* draw in little markers for threads program counters */
- if (showThreads)
- [self drawThreads];
-
- if (showSectionNames)
- [self drawSectionNames];
-
- EXIT("- drawSelf::");
- return self;
- }
-
- //M+ -drawThreads
- //M-
- - drawThreads
- {
- int iCC, iThreadCount = [theFile threads];
- int iSegCount = [theFile mappedSegments];
-
- PSsetlinewidth(0.50);
-
- for (iCC = 0; iCC < iThreadCount; ++iCC)
- {
- float xCoord, yCoord;
- int iSegNo = [theFile segmentOfThread:iCC];
-
- // iSegNo is -1 if there's no segment containing this thread's PC.
- // abort(2) causes just this sort of situation.
- if (iSegNo > -1)
- {
- unsigned long ulPCAddr = [[theFile thread:iCC] pc];
-
- if (ulPCAddr >= loAddr && ulPCAddr <= hiAddr)
- {
-
- xCoord = NX_WIDTH(&bounds)/2.0
- - ((float)[theFile mappedSegments]/2.0)*(LINE_STAGGER)
- + (float)(iSegCount - iSegNo) * LINE_STAGGER;
-
- yCoord = addressMap[iSegNo].yCoordBase
- + (addressMap[iSegNo].yCoordTop - addressMap[iSegNo].yCoordBase)
- * ((float)ulPCAddr - addressMap[iSegNo].baseAddress)
- / (addressMap[iSegNo].endAddress-addressMap[iSegNo].baseAddress);
-
- drawLeftArrowHead(xCoord, yCoord, 8.0);
- }
- }
- }
-
- return self;
- }
-
- //M+ -spaceLabels
- // Figure out the spacing of the address labels
- // Fills in yCoordBaseLabel and yCoordTopLabel fields such that the
- // addresses don't overlap, and don't end up out of the MachOView.
- // yCoordBaseLabel field ends up as -1.0 if it is the same number
- // as the yCoordTopLabel of the preceding (lower in memory) segment.
- //M-
- - spaceLabels
- {
- float lastY;
- float yLastAddress;
- int iCC, iSegments = [theFile mappedSegments];
-
- lastY = addressMap[iSegments - 1].baseAddress - 20.0;
- yLastAddress = addressMap[iSegments - 1].yCoordBase - LABEL_HT;
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- if (addressMap[iCC].baseAddress > hiAddr)
- break; // no need to go any higher
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
-
- if (addressMap[iCC].baseAddress != lastY)
- {
- if (addressMap[iCC].yCoordBase < yLastAddress + LABEL_HT)
- addressMap[iCC].yCoordBaseLabel
- = yLastAddress + (LABEL_HT + 2.0);
- else
- addressMap[iCC].yCoordBaseLabel=addressMap[iCC].yCoordBase;
-
- yLastAddress = addressMap[iCC].yCoordBaseLabel;
-
- } else {
- /* don't need to show this segment's base address */
- addressMap[iCC].yCoordBaseLabel = -1.0;
- }
-
- if (addressMap[iCC].yCoordTop < yLastAddress + LABEL_HT)
- addressMap[iCC].yCoordTopLabel = yLastAddress + (LABEL_HT+2.0);
- else
- addressMap[iCC].yCoordTopLabel = addressMap[iCC].yCoordTop;
-
- yLastAddress = addressMap[iCC].yCoordTopLabel;
- lastY = addressMap[iCC].endAddress;
-
- }
- }
-
- if (yLastAddress + LABEL_HT > NX_HEIGHT(&bounds))
- {
- yLastAddress = NX_HEIGHT(&bounds) - (LABEL_HT + 2.0);
-
- /* try to reshuffle address labels so everything fits */
- for (iCC = 0; iCC < iSegments; ++iCC)
- {
-
- if (addressMap[iCC].endAddress < loAddr)
- break; // no need to go any lower
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
-
- if (addressMap[iCC].yCoordTopLabel > yLastAddress)
- {
- addressMap[iCC].yCoordTopLabel = yLastAddress;
- yLastAddress -= (LABEL_HT + 2.0);
- } else if (0.0 > addressMap[iCC].yCoordTopLabel)
- continue; // this label doesn't show. go to next visible.
- else
- break; /* slipped down into a gap */
-
- if (addressMap[iCC].yCoordBaseLabel > yLastAddress)
- {
- addressMap[iCC].yCoordBaseLabel = yLastAddress;
- yLastAddress -= (LABEL_HT + 2.0);
- } else if (0.0 > addressMap[iCC].yCoordBaseLabel)
- continue;
- else
- break;
- }
- }
- }
-
- return self;
- }
-
- //M+ -spaceNames
- // Figure out the spacing of the segment name labels
- // Fills in yCoordBaseLabel field such that the
- // names don't overlap, and don't end up out of the MachOView.
- // Segment
- //M-
- - spaceNames
- {
- int iCC, iSegments = [theFile mappedSegments];
- float yLastAddress;
-
- yLastAddress = addressMap[iSegments - 1].yCoordBase - LABEL_HT;
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
- /* space name across width of view */
- addressMap[iCC].nameXcoord = NX_WIDTH(&bounds) - LABEL_MARGIN
- - [theFont getWidthOf:addressMap[iCC].segmentName];
-
- /* put name in middle of segment vertically */
- addressMap[iCC].nameYcoord =
- (addressMap[iCC].yCoordBase + addressMap[iCC].yCoordTop)/2.0;
-
- /* handle overlaps */
- if (addressMap[iCC].nameYcoord < yLastAddress + LABEL_HT)
- addressMap[iCC].nameYcoord = yLastAddress + LABEL_HT;
-
- yLastAddress = addressMap[iCC].nameYcoord;
- }
- }
-
- if (yLastAddress + LABEL_HT > NX_HEIGHT(&bounds))
- {
- yLastAddress = NX_HEIGHT(&bounds) - (LABEL_HT + 2.0);
-
- /* try to reshuffle address labels so everything fits */
- for (iCC = 0; iCC < iSegments; ++iCC)
- {
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
- if (addressMap[iCC].nameYcoord > yLastAddress)
- {
- addressMap[iCC].nameYcoord = yLastAddress;
- yLastAddress -= (LABEL_HT + 2.0);
- } else
- break; /* slipped down into a gap */
- }
- }
- }
-
- return self;
- }
-
- //M+ -free
- //M-
- - free
- {
- ENTER("- free");
- [self freeInternals];
-
- [zoomStack free];
-
- [super free];
-
- EXIT("- free");
- return self;
- }
-
- //M+ - freeInternals
- //M-
- - freeInternals
- {
- ENTER("- freeInternals");
- if (NULL != addressMap)
- {
- int iSegments = [theFile mappedSegments];
- while (--iSegments > -1)
- if (addressMap[iSegments].sectionMap)
- free(addressMap[iSegments].sectionMap);
-
- free(addressMap);
- addressMap = NULL;
- }
-
- if (NULL != currentFileName)
- {
- free(currentFileName);
- currentFileName = NULL;
- }
-
- if (NULL != theFile)
- {
- [theFile free];
- theFile = NULL;
- }
-
- if (NULL != mappedFile)
- {
- [mappedFile free];
- mappedFile = NULL;
- }
-
- if (NULL != zoomStack)
- { // free zoomStack's contents
- void *vp;
-
- while ((vp = [zoomStack pop]) != NULL)
- free(vp);
- }
-
- EXIT("- freeInternals");
- return self;
- }
-
- //M+ -show:sender
- //M-
- - show:sender
- {
- [theWindow makeKeyAndOrderFront:self];
-
- return self;
- }
-
- //M+ -drawAddresses
- //M-
- - drawAddresses
- {
- float yCoord, xCoord;
- int iCC, iSegments;
-
- iSegments = [theFile mappedSegments];
-
- /* figure out address label spacing */
- [self spaceLabels];
-
- PSnewpath();
- PSsetlinewidth(0.50); /* thin lines to each segment */
- [theFont set];
-
- yCoord = VERT_MARGIN;
- xCoord = NX_WIDTH(&bounds)/2.0 - ((float)iSegments/2.0)*(LINE_STAGGER);
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- char bvBuffer[256];
-
- if (addressMap[iCC].baseAddress > hiAddr)
- break; // no need to go any higher
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
-
- if (!(addressMap[iCC].yCoordBaseLabel < 0.0))
- { sprintf(bvBuffer, "0x%x",
- (unsigned int)addressMap[iCC].baseAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordBaseLabel,
- bvBuffer, xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordBase);
- }
-
- sprintf(bvBuffer, "0x%x", (unsigned int)addressMap[iCC].endAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordTopLabel, bvBuffer,
- xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordTop);
-
- xCoord += LINE_STAGGER;
-
- }
- }
-
- PSstroke();
-
- return self;
- }
-
- //M+ -drawSegmentNames
- //M-
- - drawSegmentNames
- {
- float xCoord;
- int iCC, iSegments;
-
- if (FALSE == showAddresses)
- [self spaceLabels];
-
- [self spaceNames];
-
- PSnewpath();
- PSsetlinewidth(0.50);
- [theFont set];
-
- iSegments = [theFile mappedSegments];
-
- xCoord = NX_WIDTH(&bounds)/2.0
- - ((float)iSegments/2.0)*(LINE_STAGGER) + 5.0;
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- if (addressMap[iCC].baseAddress > hiAddr)
- break; // no need to go any higher
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
-
- xCoord += LINE_STAGGER;
- PSmoveto(
- xCoord,
- (addressMap[iCC].yCoordBase + addressMap[iCC].yCoordTop)/2.0);
- PSlineto(
- addressMap[iCC].nameXcoord - 10.0,
- addressMap[iCC].nameYcoord);
- PSmoveto(addressMap[iCC].nameXcoord, addressMap[iCC].nameYcoord);
- PSshow(addressMap[iCC].segmentName);
-
- }
- }
-
- PSstroke();
-
- return self;
- }
-
- //M+ -spaceSectionNames
- //M-
- - spaceSectionNames
- {
- int iCC, iSegments;
- float yLastAddress;
-
- iSegments = [theFile mappedSegments];
-
- yLastAddress = addressMap[iSegments - 1].yCoordBase - LABEL_HT;
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- if (addressMap[iCC].baseAddress > hiAddr)
- break; // no need to go any higher
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
- SegmentCommand *oSegment = [theFile mappedSegment:iCC];
- int iSection = [oSegment numberOfSections];
-
- if (iSection > 0 && addressMap[iCC].sectionMap != NULL)
- {
- int i;
-
- for (i = 0; i < iSection; ++i)
- {
- if(
- (addressMap[iCC].sectionMap[i].sectionAddress <= hiAddr)
- && (addressMap[iCC].sectionMap[i].sectionAddress >= loAddr)
- )
- {
-
- if (toScale)
- {
- addressMap[iCC].sectionMap[i].nameYcoord
- = scaleSlope*(float)addressMap[iCC].sectionMap[i].sectionAddress
- + scaleYintercept;
- } else {
- addressMap[iCC].sectionMap[i].nameYcoord
- = smashedSlope*(float)addressMap[iCC].sectionMap[i].sectionAddress
- + smashedYintercept;
- }
-
- if (addressMap[iCC].sectionMap[i].nameYcoord <= yLastAddress+LABEL_HT)
- addressMap[iCC].sectionMap[i].nameYcoord = yLastAddress + LABEL_HT;
-
- yLastAddress = addressMap[iCC].sectionMap[i].nameYcoord;
-
- }
-
- }
- }
- }
- }
-
- return self;
- }
-
- //M+ -drawSectionNames
- //M-
- - drawSectionNames
- {
- float xCoord;
- int iCC, iSegments;
-
- [self spaceSectionNames];
-
- PSnewpath();
- PSsetlinewidth(0.50);
- [theFont set];
-
- iSegments = [theFile mappedSegments];
-
- xCoord = NX_WIDTH(&bounds)/2.0
- - ((float)iSegments/2.0)*(LINE_STAGGER) + 5.0;
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- if (addressMap[iCC].baseAddress > hiAddr)
- break; // no need to go any higher
-
- if (
- (addressMap[iCC].endAddress <= hiAddr && addressMap[iCC].baseAddress >= loAddr)
- ||(addressMap[iCC].endAddress >= loAddr && addressMap[iCC].baseAddress < loAddr)
- ||(addressMap[iCC].endAddress > hiAddr && addressMap[iCC].baseAddress < hiAddr)
- )
- {
- SegmentCommand *oSegment = [theFile mappedSegment:iCC];
- int iSection = [oSegment numberOfSections];
-
- if (iSection > 0 && addressMap[iCC].sectionMap != NULL)
- {
- int i;
- for (i = 0; i < iSection; ++i)
- {
- if(
- (addressMap[iCC].sectionMap[i].sectionAddress <= hiAddr)
- &&(addressMap[iCC].sectionMap[i].sectionAddress >= loAddr)
- )
- {
- float yCoord;
-
- if (toScale)
- {
- yCoord
- = scaleSlope*(float)addressMap[iCC].sectionMap[i].sectionAddress
- + scaleYintercept;
- } else {
- yCoord
- = smashedSlope*(float)addressMap[iCC].sectionMap[i].sectionAddress
- + smashedYintercept;
- }
- PSmoveto(xCoord, yCoord);
- PSlineto(xCoord + 10.0,
- addressMap[iCC].sectionMap[i].nameYcoord);
- PSmoveto(xCoord + 14.0,
- addressMap[iCC].sectionMap[i].nameYcoord);
- PSshow(addressMap[iCC].sectionMap[i].sectionName);
- }
- }
- }
-
- xCoord += LINE_STAGGER;
- }
- }
-
- PSstroke();
-
- return self;
- }
-
- //M+ - mouseDown:(NXEvent *)spTheEvent
- // PURPOSE:
- // draw a box following the user's mouse drags
- //M-
- - mouseDown:(NXEvent *)spTheEvent
- {
- NXEvent *spNextEvent;
- int iOldMask, iCheckMask, iDragged = 0;
- char bvBuf[64];
-
- [self lockFocus];
-
- iOldMask = [window eventMask];
-
- iCheckMask = NX_MOUSEUPMASK | NX_MOUSEDRAGGEDMASK;
-
- [window setEventMask:(iOldMask|iCheckMask)];
-
- sFirstMouseDown = spTheEvent->location;
- [self convertPoint:&sFirstMouseDown fromView:nil];
-
- yLooping = 1;
- while (yLooping)
- {
- iDragged = 1;
- spNextEvent = [NXApp getNextEvent:iCheckMask];
-
- if ((yLooping = (spNextEvent->type != NX_MOUSEUP)))
- {
- sMouseDown = spTheEvent->location;
- [self convertPoint:&sMouseDown fromView:nil];
- [self display];
- }
- }
-
- [self unlockFocus];
-
- [window setEventMask:iOldMask];
-
- if (!iDragged)
- return self;
-
- // For sake of aesthetics, address 0x0 is not exactly at bottom of
- // view. This lets the user drag an address of less than zero,
- // which ends up as a very high address in an unsigned long.
- // The next bits use the view coords to keep user from screwing up.
- if (sFirstMouseDown.y < VERT_MARGIN)
- sFirstMouseDown.y = VERT_MARGIN;
- if (sMouseDown.y < VERT_MARGIN)
- sMouseDown.y = VERT_MARGIN;
-
- // set displayed coords for user's inspection
- if (toScale)
- {
- hiAddrZoom =
- (unsigned long)((sFirstMouseDown.y - scaleYintercept)/scaleSlope);
- loAddrZoom =
- (unsigned long)((sMouseDown.y - scaleYintercept)/scaleSlope);
-
- } else {
- int iCC;
- int iSegments = [theFile mappedSegments];
- int iLoSet = 0, iHiSet = 0;
- // find out where the addresses dragged out are
-
- for (iCC = iSegments - 1;
- iCC > -1 && (!iLoSet || !iHiSet);
- --iCC)
- {
- if (!iLoSet && addressMap[iCC].yCoordBase <= sMouseDown.y
- && addressMap[iCC].yCoordTop >= sMouseDown.y)
- {
- loAddrZoom =
- (unsigned long)((sMouseDown.y - addressMap[iCC].yCoordBase)
- /(addressMap[iCC].yCoordTop - addressMap[iCC].yCoordBase)
- *(float)(addressMap[iCC].endAddress - addressMap[iCC].baseAddress))
- + addressMap[iCC].baseAddress;
- iLoSet = 1;
-
- }
-
- if (!iHiSet && addressMap[iCC].yCoordBase <= sFirstMouseDown.y
- && addressMap[iCC].yCoordTop >= sFirstMouseDown.y)
- {
- hiAddrZoom =
- (unsigned long)((sFirstMouseDown.y - addressMap[iCC].yCoordBase)
- /(addressMap[iCC].yCoordTop - addressMap[iCC].yCoordBase)
- *(float)(addressMap[iCC].endAddress - addressMap[iCC].baseAddress))
- + addressMap[iCC].baseAddress;
- iHiSet = 1;
- }
- }
-
- if (!iLoSet)
- {
- // sMouseDown.y not in range of any segment
- if (sMouseDown.y > addressMap[0].yCoordTop)
- loAddrZoom = hiAddr;
- else
- loAddrZoom = loAddr;
- }
-
- if (!iHiSet)
- {
- // sFirstMouseDown.y not in range of any segment
- if (sFirstMouseDown.y > addressMap[0].yCoordTop)
- hiAddrZoom = hiAddr;
- else
- hiAddrZoom = loAddr;
- }
-
- }
-
- // user may have dragged from bottom to top.
- if (hiAddrZoom < loAddrZoom)
- { unsigned long ulTmp = hiAddrZoom; hiAddrZoom = loAddrZoom;
- loAddrZoom = ulTmp; }
-
- // clamp zoomed values no matter what they calculated out as
- if (hiAddrZoom > hiAddr)
- hiAddrZoom = hiAddr;
-
- if (loAddrZoom < loAddr)
- loAddrZoom = loAddr;
-
- sprintf(bvBuf, "0x%x", loAddrZoom);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", hiAddrZoom);
- [maxAddress setStringValue:bvBuf];
-
- [zoomButton setEnabled:YES];
-
- return self;
- }
-
- //M+ - zoom:sender
- // PURPOSE:
- // Do what needs to be done when user clicks on "zoom" button.
- // Essentially, it pushes the current state (high address displayed,
- // low address displayed, and amount of mapped address taked up)
- // on the zoom stack, recalcs the amount of address taken up
- // inside the new high and low addresses, then redisplays.
- //M-
- - zoom:sender
- {
- struct zoomAddress *spZoom;
- int iCC;
-
- // save current "zoom state".
- spZoom = malloc(sizeof(struct zoomAddress));
- assert(spZoom != NULL);
- spZoom->hiAddr = hiAddr;
- spZoom->loAddr = loAddr;
- spZoom->sumAddr = sumAddr;
- [zoomStack push:(void *)spZoom];
-
- hiAddr = hiAddrZoom;
- loAddr = loAddrZoom;
-
- // recalculate the amount of the address used by file's mapped segments
- sumAddr = 0;
- for (iCC = [theFile mappedSegments] - 1; iCC > -1; --iCC)
- {
- id oSegment = [theFile mappedSegment:iCC];
- unsigned long ulBaseAddr, ulUpperAddr;
-
- ulBaseAddr = [oSegment getBaseAddress];
- ulUpperAddr = [oSegment getUpperAddress];
-
- if (ulBaseAddr > hiAddr)
- break;
-
- if (
- (ulUpperAddr <= hiAddr && ulBaseAddr >= loAddr)
- ||(ulUpperAddr >= loAddr && ulBaseAddr < loAddr)
- ||(ulUpperAddr > hiAddr && ulBaseAddr < hiAddr)
- )
- {
- sumAddr +=
- (ulUpperAddr <= hiAddr ? ulUpperAddr : hiAddr)
- -
- (ulBaseAddr >= loAddr ? ulBaseAddr : loAddr);
- }
- }
-
- [unzoomButton setEnabled:YES];
-
- [self display];
-
- return self;
- }
-
- //M+ - unzoom:sender
- // PURPOSE:
- // "unzoom" a level.
- //M-
- - unzoom:sender
- {
- char bvBuf[64];
- struct zoomAddress *spZoom;
-
- spZoom = (struct zoomAddress *)[zoomStack pop];
-
- loAddr = spZoom->loAddr;
- hiAddr = spZoom->hiAddr;
- sumAddr = spZoom->sumAddr;
- free(spZoom);
-
- sprintf(bvBuf, "0x%x", loAddr);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", hiAddr);
- [maxAddress setStringValue:bvBuf];
-
- if ([zoomStack isEmpty])
- [unzoomButton setEnabled:NO];
-
- [self display];
-
- return self;
- }
-
- @@end
- @
-
-
- 1.17
- log
- @finally got section names to draw acceptably.
- @
- text
- @d5 3
- d55 1
- a55 1
- static char rcsident[] = "$Id: MachOView.m,v 1.16 94/05/26 21:21:06 ediger Exp Locker: ediger $";
- d263 2
- a264 1
- addressMap[iCC].sectionMap[i].sectionAddress = spSection[i].addr;
- d294 5
- d316 1
- d320 1
- a320 1
- { // free zoomStack's contents
- d537 1
- a537 1
- if (showThreads && addressMap)
- @
-
-
- 1.16
- log
- @correct address bracket zooming, hi and lo address bracket checking
- @
- text
- @d5 3
- d52 1
- a52 1
- static char rcsident[] = "$Id: MachOView.m,v 1.15 94/05/23 20:32:13 ediger Exp Locker: ediger $";
- d138 1
- d140 2
- a141 1
- [theFile mappedSegments] * sizeof(struct addressMapping));
- d159 1
- d161 5
- a165 1
- else
- d167 3
- d231 2
- d238 29
- d530 3
- d758 5
- d905 136
- @
-
-
- 1.15
- log
- @lot's o' stuff to do address bracket zoom-in
- @
- text
- @d5 3
- d49 1
- a49 1
- static char rcsident[] = "$Id: MachOView.m,v 1.14 94/05/17 23:09:48 ediger Exp Locker: ediger $";
- a301 1
- float falseSize = (float)sumAddr;
- d309 1
- a309 1
- smashedSlope = ht/falseSize;
- d398 2
- a399 2
- (ulUpperAddr >= loAddr && ulBaseAddr < loAddr) ||
- (ulUpperAddr > hiAddr && ulBaseAddr < hiAddr)
- d403 4
- a406 6
- if (showAddresses || showNames)
- { addressMap[iCC].baseAddress
- = (loAddr < ulBaseAddr)?ulBaseAddr:loAddr;
- addressMap[iCC].endAddress
- = (hiAddr > ulUpperAddr)?ulUpperAddr:hiAddr;
- }
- d435 4
- a438 6
- if (showAddresses || showNames)
- { if (ulBaseAddr != yLast)
- addressMap[iCC].yCoordBase = yCoord + SEGMENT_GAP;
- else
- addressMap[iCC].yCoordBase = yCoord;
- }
- d440 9
- a448 2
- yCoord += smashedSlope*(float)(ulUpperAddr - ulBaseAddr)
- + smashedYintercept;
- d452 1
- a452 2
- if (showAddresses || showNames)
- addressMap[iCC].yCoordTop = yCoord;
- d868 1
- a868 1
- int iOldMask, iCheckMask;
- d885 1
- d900 3
- d921 4
- d926 46
- a971 1
- // find out where the addresses dragged out are
- d979 7
- d1023 2
- a1024 1
- { id oSegment = [theFile mappedSegment:iCC];
- d1030 8
- a1037 1
- if (ulBaseAddr >= loAddr)
- d1039 4
- a1042 6
- if (ulUpperAddr <= hiAddr)
- sumAddr += (ulUpperAddr - ulBaseAddr);
- else {
- sumAddr += (hiAddr - ulBaseAddr);
- break; // don't need to check any higher
- }
- @
-
-
- 1.14
- log
- @support for stacking of zoomed address ranges, changed types of
- some instance vars from id to pointer to that kind of object.
- @
- text
- @d5 4
- d46 1
- a46 1
- static char rcsident[] = "$Id: MachOView.m,v 1.13 94/05/10 22:41:07 ediger Exp Locker: ediger $";
- a139 2
- zoomStack = [[Queue alloc] init];
-
- d261 11
- d287 1
- a294 2
- // EDITORIAL:
- // has to be a method because it fiddles with instance vars.
- d332 1
- d338 1
- a338 1
- zoomStack = NULL;
- a342 1
- //zoomStack = [[Queue alloc] init];
- d376 3
- d381 1
- a381 1
- yCoord = 5.0;
- d386 4
- a389 1
- { id oSegment = [theFile mappedSegment:iCC];
- d391 2
- a392 4
- if (showAddresses || showNames)
- { addressMap[iCC].baseAddress = [oSegment getBaseAddress];
- addressMap[iCC].endAddress = [oSegment getUpperAddress];
- }
- d394 6
- a399 2
- if (showNames)
- addressMap[iCC].segmentName = [oSegment commandName];
- a400 2
- if (toScale)
- {
- d402 4
- a405 4
- { addressMap[iCC].yCoordBase =
- scaleSlope*(float)[oSegment getBaseAddress] + scaleYintercept;
- addressMap[iCC].yCoordTop =
- scaleSlope*(float)[oSegment getUpperAddress] + scaleYintercept;
- d408 2
- a409 5
- PSmoveto(xCoord,
- scaleSlope*(float)[oSegment getBaseAddress] + scaleYintercept);
-
- PSlineto(xCoord,
- scaleSlope*(float)[oSegment getUpperAddress] + scaleYintercept);
- d411 12
- a422 2
- } else {
- unsigned long ulBase = [oSegment getBaseAddress];
- d424 3
- a426 4
- if (ulBase != yLast)
- PSmoveto(xCoord, yCoord + SEGMENT_GAP);
- else
- PSmoveto(xCoord, yCoord);
- d428 4
- a431 3
- if (showAddresses || showNames)
- { if (ulBase != yLast)
- addressMap[iCC].yCoordBase = yCoord + SEGMENT_GAP;
- d433 1
- a433 2
- addressMap[iCC].yCoordBase = yCoord;
- }
- d435 8
- a442 2
- yCoord +=
- smashedSlope*(float)([oSegment getUpperAddress] - ulBase)
- d445 1
- a445 1
- PSlineto(xCoord, yCoord);
- d447 2
- a448 2
- if (showAddresses || showNames)
- addressMap[iCC].yCoordTop = yCoord;
- d450 6
- a455 1
- yLast = [oSegment getUpperAddress];
- a456 3
-
- /* stagger to the right, on the way up */
- xCoord += LINE_STAGGER;
- d504 6
- a509 1
- xCoord = NX_WIDTH(&bounds)/2.0
- d513 1
- a513 1
- yCoord = addressMap[iSegNo].yCoordBase
- d515 1
- a515 1
- * ((float)[[theFile thread:iCC] pc]-addressMap[iSegNo].baseAddress)
- d518 2
- a519 1
- drawLeftArrowHead(xCoord, yCoord, 8.0);
- d544 8
- a551 1
- if (addressMap[iCC].baseAddress != lastY)
- d553 18
- a570 3
- if (addressMap[iCC].yCoordBase < yLastAddress + LABEL_HT)
- addressMap[iCC].yCoordBaseLabel
- = yLastAddress + (LABEL_HT + 2.0);
- d572 1
- a572 1
- addressMap[iCC].yCoordBaseLabel = addressMap[iCC].yCoordBase;
- d574 2
- a575 1
- yLastAddress = addressMap[iCC].yCoordBaseLabel;
- a576 3
- } else {
- /* don't need to show this segment's base address */
- addressMap[iCC].yCoordBaseLabel = -1.0;
- a577 8
-
- if (addressMap[iCC].yCoordTop < yLastAddress + LABEL_HT)
- addressMap[iCC].yCoordTopLabel = yLastAddress + (LABEL_HT + 2.0);
- else
- addressMap[iCC].yCoordTopLabel = addressMap[iCC].yCoordTop;
-
- yLastAddress = addressMap[iCC].yCoordTopLabel;
- lastY = addressMap[iCC].endAddress;
- d587 9
- a595 1
- if (addressMap[iCC].yCoordTopLabel > yLastAddress)
- a596 6
- addressMap[iCC].yCoordTopLabel = yLastAddress;
- yLastAddress -= (LABEL_HT + 2.0);
- } else if (0.0 > addressMap[iCC].yCoordTopLabel)
- continue; /* this label doesn't show. go to next visible */
- else
- break; /* slipped down into a gap */
- d598 18
- a615 8
- if (addressMap[iCC].yCoordBaseLabel > yLastAddress)
- {
- addressMap[iCC].yCoordBaseLabel = yLastAddress;
- yLastAddress -= (LABEL_HT + 2.0);
- } else if (0.0 > addressMap[iCC].yCoordBaseLabel)
- continue;
- else
- break;
- d637 6
- d656 1
- d666 6
- d678 1
- d692 2
- d730 1
- a730 1
- {
- a734 3
-
- [zoomStack free];
- zoomStack = NULL;
- d766 1
- a766 1
- yCoord = 5.0;
- d773 2
- a774 7
- if (!(addressMap[iCC].yCoordBaseLabel < 0.0))
- { sprintf(bvBuffer, "0x%x",
- (unsigned int)addressMap[iCC].baseAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordBaseLabel,
- bvBuffer, xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordBase);
- }
- d776 6
- a781 4
- sprintf(bvBuffer, "0x%x", (unsigned int)addressMap[iCC].endAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordTopLabel, bvBuffer,
- xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordTop);
- d783 16
- a798 1
- xCoord += LINE_STAGGER;
- d829 21
- a849 9
- xCoord += LINE_STAGGER;
- PSmoveto(
- xCoord,
- (addressMap[iCC].yCoordBase + addressMap[iCC].yCoordTop)/2.0);
- PSlineto(
- addressMap[iCC].nameXcoord - 10.0,
- addressMap[iCC].nameYcoord);
- PSmoveto(addressMap[iCC].nameXcoord, addressMap[iCC].nameYcoord);
- PSshow(addressMap[iCC].segmentName);
- d865 1
- d895 9
- a906 2
- char bvBuf[64];
-
- d912 1
- a912 3
- if (hiAddrZoom < loAddrZoom)
- { unsigned long ulTmp = hiAddrZoom; hiAddrZoom = loAddrZoom;
- hiAddrZoom = ulTmp; }
- d914 1
- a914 4
- sprintf(bvBuf, "0x%x", loAddrZoom);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", hiAddrZoom);
- [maxAddress setStringValue:bvBuf];
- d917 10
- d933 6
- d943 1
- d945 1
- d948 3
- a950 3
- spZoom->hiAddr = hiAddrZoom;
- spZoom->loAddr = loAddrZoom;
-
- d953 23
- d978 2
- d989 1
- d993 4
- d999 4
- a1002 1
- spZoom = (struct zoomAddress *)[zoomStack tail];
- a1003 18
- if (toScale)
- {
- char bvBuf[64];
-
- if (spZoom)
- {
- sprintf(bvBuf, "0x%x", spZoom->loAddr);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", spZoom->hiAddr);
- [maxAddress setStringValue:bvBuf];
- } else {
- sprintf(bvBuf, "0x%x", loAddr);
- [minAddress setStringValue:bvBuf];
- sprintf(bvBuf, "0x%x", hiAddr);
- [maxAddress setStringValue:bvBuf];
- }
- }
-
- d1006 2
- @
-
-
- 1.13
- log
- @support for displaying a "zooming box" by mouse drag
- @
- text
- @d5 3
- d42 1
- a42 1
- static char rcsident[] = "$Id: MachOView.m,v 1.12 94/05/04 11:19:58 ediger Exp Locker: ediger $";
- d44 11
- d69 1
- d71 2
- d88 6
- d109 1
- d112 1
- a112 2
- if (Nil != mappedFile)
- [mappedFile free];
- a113 12
- if (Nil != theFile)
- [theFile free];
-
- if (NULL != currentFileName)
- free(currentFileName);
-
- if (NULL != addressMap)
- {
- free(addressMap);
- addressMap = NULL;
- }
-
- d117 1
- a117 1
- if (mappedFile == Nil || [mappedFile map] == FALSE)
- d124 1
- a124 1
- if (Nil == theFile)
- d136 3
- d235 1
- a235 1
- if (theFile != Nil)
- d272 3
- a274 15
- if (theFile != Nil)
- [theFile free];
-
- if (mappedFile != Nil)
- [mappedFile free];
-
- if (theFont != Nil)
- [theFont free]; // not strictly necessary?
-
- if (currentFileName != NULL)
- free(currentFileName);
-
- if (addressMap != NULL)
- free(addressMap);
-
- d288 1
- d298 1
- d312 1
- d323 3
- a325 2
- mappedFile = Nil;
- theFile = Nil;
- d330 3
- d346 1
- d434 2
- d450 1
- a450 1
- D(printf("exit MachOView -drawSelf::\n");)
- d613 16
- a628 1
- if (addressMap == NULL)
- d630 2
- d634 1
- d636 2
- d639 2
- a640 1
- if (Nil == theFile)
- d642 2
- d645 5
- a649 1
- [super free];
- d651 12
- d758 4
- d796 3
- d800 17
- d819 56
- @
-
-
- 1.12
- log
- @rearrange drawSelf:: to be a bit more modular
- @
- text
- @d5 3
- d39 1
- a39 1
- static char rcsident[] = "$Id: MachOView.m,v 1.10 94/05/01 17:32:57 ediger Exp Locker: ediger $";
- d419 7
- d707 37
- @
-
-
- 1.11
- log
- @support for drawing a marker at thread's program counter
- @
- text
- @d418 1
- a418 3
- {
- /* figure out address label spacing */
- [self spaceLabels];
- a419 31
- PSnewpath();
- PSsetlinewidth(0.50); /* thin lines to each segment */
- [theFont set];
-
- yCoord = 5.0;
- xCoord = NX_WIDTH(&bounds)/2.0 - ((float)iSegments/2.0)*(LINE_STAGGER);
-
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- char bvBuffer[256];
-
- if (!(addressMap[iCC].yCoordBaseLabel < 0.0))
- { sprintf(bvBuffer, "0x%x",
- (unsigned int)addressMap[iCC].baseAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordBaseLabel,
- bvBuffer, xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordBase);
- }
-
- sprintf(bvBuffer, "0x%x", (unsigned int)addressMap[iCC].endAddress);
- drawLabel(LABEL_MARGIN, addressMap[iCC].yCoordTopLabel, bvBuffer,
- xCoord - (LINE_STAGGER - LABEL_MARGIN),
- addressMap[iCC].yCoordTop);
-
- xCoord += LINE_STAGGER;
- }
-
- PSstroke();
-
- }
-
- d422 1
- a422 4
- {
- if (FALSE == showAddresses)
- [self spaceLabels];
- [self spaceNames];
- a423 21
- PSnewpath();
- PSsetlinewidth(0.50);
- [theFont set];
-
- xCoord = NX_WIDTH(&bounds)/2.0
- - ((float)iSegments/2.0)*(LINE_STAGGER) + 5.0;
- for (iCC = iSegments - 1; iCC > -1; --iCC)
- {
- xCoord += LINE_STAGGER;
- PSmoveto(
- xCoord,
- (addressMap[iCC].yCoordBase + addressMap[iCC].yCoordTop)/2.0);
- PSlineto(
- addressMap[iCC].nameXcoord - 10.0,
- addressMap[iCC].nameYcoord);
- PSmoveto(addressMap[iCC].nameXcoord, addressMap[iCC].nameYcoord);
- PSshow(addressMap[iCC].segmentName);
- }
- PSstroke();
- }
-
- d610 83
- @
-
-
- 1.10
- log
- @efficiency improvements
- @
- text
- @d5 3
- d36 1
- a36 1
- static char rcsident[] = "$Id: MachOView.m,v 1.9 94/02/07 21:37:17 ediger Exp Locker: ediger $";
- d174 32
- d307 1
- a307 1
- toScale = TRUE;
- d310 2
- a311 1
- showNames = TRUE;
- d314 3
- a316 3
- addressMap = NULL;
- mappedFile = Nil;
- theFile = Nil;
- d482 36
- a517 4
- /*
- iSegments = [theFile threads];
- for (iCC = 0; iCC < iSegments; ++iCC)
- { // how do I decide which seg the thread belongs to?
- a518 1
- */
- a519 1
- D(printf("exit MachOView -drawSelf::\n");)
- @
-
-
- 1.9
- log
- @Use of memory-mapped file object to manage file mapping,
- add display of segment names and use of matrix of buttons
- for choices of what to display.
- @
- text
- @d5 5
- d33 1
- a33 1
- static char rcsident[] = "$Id: MachOView.m,v 1.7 94/01/30 16:27:34 ediger Exp Locker: ediger $";
- d91 6
- d111 2
- d187 6
- d204 3
- d232 3
- d278 1
- a297 1
- struct addressMapping *spAddrMap = NULL;
- a313 3
- if (showAddresses || showNames)
- spAddrMap = (struct addressMapping *)malloc(
- iSegments * sizeof(struct addressMapping));
- d325 2
- a326 2
- { spAddrMap[iCC].baseAddress = [oSegment getBaseAddress];
- spAddrMap[iCC].endAddress = [oSegment getUpperAddress];
- d330 1
- a330 1
- spAddrMap[iCC].segmentName = [oSegment commandName];
- d335 1
- a335 1
- { spAddrMap[iCC].yCoordBase =
- d337 1
- a337 1
- spAddrMap[iCC].yCoordTop =
- d357 1
- a357 1
- spAddrMap[iCC].yCoordBase = yCoord + SEGMENT_GAP;
- d359 1
- a359 1
- spAddrMap[iCC].yCoordBase = yCoord;
- d369 1
- a369 1
- spAddrMap[iCC].yCoordTop = yCoord;
- d384 1
- a384 1
- [self spaceLabels:spAddrMap];
- d397 1
- a397 1
- if (!(spAddrMap[iCC].yCoordBaseLabel < 0.0))
- d399 2
- a400 2
- (unsigned int)spAddrMap[iCC].baseAddress);
- drawLabel(LABEL_MARGIN, spAddrMap[iCC].yCoordBaseLabel,
- d402 1
- a402 1
- spAddrMap[iCC].yCoordBase);
- d405 2
- a406 2
- sprintf(bvBuffer, "0x%x", (unsigned int)spAddrMap[iCC].endAddress);
- drawLabel(LABEL_MARGIN, spAddrMap[iCC].yCoordTopLabel, bvBuffer,
- d408 1
- a408 1
- spAddrMap[iCC].yCoordTop);
- d421 2
- a422 2
- [self spaceLabels:spAddrMap];
- [self spaceNames:spAddrMap];
- d435 1
- a435 1
- (spAddrMap[iCC].yCoordBase + spAddrMap[iCC].yCoordTop)/2.0);
- d437 4
- a440 4
- spAddrMap[iCC].nameXcoord - 10.0,
- spAddrMap[iCC].nameYcoord);
- PSmoveto(spAddrMap[iCC].nameXcoord, spAddrMap[iCC].nameYcoord);
- PSshow(spAddrMap[iCC].segmentName);
- a452 3
- if (NULL != spAddrMap)
- free(spAddrMap);
-
- d457 1
- a457 1
- //M+ -spaceLabels:(struct addressMapping *)aspAddrMap
- d464 1
- a464 1
- - spaceLabels:(struct addressMapping *)aspAddrMap
- d470 2
- a471 2
- lastY = aspAddrMap[iSegments - 1].baseAddress - 20.0;
- yLastAddress = aspAddrMap[iSegments - 1].yCoordBase - LABEL_HT;
- d475 1
- a475 1
- if (aspAddrMap[iCC].baseAddress != lastY)
- d477 2
- a478 2
- if (aspAddrMap[iCC].yCoordBase < yLastAddress + LABEL_HT)
- aspAddrMap[iCC].yCoordBaseLabel
- d481 1
- a481 1
- aspAddrMap[iCC].yCoordBaseLabel = aspAddrMap[iCC].yCoordBase;
- d483 1
- a483 1
- yLastAddress = aspAddrMap[iCC].yCoordBaseLabel;
- d487 1
- a487 1
- aspAddrMap[iCC].yCoordBaseLabel = -1.0;
- d490 2
- a491 2
- if (aspAddrMap[iCC].yCoordTop < yLastAddress + LABEL_HT)
- aspAddrMap[iCC].yCoordTopLabel = yLastAddress + (LABEL_HT + 2.0);
- d493 1
- a493 1
- aspAddrMap[iCC].yCoordTopLabel = aspAddrMap[iCC].yCoordTop;
- d495 2
- a496 2
- yLastAddress = aspAddrMap[iCC].yCoordTopLabel;
- lastY = aspAddrMap[iCC].endAddress;
- d506 1
- a506 1
- if (aspAddrMap[iCC].yCoordTopLabel > yLastAddress)
- d508 1
- a508 1
- aspAddrMap[iCC].yCoordTopLabel = yLastAddress;
- d510 1
- a510 1
- } else if (0.0 > aspAddrMap[iCC].yCoordTopLabel)
- d515 1
- a515 1
- if (aspAddrMap[iCC].yCoordBaseLabel > yLastAddress)
- d517 1
- a517 1
- aspAddrMap[iCC].yCoordBaseLabel = yLastAddress;
- d519 1
- a519 1
- } else if (0.0 > aspAddrMap[iCC].yCoordBaseLabel)
- d529 1
- a529 1
- //M+ -spaceNames:(struct addressMapping *)aspAddrMap
- d535 1
- a535 1
- - spaceNames:(struct addressMapping *)aspAddrMap
- d540 1
- a540 1
- yLastAddress = aspAddrMap[iSegments - 1].yCoordBase - LABEL_HT;
- d545 2
- a546 2
- aspAddrMap[iCC].nameXcoord = NX_WIDTH(&bounds) - LABEL_MARGIN
- - [theFont getWidthOf:aspAddrMap[iCC].segmentName];
- d549 2
- a550 2
- aspAddrMap[iCC].nameYcoord =
- (aspAddrMap[iCC].yCoordBase + aspAddrMap[iCC].yCoordTop)/2.0;
- d553 2
- a554 2
- if (aspAddrMap[iCC].nameYcoord < yLastAddress + LABEL_HT)
- aspAddrMap[iCC].nameYcoord = yLastAddress + LABEL_HT;
- d556 1
- a556 1
- yLastAddress = aspAddrMap[iCC].nameYcoord;
- a558 1
- #ifdef SPAM
- d566 6
- a573 1
- #endif
- d582 6
- d590 1
- @
-
-
- 1.8
- log
- @ditched doFont pswrap function, added theFont Font object instance
- to get the benefits of using a Font.
- @
- text
- @d2 1
- a2 1
- #import "MachOView.h"
- a57 1
- D(printf(" -> 0x%lx - 0x%lx\n", ulUpperAddr, ulBaseAddr);)
- d77 3
- d88 5
- a92 3
- if (Nil == (theFile = [[[MachOFile alloc]init]fillFromFileNamed:fileName]))
- { [cpuType setStringValue:"Not a"];
- [cpuSubtype setStringValue:"Mach-O file"];
- d94 10
- a103 3
- [cpuType setStringValue:[theFile cpuType]];
- [cpuSubtype setStringValue:[theFile cpuSubtype]];
- [[self findSizes] display];
- d110 2
- a115 1
- { [sender setTitle:"actual scale"];
- d117 1
- a117 2
- } else {
- [sender setTitle:"scale to fit"];
- a118 1
- }
- d127 2
- a132 1
- { [sender setTitle:"no addresses"];
- d134 1
- a134 2
- } else {
- [sender setTitle:"addresses"];
- a135 1
- }
- d142 16
- d159 8
- d170 4
- d175 1
- a175 1
- { [sender setTitle:"libraries, too"];
- d177 1
- a178 1
- [sender setTitle:"no libraries"];
- d180 1
- d183 1
- a183 2
- if (Nil != theFile)
- [theFile free];
- d185 1
- a185 6
- if (showLibraries)
- { theFile = [[[[MachOFile alloc] init] considerMappedFiles]
- fillFromFileNamed:currentFileName];
- } else {
- theFile=[[[MachOFile alloc]init]fillFromFileNamed:currentFileName];
- }
- a186 9
- if (Nil == theFile)
- { [cpuType setStringValue:"Not a"];
- [cpuSubtype setStringValue:"Mach-O file"];
- } else {
- [cpuType setStringValue:[theFile cpuType]];
- [cpuSubtype setStringValue:[theFile cpuSubtype]];
- [[self findSizes] display];
- }
-
- d201 9
- a234 7
- //M+ -init
- //M-
- - init
- {
- [super init];
- return self;
- }
- a235 1
-
- d237 2
- d246 1
- d250 2
- d253 2
- d265 2
- a266 1
- // Override of a View method
- d289 1
- a289 1
- if (showAddresses)
- d302 1
- a302 1
- if (showAddresses)
- d307 3
- d312 1
- a312 1
- if (showAddresses)
- d333 1
- a333 1
- if (showAddresses)
- d346 1
- a346 1
- if (showAddresses)
- a360 3
- float lastY = -1.0;
- float yLastAddress = 0.0 - LABEL_HT;
-
- d395 28
- d439 5
- d468 1
- a468 1
- aspAddrMap[iCC].yCoordBaseLabel = -1;
- d506 45
- @
-
-
- 1.7
- log
- @mostly correct address spacing
- @
- text
- @d5 3
- d28 1
- a28 1
- static char rcsident[] = "$Id: MachOView.m,v 1.6 94/01/01 23:02:22 ediger Exp Locker: ediger $";
- d225 3
- a252 1
- doFont(LABEL_HT - LABEL_LEADING); /* leave some leading */
- d254 2
- d334 1
- a334 1
- doFont(LABEL_HT - LABEL_LEADING);
- @
-
-
- 1.6
- log
- @broke address label spacing calcs into separate method.
- @
- text
- @d5 3
- d25 1
- a25 1
- static char rcsident[] = "$Id: MachOView.m,v 1.5 93/12/31 17:32:28 ediger Exp Locker: ediger $";
- a41 2
- D(printf("enter MachOView -findSizes\n");)
-
- a45 1
- D(printf("MachOView -findSizes, %d segments\n", iSegments);)
- a57 4
- D(printf("MachOView -findSizes, hi 0x%lx, lo 0x%lx, sum 0x%lx\n",
- hiAddr, loAddr, sumAddr);
- printf("exit MachOView -findSizes\n");)
-
- a73 1
- D(printf("enter MachOView -openFileNamed:\"%s\"\n", fileName);)
- a91 1
- D(printf("exit MachOView -openFileNamed:\"%s\"\n", fileName);)
- a177 9
- //M+ -windowDidResize:sender
- // EDITORIAL
- // one of the Window delegate methods
- //M-
- /*- windowDidResize:sender
- {
- return self;
- }*/
-
- d233 1
- a233 1
- float xCoord, yCoord;
- d246 2
- a247 2
- PSsetlinewidth(5.0);
- doFont(9.0);
- d255 1
- a255 1
- xCoord = NX_WIDTH(&bounds)/2.0 - (float)iSegments/2.0*8.0;
- d257 1
- d284 1
- d286 5
- a290 1
- PSmoveto(xCoord, yCoord);
- d292 5
- a296 1
- spAddrMap[iCC].yCoordBase = yCoord;
- d298 3
- a300 3
- yCoord += smashedSlope*
- (float)([oSegment getUpperAddress]
- - [oSegment getBaseAddress]) + smashedYintercept;
- d303 1
- d307 1
- d311 1
- a311 1
- xCoord += 8.0;
- d327 1
- a327 1
- doFont(LABEL_HT);
- d330 1
- a330 1
- xCoord = NX_WIDTH(&bounds)/2.0 - (float)iSegments/2.0*8.0;
- d336 1
- a336 1
- if (!(spAddrMap[iCC].baseAddress < 0.0))
- d339 3
- a341 2
- drawLabel(2.0, spAddrMap[iCC].yCoordBaseLabel, bvBuffer,
- xCoord - 2.0, spAddrMap[iCC].yCoordBase);
- d345 3
- a347 2
- drawLabel(2.0, spAddrMap[iCC].yCoordTopLabel, bvBuffer,
- xCoord - 2.0, spAddrMap[iCC].yCoordTop);
- d349 1
- a349 1
- xCoord += 8.0;
- d356 8
- d376 1
- a376 1
- float yLastAddress = 5.0;
- d379 2
- a380 1
- lastY = aspAddrMap[0].baseAddress - 20.0;
- d408 26
- a433 2
- if (lastY > NX_HEIGHT(&bounds))
- printf("Need to rescale...\n");
- @
-
-
- 1.5
- log
- @better address label spacing
- @
- text
- @d5 3
- d22 1
- a22 1
- static char rcsident[] = "$Id: MachOView.m,v 1.3 93/12/30 19:01:37 ediger Exp Locker: ediger $";
- d188 1
- a188 1
- - windowDidResize:sender
- d191 1
- a191 1
- }
- d285 1
- a285 1
- { spAddrMap[iCC].yCoord =
- d287 1
- a287 1
- spAddrMap[iCC].yCoord2 =
- d301 1
- a301 1
- spAddrMap[iCC].yCoord = yCoord;
- d309 1
- a309 1
- spAddrMap[iCC].yCoord2 = yCoord;
- d319 1
- a321 1
- /* label the ends of each memory segment with its address */
- d325 3
- d339 6
- a344 3
- if (spAddrMap[iCC].baseAddress != lastY)
- {
- sprintf(bvBuffer, "0x%x", spAddrMap[iCC].baseAddress);
- d346 3
- a348 4
- if (spAddrMap[iCC].yCoord < yLastAddress + LABEL_HT)
- yLastAddress += (LABEL_HT + 2.0);
- else
- yLastAddress = spAddrMap[iCC].yCoord;
- d350 2
- a351 3
- drawLabel(2.0, yLastAddress, bvBuffer, xCoord - 2.0,
- spAddrMap[iCC].yCoord);
- }
- d353 1
- a353 1
- sprintf(bvBuffer, "0x%x", spAddrMap[iCC].endAddress);
- d355 26
- a380 2
- if (spAddrMap[iCC].yCoord2 < yLastAddress + LABEL_HT)
- yLastAddress += (LABEL_HT + 2.0);
- d382 1
- a382 1
- yLastAddress = spAddrMap[iCC].yCoord2;
- d384 1
- a384 2
- drawLabel(2.0, yLastAddress, bvBuffer, xCoord - 2.0,
- spAddrMap[iCC].yCoord2);
- d386 3
- a388 2
- xCoord += 8.0;
- lastY = spAddrMap[iCC].endAddress;
- d391 4
- a394 1
- PSstroke();
- d396 2
- a397 3
- if (NULL != spAddrMap)
- free(spAddrMap);
-
- d400 3
- a402 1
- D(printf("exit MachOView -drawSelf::\n");)
- @
-
-
- 1.4
- log
- @Address labeling cleaned up
- @
- text
- @d201 1
- a201 1
- ht = NX_HEIGHT(&bounds) - 10.0;
- d320 1
- a320 1
- float yInterval, yLastAddress = -1.0;
- d324 1
- a324 1
- doFont(10.0);
- a327 1
- yInterval = (NX_HEIGHT(&bounds) - 20.0)/(float)iSegments;
- d330 2
- a331 1
- { char bvBuffer[256];
- d334 2
- a335 1
- { sprintf(bvBuffer, "0x%x", spAddrMap[iCC].baseAddress);
- d337 7
- a343 3
- if (spAddrMap[iCC].yCoord -
- drawLabel(2.0, yCoord, bvBuffer,
- xCoord - 2.0 , spAddrMap[iCC].yCoord);
- d345 1
- a345 1
- yCoord += yInterval;
- d347 9
- a355 2
- drawLabel(2.0, yCoord, bvBuffer,
- xCoord - 2.0, spAddrMap[iCC].yCoord2);
- @
-
-
- 1.3
- log
- @support for showing upper and lower addresses
- of memory mapped segments.
- @
- text
- @d5 4
- d19 1
- a19 1
- static char rcsident[] = "$Id: MachOView.m,v 1.2 93/12/19 14:31:43 ediger Exp Locker: ediger $";
- d26 1
- d70 1
- a101 1
- BOOL settingChanged = FALSE;
- a104 1
- settingChanged = TRUE;
- a107 1
- settingChanged = TRUE;
- d110 1
- a110 2
- if (settingChanged)
- [self display];
- a119 2
- BOOL settingChanged = FALSE;
-
- a122 1
- settingChanged = TRUE;
- a125 1
- settingChanged = TRUE;
- d128 1
- a128 2
- if (settingChanged)
- [self display];
- a136 2
- BOOL settingChanged = FALSE;
-
- a139 1
- settingChanged = TRUE;
- a142 1
- settingChanged = TRUE;
- d145 2
- a146 4
- if (settingChanged)
- {
- if (Nil != theFile)
- [theFile free];
- d148 6
- a153 5
- if (showLibraries)
- theFile = [[[[MachOFile alloc] init] considerMappedFiles]
- fillFromFileNamed:currentFileName];
- else
- theFile=[[[MachOFile alloc]init]fillFromFileNamed:currentFileName];
- d155 7
- a161 8
- if (Nil == theFile)
- { [cpuType setStringValue:"Not a"];
- [cpuSubtype setStringValue:"Mach-O file"];
- } else {
- [cpuType setStringValue:[theFile cpuType]];
- [cpuSubtype setStringValue:[theFile cpuSubtype]];
- [[self findSizes] display];
- }
- a186 4
- D(printf("MachOView -windowDidResize:\n");)
-
- //[self display];
-
- d203 1
- a203 1
- scaleSlope = ht/(float)(hiAddr - loAddr);
- d206 1
- a206 1
- smashedSlope = ht/falseSize;
- d245 1
- a245 1
- float xCoord, yCoord, yInterval;
- a247 6
- D(printf("enter MachOView -drawSelf::\n");
- printf("width %f, height %f\n", NX_WIDTH(&bounds),
- NX_HEIGHT(&bounds));
- printf("sum of addresses 0x%lx\n", sumAddr);
- )
-
- a249 5
- D(
- printf("scaled slope %f, intercept %f\n", scaleSlope, scaleYintercept);
- printf("smashed slope %f, intercept %f\n", smashedSlope, smashedYintercept);
- )
-
- d319 2
- d324 1
- a324 1
- doFont(9.0);
- d333 7
- a339 3
- sprintf(bvBuffer, "0x%x", spAddrMap[iCC].baseAddress);
- drawLabel(2.0, yCoord, bvBuffer,
- xCoord - 2.0 , spAddrMap[iCC].yCoord);
- d343 1
- a343 1
- xCoord - 10.0, spAddrMap[iCC].yCoord2);
- d345 1
- @
-
-
- 1.2
- log
- @corrected scaling and inclusion of mapped segments of library files
- @
- text
- @d5 3
- d15 1
- a15 1
- static char rcsident[] = "$Id: MachOView.m,v 1.1 93/12/19 12:57:04 ediger Exp Locker: ediger $";
- d24 1
- a24 1
- // openor re-open the Mach-O file being represented.
- d98 1
- a98 2
- {
- [sender setTitle:"actual scale"];
- d113 23
- d143 1
- a143 2
- {
- [sender setTitle:"libraries, too"];
- a183 2
- D(printf("enter MachOView -windowWillClose:%x\n", (unsigned int)sender);)
-
- a186 1
- D(printf("exit MachOView -windowWillClose:%x\n", (unsigned int)sender);)
- a213 2
- D(printf("enter MachOView -rescale\n");)
-
- a221 2
- D(printf("exit MachOView -rescale\n");)
-
- a228 1
- D(printf("MachOView -init\n");)
- a240 1
- D(printf("enter MachOView -initFrame:\n");)
- d244 1
- d246 1
- a246 1
- D(printf("exit MachOView -initFrame:\n");)
- d258 2
- a259 1
- float xCoord, yCoord;
- d283 1
- d286 3
- a288 1
- D(printf("MachOView -drawSelf::, %d segments\n", iSegments);)
- d295 1
- a295 1
- for (iCC = [theFile mappedSegments] - 1; iCC > -1; --iCC)
- d298 5
- d305 7
- a313 2
- D(printf("moveto (%f, %f)\n", xCoord,
- scaleSlope*(float)[oSegment getBaseAddress] + scaleYintercept);)
- a316 2
- D(printf("lineto (%f, %f)\n", xCoord,
- scaleSlope*(float)[oSegment getUpperAddress] + scaleYintercept);)
- a317 5
- D(printf(" -> (0x%lx - 0x%lx = 0x%lx)\n",
- [oSegment getUpperAddress],
- [oSegment getBaseAddress],
- [oSegment getUpperAddress] - [oSegment getBaseAddress]
- );)
- d321 2
- a322 1
- D(printf("moveto (%f, %f)\n", xCoord, yCoord);)
- d329 2
- a330 1
- D(printf("lineto (%f, %f)\n", xCoord, yCoord);)
- a331 5
- D(printf(" -> (0x%lx - 0x%lx = 0x%lx)\n",
- [oSegment getUpperAddress],
- [oSegment getBaseAddress],
- [oSegment getUpperAddress] - [oSegment getBaseAddress]
- );)
- d340 32
- a379 1
- D(printf("MachOView -free\n");)
- d383 1
- a390 1
- D(printf("MachOView, -show:%x\n", (unsigned int)sender);)
- d392 1
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d4 4
- a7 1
- /* $Log$
- d12 1
- a12 1
- static char rcsident[] = "$Id$";
- d14 9
- d30 3
- d47 1
- a47 1
- D( printf("MachOView -findSizes, hi 0x%x, lo 0x%x, sum 0x%x\n",
- d49 1
- a49 1
- printf("exit MachOView -findSizes\n");)
- d54 2
- d61 2
- d74 1
- a74 2
- currentFileName = malloc(strlen(fileName) + 1);
- strcpy(currentFileName, fileName);
- d82 1
- a82 2
- [self findSizes];
- [self windowDidResize:self];
- d89 2
- a105 2
- {
- [self windowDidResize:self];
- a106 1
- }
- d111 2
- d119 1
- a119 1
- [sender setTitle:"no libraries"];
- d123 1
- a123 1
- [sender setTitle:"libraries, too"];
- d145 1
- a145 3
- [self findSizes];
- [self windowDidResize:self];
- [self display];
- d152 6
- d169 4
- d175 15
- d191 1
- d193 1
- a193 1
- D(printf("MachOView -windowDidResize:\n");)
- d197 2
- a198 9
- if (toScale)
- {
- slope = ht/(float)(hiAddr - loAddr);
- yintercept = 5.0 - slope*(float)loAddr;
- } else {
- float falseSize = (float)sumAddr;
- slope = ht/falseSize;
- yintercept = 0.0;
- }
- d200 2
- a201 2
- D(printf("MachOView -windowDidResize:, slope %f, intercept %f\n",
- slope, yintercept);)
- d203 2
- d208 2
- d218 5
- a226 2
- loAddr = (unsigned long)-1; /* cheat */
- sumAddr = hiAddr = 0;
- d234 5
- a247 1
- printf("slope %f, intercept %f\n", slope, yintercept);
- d250 7
- d281 1
- a281 1
- slope*(float)[oSegment getBaseAddress] + yintercept);
- d283 1
- a283 1
- slope*(float)[oSegment getBaseAddress] + yintercept);)
- d286 1
- a286 1
- slope*(float)[oSegment getUpperAddress] + yintercept);
- d288 1
- a288 1
- slope*(float)[oSegment getUpperAddress] + yintercept);)
- d300 1
- a300 1
- yCoord += slope*
- d302 1
- a302 1
- - [oSegment getBaseAddress]) + yintercept;
- d324 2
- d335 2
- @
-