Changeset 15
- Timestamp:
- 10/03/09 13:23:10 (3 years ago)
- Files:
-
- trunk/analyzer/analyzerc.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/analyzer/analyzerc.d
r14 r15 269 269 writef(" - outside heap/stack"); 270 270 writefln(); 271 } 272 273 void dump(ubyte[] data, uint startAddr) 274 { 275 foreach (i,v;data) 276 { 277 if (i%16==0) 278 writef("%08X: ", i+startAddr); 279 else 280 if (i%8==0) 281 writef(" "); 282 writef("%02X ", v); 283 if (i%16==15 || i==data.length-1) 284 { 285 for (int l=i%16+1;l<16;l++) 286 { 287 if (l%8==0) 288 writef(" "); 289 writef(" "); 290 } 291 writef("| "); 292 foreach (vv;data[i&~15..i+1]) 293 if (vv==0) 294 writef(" "); 295 else if (vv<32 || vv>=127) 296 writef("."); 297 else 298 writef(cast(char)vv); 299 writefln; 300 } 301 } 271 302 } 272 303 … … 772 803 auto event = cast(MemoryDumpEvent)log.events[analysis.cursor]; 773 804 if (event is null && analysis.cursor>0) event = cast(MemoryDumpEvent)log.events[analysis.cursor-1]; 774 if (event is null) throw new Exception("This is not a memory dump /mapevent.");805 if (event is null) throw new Exception("This is not a memory dump event."); 775 806 bool found; 776 807 foreach (int poolNr, ref pool;event.pools) … … 779 810 if (max>pool.topCommittedAddr) throw new Exception("Specified address range intersects a reserved memory region"); 780 811 found = true; 781 ubyte[] data = event.loadPoolData(poolNr)[min-pool.addr .. max-pool.addr]; 782 foreach (i,v;data) 783 { 784 if (i%16==0) 785 writef("%08X: ", i+min); 786 else 787 if (i%8==0) 788 writef(" "); 789 writef("%02X ", v); 790 if (i%16==15 || i==data.length-1) 791 { 792 for (int l=i%16+1;l<16;l++) 793 { 794 if (l%8==0) 795 writef(" "); 796 writef(" "); 797 } 798 writef("| "); 799 foreach (vv;data[i&~15..i+1]) 800 if (vv==0) 801 writef(" "); 802 else if (vv<32 || vv>=127) 803 writef("."); 804 else 805 writef(cast(char)vv); 806 writefln; 807 } 808 } 812 ubyte[] data = event.loadPoolData(poolNr); 813 dump(data[min-pool.addr .. max-pool.addr], min); 809 814 delete data; 810 815 } 811 816 if (!found) 812 throw new Exception("Specified address range does not belong in any pool."); 817 if (event.stackTop<=min && event.stackBottom>=max) 818 { 819 found = true; 820 ubyte[] data = event.loadStackData(); 821 dump(data[min-event.stackTop .. max-event.stackTop], min); 822 delete data; 823 } 824 if (!found) 825 foreach (ref root; event.roots) 826 if (root.bottom<=min && root.top>=max) 827 { 828 found = true; 829 ubyte[] data = event.loadRootData(root); 830 dump(data[min-root.bottom.. max-root.bottom], min); 831 delete data; 832 } 833 if (!found) 834 throw new Exception("Data for specified address range is not available."); 835 break; 836 } 837 // === symbols === 838 case "symbol": 839 case "symbols": 840 { 841 if (args.length!=2) 842 throw new Exception("Specify a search pattern"); 843 foreach (ref symbol; map.symbols) 844 if (symbol.name.find(args[1])>=0) 845 writefln("%08X - %s", symbol.address, symbol.prettyName()); 846 break; 847 } 848 case "symbolat": 849 { 850 if (args.length!=2) 851 throw new Exception("Specify an address"); 852 uint address = fromHex(args[1]); 853 writefln("%08X - %s", address, mapLookUp(address)); 813 854 break; 814 855 } … … 848 889 // other 849 890 case "help": 891 case "?": 850 892 writefln("Command list. Event numbers are always in decimal, addresses are in hex."); 851 893 writefln("Use ^ in event numbers for start, @ for cursor position, $ for end of file."); … … 883 925 writefln("allrefs <address> [<address2>] same, but also search unallocated memory"); 884 926 writefln("dump <address> [<address2>] dump memory at address/range"); 927 /*highVideo();*/writefln("=== symbols ===");/*normVideo();*/ 928 writefln("symbol <symbol> show symbols matching name"); 929 writefln("symbolat <address> look up symbol by offset"); 885 930 /*highVideo();*/writefln("=== diagnostics ===");/*normVideo();*/ 886 931 writefln("integrity verify the validity of the analysis state");
