home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / DevTools / MachOViewer / Source / RCS / MachOFile.h,v < prev    next >
Encoding:
Text File  |  1994-05-03  |  5.9 KB  |  366 lines

  1. head     1.10;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ediger:1.10;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.10
  10. date     94.05.04.11.20.18;  author ediger;  state Exp;
  11. branches ;
  12. next     1.9;
  13.  
  14. 1.9
  15. date     94.05.01.17.32.04;  author ediger;  state Exp;
  16. branches ;
  17. next     1.8;
  18.  
  19. 1.8
  20. date     94.02.07.21.21.01;  author ediger;  state Exp;
  21. branches ;
  22. next     1.7;
  23.  
  24. 1.7
  25. date     94.01.30.16.28.52;  author ediger;  state Exp;
  26. branches ;
  27. next     1.6;
  28.  
  29. 1.6
  30. date     93.12.18.22.48.44;  author ediger;  state Exp;
  31. branches ;
  32. next     1.5;
  33.  
  34. 1.5
  35. date     93.12.07.23.30.53;  author ediger;  state Exp;
  36. branches ;
  37. next     1.4;
  38.  
  39. 1.4
  40. date     93.12.02.00.27.53;  author ediger;  state Exp;
  41. branches ;
  42. next     1.3;
  43.  
  44. 1.3
  45. date     93.10.31.21.33.54;  author ediger;  state Exp;
  46. branches ;
  47. next     1.2;
  48.  
  49. 1.2
  50. date     93.10.27.23.43.42;  author ediger;  state Exp;
  51. branches ;
  52. next     1.1;
  53.  
  54. 1.1
  55. date     93.10.25.18.00.25;  author ediger;  state Exp;
  56. branches ;
  57. next     ;
  58.  
  59.  
  60. desc
  61. @MachOFile object interface and declaration
  62. @
  63.  
  64.  
  65. 1.10
  66. log
  67. @support for finding which segment a thread's pc is in
  68. @
  69. text
  70. @/*
  71.  * $Id: MachOFile.h,v 1.9 94/05/01 17:32:04 ediger Exp Locker: ediger $
  72.  * $Log:    MachOFile.h,v $
  73.  * Revision 1.9  94/05/01  17:32:04  ediger
  74.  * added - (struct section *)sectionNamed:: method
  75.  * 
  76.  * Revision 1.8  94/02/07  21:21:01  ediger
  77.  * added methods and instance vars to allow an already-mapped file
  78.  * to be represented by the MachOFile object instance.
  79.  * 
  80.  * Revision 1.7  94/01/30  16:28:52  ediger
  81.  * add support for threads
  82.  * 
  83.  * Revision 1.6  93/12/18  22:48:44  ediger
  84.  * -initFromFileNamed: method renamed to -fillFromFileNamed:
  85.  * 
  86.  * Revision 1.5  93/12/07  23:30:53  ediger
  87.  * added cpuType and cpuSubtype methods
  88.  * split error number return between lastErrno and lastKernReturn inst vars
  89.  * 
  90.  * Revision 1.4  93/12/02  00:27:53  ediger
  91.  * added -(char *)fileType method declaration
  92.  * 
  93.  * Revision 1.3  93/10/31  21:33:54  ediger
  94.  * removed declarations of -printSegments and +new
  95.  * 
  96.  * Revision 1.2  93/10/27  23:43:42  ediger
  97.  * Definition of MachOFile object that uses LoadCommand subclasses
  98.  * 
  99.  */
  100. #import <stdlib.h>
  101. #import <libc.h>
  102. #import <sys/types.h>
  103. #import <sys/stat.h>
  104. #import <fcntl.h>
  105. #import <assert.h>
  106. #import <objc/Object.h>
  107. #import <mach/mach.h>
  108. #import <mach/mach_error.h>
  109. #import <mach-o/loader.h>
  110. #import <errno.h>
  111. #import <mach/mach_error.h>
  112.  
  113. #import <objc/List.h>
  114. #import <SortedList.h>
  115. #import <LoadCommand.h>
  116.  
  117. @@interface MachOFile: Object
  118. {
  119.     SortedList         *mappedSegmentList;
  120.     List               *unmappedSegmentList;
  121.     List               *threadList;
  122.     int                *threadSegment;
  123.  
  124.     struct mach_header *fileHeader;
  125.  
  126.     vm_offset_t         mappedFileAddress;
  127.     vm_size_t           mappedFileSize;
  128.     int                 fileDescriptor;
  129.  
  130.     BOOL                mapsFile;
  131.     BOOL                addMappedFiles;
  132.  
  133.     int                 lastErrno;
  134.     kern_return_t       lastKernReturn;
  135. }
  136.  
  137. - free;
  138. - init;
  139.  
  140. // do the rest of the initialization
  141. - fillFromFileNamed: (char *)filename;
  142. - fillFromAddress: (char *)address;
  143.  
  144. // internal use method
  145. - (int)mapFile: (char *)filename;
  146.  
  147. // count of segments or threads
  148. - (int)mappedSegments;
  149. - (int)unmappedSegments;
  150. - (int)threads;
  151.  
  152. - (int)segmentOfThread:(int)threadNumber;
  153.  
  154. // actually gives back LoadCommand subclass
  155. - mappedSegment: (int)segmentNumber;
  156. - unmappedSegment: (int)segmentNumber;
  157. - thread: (int)threadNumber;
  158.  
  159. // give back a pointer to a piece of an LC_SEGMENT
  160. - (struct section *)sectionNamed:(char *)sectName inSegNamed:(char *)segName;
  161.  
  162. // printable strings about the file.
  163. - (char *)fileType;
  164. - (char *)cpuType;
  165. - (char *)cpuSubtype;
  166.  
  167. // change how object views the file
  168. - considerMappedFiles;
  169. - unconsiderMappedFiles;
  170. - removeSegment:aLoadCommand;
  171.  
  172. @@end
  173. @
  174.  
  175.  
  176. 1.9
  177. log
  178. @added - (struct section *)sectionNamed:: method
  179. @
  180. text
  181. @d2 1
  182. a2 1
  183.  * $Id: MachOFile.h,v 1.8 94/02/07 21:21:01 ediger Exp Locker: ediger $
  184. d4 3
  185. d53 1
  186. d82 2
  187. @
  188.  
  189.  
  190. 1.8
  191. log
  192. @added methods and instance vars to allow an already-mapped file
  193. to be represented by the MachOFile object instance.
  194. @
  195. text
  196. @d2 1
  197. a2 1
  198.  * $Id: MachOFile.h,v 1.7 94/01/30 16:28:52 ediger Exp Locker: ediger $
  199. d4 4
  200. d50 1
  201. d52 1
  202. a52 2
  203.     BOOL                mapsFile;
  204.     int                 fileDescriptor;
  205. d55 3
  206. d59 1
  207. a64 1
  208.  
  209. d67 1
  210. a68 1
  211.  
  212. d71 1
  213. d74 1
  214. a75 1
  215.  
  216. a76 1
  217.  
  218. d79 1
  219. a80 1
  220.  
  221. a81 1
  222.  
  223. d84 2
  224. a85 1
  225. - considerMappedFiles;
  226. d87 1
  227. a87 4
  228. - unconsiderMappedFiles;
  229.  
  230. - removeSegment:aLoadCommand;
  231.  
  232. d91 5
  233. @
  234.  
  235.  
  236. 1.7
  237. log
  238. @add support for threads
  239. @
  240. text
  241. @d2 1
  242. a2 1
  243.  * $Id: MachOFile.h,v 1.6 93/12/18 22:48:44 ediger Exp Locker: ediger $
  244. d4 3
  245. d47 1
  246. d61 2
  247. @
  248.  
  249.  
  250. 1.6
  251. log
  252. @-initFromFileNamed: method renamed to -fillFromFileNamed:
  253. @
  254. text
  255. @d2 1
  256. a2 1
  257.  * $Id: MachOFile.h,v 1.5 93/12/07 23:30:53 ediger Exp Locker: ediger $
  258. d4 3
  259. d42 1
  260. d64 2
  261. d69 2
  262. @
  263.  
  264.  
  265. 1.5
  266. log
  267. @added cpuType and cpuSubtype methods
  268. split error number return between lastErrno and lastKernReturn inst vars
  269. @
  270. text
  271. @d2 1
  272. a2 1
  273.  * $Id: MachOFile.h,v 1.4 93/12/02 00:27:53 ediger Exp Locker: ediger $
  274. d4 4
  275. d52 1
  276. a52 1
  277. - initFromFileNamed: (char *) filename;
  278. d54 1
  279. a54 1
  280. - (int)mapFile: (char *) filename;
  281. d60 1
  282. a60 1
  283. - mappedSegment:(int)segmentNumber;
  284. d62 1
  285. a62 1
  286. - unmappedSegment:(int)segmentNumber;
  287. @
  288.  
  289.  
  290. 1.4
  291. log
  292. @added -(char *)fileType method declaration
  293. @
  294. text
  295. @d2 1
  296. a2 1
  297.  * $Id: MachOFile.h,v 1.3 93/10/31 21:33:54 ediger Exp Locker: ediger $
  298. d4 3
  299. d19 1
  300. d24 2
  301. d40 2
  302. d67 2
  303. @
  304.  
  305.  
  306. 1.3
  307. log
  308. @removed declarations of -printSegments and +new
  309. @
  310. text
  311. @d2 1
  312. a2 1
  313.  * $Id: MachOFile.h,v 1.2 93/10/27 23:43:42 ediger Exp Locker: ediger $
  314. d4 3
  315. d40 1
  316. a40 1
  317. - initFromFile: (char *) filename;
  318. d57 2
  319. @
  320.  
  321.  
  322. 1.2
  323. log
  324. @Definition of MachOFile object that uses LoadCommand subclasses
  325. @
  326. text
  327. @d2 5
  328. a6 2
  329.  * $Id$
  330.  * $Log$
  331. a32 2
  332. + new;
  333.  
  334. a51 2
  335.  
  336. - printSegments;
  337. @
  338.  
  339.  
  340. 1.1
  341. log
  342. @Initial revision
  343. @
  344. text
  345. @d1 8
  346. a8 4
  347. #include <stdlib.h>
  348. #include <libc.h>
  349. #include <sys/types.h>
  350. #include <sys/stat.h>
  351. d15 1
  352. d21 2
  353. a22 1
  354.     SortedList         *segmentList;
  355. d27 1
  356. d36 1
  357. a36 1
  358. -initFromFile: (char *) filename;
  359. d38 1
  360. a38 1
  361. -(int)mapFile: (char *) filename;
  362. d40 15
  363. a54 1
  364. -printSegments;
  365. @
  366.