Index: meta/src/TCint.cxx =================================================================== --- meta/src/TCint.cxx (revision 21351) +++ meta/src/TCint.cxx (working copy) @@ -1109,67 +1109,68 @@ fRootMapFiles = new TObjArray; fRootMapFiles->SetOwner(); + } - // Load all rootmap files in the dynamic load path ((DY)LD_LIBRARY_PATH, etc.). - // A rootmap file must end with the string ".rootmap". - TString ldpath = gSystem->GetDynamicPath(); + // Load all rootmap files in the dynamic load path ((DY)LD_LIBRARY_PATH, etc.). + // A rootmap file must end with the string ".rootmap". + TString ldpath = gSystem->GetDynamicPath(); #ifdef WIN32 - TObjArray *paths = ldpath.Tokenize(";"); + TObjArray *paths = ldpath.Tokenize(";"); #else - TObjArray *paths = ldpath.Tokenize(":"); + TObjArray *paths = ldpath.Tokenize(":"); #endif - TString d; - for (Int_t i = 0; i < paths->GetEntriesFast(); i++) { - d = ((TObjString*)paths->At(i))->GetString(); - // check if directory already scanned - Int_t skip = 0; - for (Int_t j = 0; j < i; j++) { - TString pd = ((TObjString*)paths->At(j))->GetString(); - if (pd == d) { - skip++; - break; - } + TString d; + for (Int_t i = 0; i < paths->GetEntriesFast(); i++) { + d = ((TObjString*)paths->At(i))->GetString(); + // check if directory already scanned + Int_t skip = 0; + for (Int_t j = 0; j < i; j++) { + TString pd = ((TObjString*)paths->At(j))->GetString(); + if (pd == d) { + skip++; + break; } - if (!skip) { - void *dirp = gSystem->OpenDirectory(d); - if (dirp) { - if (gDebug > 0) - Info("LoadLibraryMap", "%s", d.Data()); - const char *f1; - while ((f1 = gSystem->GetDirEntry(dirp))) { - TString f = f1; - if (f.EndsWith(".rootmap")) { - TString p; - p = d + "/" + f; - if (!gSystem->AccessPathName(p, kReadPermission)) { - if (gDebug > 1) - Info("LoadLibraryMap", " rootmap file: %s", p.Data()); - fMapfile->ReadFile(p, kEnvGlobal); - fRootMapFiles->Add(new TObjString(p)); - } + } + if (!skip) { + void *dirp = gSystem->OpenDirectory(d); + if (dirp) { + if (gDebug > 0) + Info("LoadLibraryMap", "%s", d.Data()); + const char *f1; + while ((f1 = gSystem->GetDirEntry(dirp))) { + TString f = f1; + if (f.EndsWith(".rootmap")) { + TString p; + p = d + "/" + f; + if (!gSystem->AccessPathName(p, kReadPermission)) { + if (gDebug > 1) + Info("LoadLibraryMap", " rootmap file: %s", p.Data()); + fMapfile->ReadFile(p, kEnvGlobal); + fRootMapFiles->Add(new TObjString(p)); } - if (f.BeginsWith("rootmap")) { - TString p; - p = d + "/" + f; - FileStat_t stat; - if (gSystem->GetPathInfo(p, stat) == 0 && R_ISREG(stat.fMode)) - Warning("LoadLibraryMap", "please rename %s to end with \".rootmap\"", p.Data()); - } } + if (f.BeginsWith("rootmap")) { + TString p; + p = d + "/" + f; + FileStat_t stat; + if (gSystem->GetPathInfo(p, stat) == 0 && R_ISREG(stat.fMode)) + Warning("LoadLibraryMap", "please rename %s to end with \".rootmap\"", p.Data()); + } } - gSystem->FreeDirectory(dirp); } + gSystem->FreeDirectory(dirp); } + } - delete paths; - if (!fMapfile->GetTable()->GetEntries()) { - return -1; - } + delete paths; + if (!fMapfile->GetTable()->GetEntries()) { + return -1; } if (rootmapfile && *rootmapfile) { // Add content of a specific rootmap file + //EDDY why is rootmapfile not added to fRootMapFiles ? fMapfile->IgnoreDuplicates(kFALSE); fMapfile->ReadFile(rootmapfile, kEnvGlobal); } @@ -1236,6 +1237,98 @@ } //______________________________________________________________________________ +Int_t TCint::RescanLibraryMap() +{ + // Scan again along the dynamic path for library maps. Entries for the loaded + // shared libraries are unloaded first. This can be useful after reseting + // the dynamic path through TSystem::SetDynamicPath() + // In case of error -1 is returned, 0 otherwise. + + UnloadAllSharedLibraryMaps(); + LoadLibraryMap(); + + return 0; +} + +//______________________________________________________________________________ +Int_t TCint::ReloadAllSharedLibraryMaps() +{ + // Reload the library map entries coming from all the loaded shared libraries, + // after first unloading the current ones. + // In case of error -1 is returned, 0 otherwise. + + const TString sharedLibLStr = GetSharedLibs(); + const TObjArray *sharedLibL = sharedLibLStr.Tokenize(" "); + const Int_t nrSharedLibs = sharedLibL->GetEntriesFast(); + + for (Int_t ilib = 0; ilib < nrSharedLibs; ilib++) { + const TString sharedLibStr = ((TObjString *)sharedLibL->At(ilib))->GetString(); + const TString sharedLibBaseStr = gSystem->BaseName(sharedLibStr); + const Int_t ret = UnloadLibraryMap(sharedLibBaseStr); + + if (ret < 0) continue; + + TString rootMapBaseStr = sharedLibBaseStr; + if (sharedLibBaseStr.EndsWith(".dll")) + rootMapBaseStr.ReplaceAll(".dll",""); + else if (sharedLibBaseStr.EndsWith(".DLL")) + rootMapBaseStr.ReplaceAll(".DLL",""); + else if (sharedLibBaseStr.EndsWith(".so")) + rootMapBaseStr.ReplaceAll(".so",""); + else if (sharedLibBaseStr.EndsWith(".sl")) + rootMapBaseStr.ReplaceAll(".sl",""); + else if (sharedLibBaseStr.EndsWith(".dl")) + rootMapBaseStr.ReplaceAll(".dl",""); + else if (sharedLibBaseStr.EndsWith(".a")) + rootMapBaseStr.ReplaceAll(".a",""); + else { + Error("ReloadAllSharedLibraryMaps","Unknown library type %s",sharedLibBaseStr.Data()); + delete sharedLibL; + return -1; + } + rootMapBaseStr += ".rootmap"; + + const char *rootMap = gSystem->Which(gSystem->GetDynamicPath(),rootMapBaseStr); + if (!rootMap) { + Error("ReloadAllSharedLibraryMaps","Could not find rootmap %s in path",rootMap); + delete [] rootMap; + delete sharedLibL; + return -1; + } + + const Int_t status = LoadLibraryMap(rootMap); + if (status < 0) { + Error("ReloadAllSharedLibraryMaps","Error loading map %s",rootMap); + delete [] rootMap; + delete sharedLibL; + return -1; + } + delete [] rootMap; + } + delete sharedLibL; + + return 0; +} + +//______________________________________________________________________________ +Int_t TCint::UnloadAllSharedLibraryMaps() +{ + // Unload the library map entries coming from all the loaded shared libraries. + // Returns 0 if succesful + + const TString sharedLibLStr = GetSharedLibs(); + const TObjArray *sharedLibL = sharedLibLStr.Tokenize(" "); + for (Int_t ilib = 0; ilib < sharedLibL->GetEntriesFast(); ilib++) { + const TString sharedLibStr = ((TObjString *)sharedLibL->At(ilib))->GetString(); + const TString sharedLibBaseStr = gSystem->BaseName(sharedLibStr); + UnloadLibraryMap(sharedLibBaseStr); + } + delete sharedLibL; + + return 0; +} + +//______________________________________________________________________________ Int_t TCint::UnloadLibraryMap(const char *library) { // Unload library map entries coming from the specified library. @@ -1297,6 +1390,7 @@ } if (!strcmp(library, lib)) { + //EDDY : is this a memory leak ?? if (fMapfile->GetTable()->Remove(rec) == 0) { Error("UnloadLibraryMap", "entry for <%s,%s> not found in library map table", cls.Data(), lib); ret = -1; Index: meta/inc/TCint.h =================================================================== --- meta/inc/TCint.h (revision 21351) +++ meta/inc/TCint.h (working copy) @@ -97,6 +97,9 @@ Int_t Load(const char *filenam, Bool_t system = kFALSE); void LoadMacro(const char *filename, EErrorCode *error = 0); Int_t LoadLibraryMap(const char *rootmapfile = 0); + Int_t RescanLibraryMap(); + Int_t ReloadAllSharedLibraryMaps(); + Int_t UnloadAllSharedLibraryMaps(); Int_t UnloadLibraryMap(const char *library); Long_t ProcessLine(const char *line, EErrorCode *error = 0); Long_t ProcessLineAsynch(const char *line, EErrorCode *error = 0);