Changeset 223
- Timestamp:
- 08/01/06 23:42:41 (2 years ago)
- Files:
-
- trunk/ddl/PathLibrary.d (modified) (13 diffs)
- trunk/ddl/omf/OMFLibrary.d (modified) (1 diff)
- trunk/ddl/omf/OMFModule.d (modified) (2 diffs)
- trunk/test/pathtest1.d (added)
- trunk/test/pathtest2.d (added)
- trunk/test/testconfig.d (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/PathLibrary.d
r176 r223 33 33 private import ddl.Attributes; 34 34 private import ddl.ExportSymbol; 35 private import ddl.Utils; 35 36 36 37 private import mango.io.FileScan; … … 49 50 FilePath root; 50 51 52 debug protected void debugPathList(char[] prompt,FilePath[] list){ 53 debugLog("%s (%d)\n",prompt,list.length); 54 foreach(path; list){ 55 debugLog(" %s\n",path.toUtf8()); 56 } 57 } 58 51 59 protected FilePath[] getRootFiles(){ 52 60 FilePath[] result = (new FileProxy(root)).toList(); … … 57 65 result.length = 0; 58 66 } 59 debug Log("PathLibrary.getRootFiles - %s",result);67 debug debugPathList("PathLibrary.getRootFiles",result); 60 68 return result; 61 69 } … … 69 77 result.length = 0; 70 78 } 71 debug Log("PathLibrary.getRootFiles - %s",result);79 debug debugPathList("PathLibrary.getFiles",result); 72 80 return result; 73 81 } … … 87 95 scan.files(&handle); 88 96 89 debug Log("PathLibrary.getFiles - %s",result);97 debug debugPathList("PathLibrary.getAllFiles",result); 90 98 return result; 91 99 } … … 105 113 } 106 114 115 protected char[] parseNamespace(char[] symbolName){ 116 char[] dName = demangleSymbol(symbolName); 117 uint split; 118 119 // find where symbol ends 120 for(split=0; split<dName.length; split++){ 121 switch(dName[split]){ 122 case '(': 123 case ' ': 124 case ';': 125 break; 126 default: 127 } 128 } 129 return dName[0..split]; 130 } 131 107 132 public this(char[] rootPath,LoaderRegistry loaderRegistry){ 108 133 this.root = new FilePath(rootPath); … … 111 136 //pre-load all root libs 112 137 foreach(FilePath filepath; getRootFiles()){ 113 debug Log("[PathLibrary] Loading: %s",filepath.splice(root));138 debug debugLog("[PathLibrary] Loading: %s",filepath.splice(root)); 114 139 DynamicLibrary lib = loaderRegistry.load(filepath.splice(root)); 115 140 if(lib){ … … 118 143 } 119 144 120 attributes["PATH.path"] = root.to String;121 } 122 123 public ExportSymbol getExport(char[] name){124 DynamicModule mod = getModuleForExport(name);125 if(mod) return mod.get Export(name);126 return ExportSymbol.NONE;127 } 128 129 public ExportSymbol[] get Exports(){145 attributes["PATH.path"] = root.toUtf8; 146 } 147 148 public ExportSymbolPtr getSymbol(char[] name){ 149 DynamicModule mod = this.getModuleForSymbol(name); 150 if(mod) return mod.getSymbol(name); 151 return null; 152 } 153 154 public ExportSymbol[] getSymbols(){ 130 155 ExportSymbol[] symbols; 131 156 foreach(DynamicModule mod; getModules()){ 132 symbols ~= mod.get Exports();157 symbols ~= mod.getSymbols(); 133 158 } 134 159 return symbols; … … 155 180 } 156 181 157 public DynamicModule getModuleFor Export(char[] name){182 public DynamicModule getModuleForSymbol(char[] name){ 158 183 if(name.length > 2 && name[0..2] == "_D"){ 159 184 char[] namespace = parseNamespace(name); … … 161 186 // dig through the root libs 162 187 foreach(DynamicLibrary lib; rootLibraries){ 163 DynamicModule mod = lib.getModuleFor Export(name);188 DynamicModule mod = lib.getModuleForSymbol(name); 164 189 cachedLibraries[namespace] = lib; 165 190 if(mod) return mod; … … 168 193 // attempt to search the cache 169 194 DynamicLibrary* pLib = namespace in cachedLibraries; 170 if(pLib) return pLib.getModuleFor Export(name);195 if(pLib) return pLib.getModuleForSymbol(name); 171 196 172 197 // look for a path match … … 176 201 foreach(FilePath libPath; getFiles(path)){ 177 202 DynamicLibrary lib = loaderRegistry.load(libPath.toString); 178 if(lib) return lib.getModuleFor Export(name);203 if(lib) return lib.getModuleForSymbol(name); 179 204 } 180 205 } … … 184 209 // dig through the root libs 185 210 foreach(DynamicLibrary lib; rootLibraries){ 186 DynamicModule mod = lib.getModuleFor Export(name);211 DynamicModule mod = lib.getModuleForSymbol(name); 187 212 if(mod) return mod; 188 213 } 189 214 } 190 215 //failed to find the module 216 debugLog("PathLibrary.getModuleForSymbol - failed to find: %s",name); 191 217 return null; 192 218 } trunk/ddl/omf/OMFLibrary.d
r219 r223 81 81 82 82 public DynamicModule getModuleForSymbol(char[] name){ 83 debug debugLog("[OMF] looking for " ~ name);83 debug debugLog("[OMF] looking for %s in %s",name,attributes["omf.filename"]); 84 84 DynamicModule* mod = name in crossReference; 85 85 debug debugLog("[OMF] Result: %0.8X",mod); trunk/ddl/omf/OMFModule.d
r221 r223 271 271 symbolXref[binary.names[comdat.nameIndex]].type = SymbolType.Strong; 272 272 symbolXref[binary.names[comdat.nameIndex]].address = *addr; 273 274 debug debugLog("%d %s first bytes: %0.8X\n",idx,cast(char[])binary.names[comdat.nameIndex],*cast(uint*)comdat.data.ptr);275 273 } 276 274 … … 442 440 foreach(idx,b; cast(ubyte[])(segdef.data)){ 443 441 if(idx % 16 == 0){ 444 result ~= sprint(" | %s\n\t[%0.8X] ",buf2,segdef.data.ptr+idx);442 result ~= sprint(" | %s\n [%0.8X] ",buf2,segdef.data.ptr+idx); 445 443 buf2 = ""; 446 444 } 445 if(b < 16) result ~= "0"; //HACK: sprint doesn't left-pad correctly 447 446 result ~= sprint("%0.2X ",b); 448 447 if(b >= 32 && b <= 126){ 449 buf2 ~= cast(char)b ~ " ";448 buf2 ~= cast(char)b; 450 449 } 451 450 else{ 452 buf2 ~= ". ";451 buf2 ~= "."; 453 452 } 454 453 }
