~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lldb/source/Core/PluginManager.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    ePluginGetInstanceAtIndex
36
36
};
37
37
 
 
38
 
 
39
typedef bool (*PluginInitCallback) (void);
 
40
typedef void (*PluginTermCallback) (void);
 
41
 
38
42
struct PluginInfo
39
43
{
40
44
    void *plugin_handle;
41
 
    void *plugin_init_callback;
42
 
    void *plugin_term_callback;
 
45
    PluginInitCallback plugin_init_callback;
 
46
    PluginTermCallback plugin_term_callback;
43
47
};
44
48
 
45
49
typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
111
115
            if (plugin_info.plugin_handle)
112
116
            {
113
117
                bool success = false;
114
 
                plugin_info.plugin_init_callback = Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
 
118
                plugin_info.plugin_init_callback = (PluginInitCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
115
119
                if (plugin_info.plugin_init_callback)
116
120
                {
117
121
                    // Call the plug-in "bool LLDBPluginInitialize(void)" function
118
 
                    success = ((bool (*)(void))plugin_info.plugin_init_callback)();
 
122
                    success = plugin_info.plugin_init_callback();
119
123
                }
120
124
 
121
125
                if (success)
122
126
                {
123
127
                    // It is ok for the "LLDBPluginTerminate" symbol to be NULL
124
 
                    plugin_info.plugin_term_callback = Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
 
128
                    plugin_info.plugin_term_callback = (PluginTermCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
125
129
                }
126
130
                else 
127
131
                {
209
213
        if (pos->second.plugin_handle)
210
214
        {
211
215
            if (pos->second.plugin_term_callback)
212
 
                ((void (*)(void))pos->second.plugin_term_callback)();
 
216
                pos->second.plugin_term_callback();
213
217
            Host::DynamicLibraryClose (pos->second.plugin_handle);
214
218
        }
215
219
    }
229
233
    {
230
234
    }
231
235
 
232
 
    std::string name;
 
236
    ConstString name;
233
237
    std::string description;
234
238
    ABICreateInstance create_callback;
235
239
};
253
257
bool
254
258
PluginManager::RegisterPlugin
255
259
(
256
 
    const char *name,
 
260
    const ConstString &name,
257
261
    const char *description,
258
262
    ABICreateInstance create_callback
259
263
)
261
265
    if (create_callback)
262
266
    {
263
267
        ABIInstance instance;
264
 
        assert (name && name[0]);
265
 
        instance.name.assign (name);
 
268
        assert ((bool)name);
 
269
        instance.name = name;
266
270
        if (description && description[0])
267
271
            instance.description = description;
268
272
        instance.create_callback = create_callback;
305
309
}
306
310
 
307
311
ABICreateInstance
308
 
PluginManager::GetABICreateCallbackForPluginName (const char *name)
 
312
PluginManager::GetABICreateCallbackForPluginName (const ConstString &name)
309
313
{
310
 
    if (name && name[0])
 
314
    if (name)
311
315
    {
312
316
        Mutex::Locker locker (GetABIInstancesMutex ());
313
 
        llvm::StringRef name_sref(name);
314
317
        ABIInstances &instances = GetABIInstances ();
315
318
 
316
319
        ABIInstances::iterator pos, end = instances.end();
317
320
        for (pos = instances.begin(); pos != end; ++ pos)
318
321
        {
319
 
            if (name_sref.equals (pos->name))
 
322
            if (name == pos->name)
320
323
                return pos->create_callback;
321
324
        }
322
325
    }
336
339
    {
337
340
    }
338
341
 
339
 
    std::string name;
 
342
    ConstString name;
340
343
    std::string description;
341
344
    DisassemblerCreateInstance create_callback;
342
345
};
360
363
bool
361
364
PluginManager::RegisterPlugin
362
365
(
363
 
    const char *name,
 
366
    const ConstString &name,
364
367
    const char *description,
365
368
    DisassemblerCreateInstance create_callback
366
369
)
368
371
    if (create_callback)
369
372
    {
370
373
        DisassemblerInstance instance;
371
 
        assert (name && name[0]);
 
374
        assert ((bool)name);
372
375
        instance.name = name;
373
376
        if (description && description[0])
374
377
            instance.description = description;
412
415
}
413
416
 
414
417
DisassemblerCreateInstance
415
 
PluginManager::GetDisassemblerCreateCallbackForPluginName (const char *name)
 
418
PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name)
416
419
{
417
 
    if (name && name[0])
 
420
    if (name)
418
421
    {
419
 
        llvm::StringRef name_sref(name);
420
422
        Mutex::Locker locker (GetDisassemblerMutex ());
421
423
        DisassemblerInstances &instances = GetDisassemblerInstances ();
422
424
        
423
425
        DisassemblerInstances::iterator pos, end = instances.end();
424
426
        for (pos = instances.begin(); pos != end; ++ pos)
425
427
        {
426
 
            if (name_sref.equals (pos->name))
 
428
            if (name == pos->name)
427
429
                return pos->create_callback;
428
430
        }
429
431
    }
445
447
    {
446
448
    }
447
449
 
448
 
    std::string name;
 
450
    ConstString name;
449
451
    std::string description;
450
452
    DynamicLoaderCreateInstance create_callback;
451
453
    DebuggerInitializeCallback debugger_init_callback;
472
474
bool
473
475
PluginManager::RegisterPlugin
474
476
(
475
 
    const char *name,
 
477
    const ConstString &name,
476
478
    const char *description,
477
479
    DynamicLoaderCreateInstance create_callback,
478
480
    DebuggerInitializeCallback debugger_init_callback
481
483
    if (create_callback)
482
484
    {
483
485
        DynamicLoaderInstance instance;
484
 
        assert (name && name[0]);
 
486
        assert ((bool)name);
485
487
        instance.name = name;
486
488
        if (description && description[0])
487
489
            instance.description = description;
525
527
}
526
528
 
527
529
DynamicLoaderCreateInstance
528
 
PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const char *name)
 
530
PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name)
529
531
{
530
 
    if (name && name[0])
 
532
    if (name)
531
533
    {
532
 
        llvm::StringRef name_sref(name);
533
534
        Mutex::Locker locker (GetDynamicLoaderMutex ());
534
535
        DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
535
536
        
536
537
        DynamicLoaderInstances::iterator pos, end = instances.end();
537
538
        for (pos = instances.begin(); pos != end; ++ pos)
538
539
        {
539
 
            if (name_sref.equals (pos->name))
 
540
            if (name == pos->name)
540
541
                return pos->create_callback;
541
542
        }
542
543
    }
555
556
    {
556
557
    }
557
558
    
558
 
    std::string name;
 
559
    ConstString name;
559
560
    std::string description;
560
561
    EmulateInstructionCreateInstance create_callback;
561
562
};
580
581
bool
581
582
PluginManager::RegisterPlugin
582
583
(
583
 
    const char *name,
 
584
    const ConstString &name,
584
585
    const char *description,
585
586
    EmulateInstructionCreateInstance create_callback
586
587
)
588
589
    if (create_callback)
589
590
    {
590
591
        EmulateInstructionInstance instance;
591
 
        assert (name && name[0]);
 
592
        assert ((bool)name);
592
593
        instance.name = name;
593
594
        if (description && description[0])
594
595
            instance.description = description;
631
632
}
632
633
 
633
634
EmulateInstructionCreateInstance
634
 
PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const char *name)
 
635
PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name)
635
636
{
636
 
    if (name && name[0])
 
637
    if (name)
637
638
    {
638
 
        llvm::StringRef name_sref(name);
639
639
        Mutex::Locker locker (GetEmulateInstructionMutex ());
640
640
        EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
641
641
        
642
642
        EmulateInstructionInstances::iterator pos, end = instances.end();
643
643
        for (pos = instances.begin(); pos != end; ++ pos)
644
644
        {
645
 
            if (name_sref.equals (pos->name))
 
645
            if (name == pos->name)
646
646
                return pos->create_callback;
647
647
        }
648
648
    }
660
660
    {
661
661
    }
662
662
    
663
 
    std::string name;
 
663
    ConstString name;
664
664
    std::string description;
665
665
    OperatingSystemCreateInstance create_callback;
666
666
};
682
682
}
683
683
 
684
684
bool
685
 
PluginManager::RegisterPlugin
686
 
(
687
 
 const char *name,
688
 
 const char *description,
689
 
 OperatingSystemCreateInstance create_callback
690
 
 )
 
685
PluginManager::RegisterPlugin (const ConstString &name,
 
686
                               const char *description,
 
687
                               OperatingSystemCreateInstance create_callback)
691
688
{
692
689
    if (create_callback)
693
690
    {
694
691
        OperatingSystemInstance instance;
695
 
        assert (name && name[0]);
 
692
        assert ((bool)name);
696
693
        instance.name = name;
697
694
        if (description && description[0])
698
695
            instance.description = description;
735
732
}
736
733
 
737
734
OperatingSystemCreateInstance
738
 
PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name)
 
735
PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name)
739
736
{
740
 
    if (name && name[0])
 
737
    if (name)
741
738
    {
742
 
        llvm::StringRef name_sref(name);
743
739
        Mutex::Locker locker (GetOperatingSystemMutex ());
744
740
        OperatingSystemInstances &instances = GetOperatingSystemInstances ();
745
741
        
746
742
        OperatingSystemInstances::iterator pos, end = instances.end();
747
743
        for (pos = instances.begin(); pos != end; ++ pos)
748
744
        {
749
 
            if (name_sref.equals (pos->name))
 
745
            if (name == pos->name)
750
746
                return pos->create_callback;
751
747
        }
752
748
    }
766
762
    {
767
763
    }
768
764
 
769
 
    std::string name;
 
765
    ConstString name;
770
766
    std::string description;
771
767
    LanguageRuntimeCreateInstance create_callback;
772
768
};
790
786
bool
791
787
PluginManager::RegisterPlugin
792
788
(
793
 
    const char *name,
 
789
    const ConstString &name,
794
790
    const char *description,
795
791
    LanguageRuntimeCreateInstance create_callback
796
792
)
798
794
    if (create_callback)
799
795
    {
800
796
        LanguageRuntimeInstance instance;
801
 
        assert (name && name[0]);
 
797
        assert ((bool)name);
802
798
        instance.name = name;
803
799
        if (description && description[0])
804
800
            instance.description = description;
841
837
}
842
838
 
843
839
LanguageRuntimeCreateInstance
844
 
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name)
 
840
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
845
841
{
846
 
    if (name && name[0])
 
842
    if (name)
847
843
    {
848
 
        llvm::StringRef name_sref(name);
849
844
        Mutex::Locker locker (GetLanguageRuntimeMutex ());
850
845
        LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
851
846
        
852
847
        LanguageRuntimeInstances::iterator pos, end = instances.end();
853
848
        for (pos = instances.begin(); pos != end; ++ pos)
854
849
        {
855
 
            if (name_sref.equals (pos->name))
 
850
            if (name == pos->name)
856
851
                return pos->create_callback;
857
852
        }
858
853
    }
866
861
    ObjectFileInstance() :
867
862
        name(),
868
863
        description(),
869
 
        create_callback(NULL)
 
864
        create_callback(NULL),
 
865
        create_memory_callback (NULL),
 
866
        get_module_specifications (NULL)
870
867
    {
871
868
    }
872
869
 
873
 
    std::string name;
 
870
    ConstString name;
874
871
    std::string description;
875
872
    ObjectFileCreateInstance create_callback;
876
873
    ObjectFileCreateMemoryInstance create_memory_callback;
877
 
 
 
874
    ObjectFileGetModuleSpecifications get_module_specifications;
878
875
};
879
876
 
880
877
typedef std::vector<ObjectFileInstance> ObjectFileInstances;
895
892
 
896
893
 
897
894
bool
898
 
PluginManager::RegisterPlugin
899
 
(
900
 
    const char *name,
901
 
    const char *description,
902
 
    ObjectFileCreateInstance create_callback,
903
 
    ObjectFileCreateMemoryInstance create_memory_callback
904
 
)
 
895
PluginManager::RegisterPlugin (const ConstString &name,
 
896
                               const char *description,
 
897
                               ObjectFileCreateInstance create_callback,
 
898
                               ObjectFileCreateMemoryInstance create_memory_callback,
 
899
                               ObjectFileGetModuleSpecifications get_module_specifications)
905
900
{
906
901
    if (create_callback)
907
902
    {
908
903
        ObjectFileInstance instance;
909
 
        assert (name && name[0]);
 
904
        assert ((bool)name);
910
905
        instance.name = name;
911
906
        if (description && description[0])
912
907
            instance.description = description;
913
908
        instance.create_callback = create_callback;
914
909
        instance.create_memory_callback = create_memory_callback;
 
910
        instance.get_module_specifications = get_module_specifications;
915
911
        Mutex::Locker locker (GetObjectFileMutex ());
916
912
        GetObjectFileInstances ().push_back (instance);
917
913
    }
960
956
    return NULL;
961
957
}
962
958
 
 
959
ObjectFileGetModuleSpecifications
 
960
PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
 
961
{
 
962
    Mutex::Locker locker (GetObjectFileMutex ());
 
963
    ObjectFileInstances &instances = GetObjectFileInstances ();
 
964
    if (idx < instances.size())
 
965
        return instances[idx].get_module_specifications;
 
966
    return NULL;
 
967
}
 
968
 
963
969
ObjectFileCreateInstance
964
 
PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name)
 
970
PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name)
965
971
{
966
 
    if (name && name[0])
 
972
    if (name)
967
973
    {
968
 
        llvm::StringRef name_sref(name);
969
974
        Mutex::Locker locker (GetObjectFileMutex ());
970
975
        ObjectFileInstances &instances = GetObjectFileInstances ();
971
976
        
972
977
        ObjectFileInstances::iterator pos, end = instances.end();
973
978
        for (pos = instances.begin(); pos != end; ++ pos)
974
979
        {
975
 
            if (name_sref.equals (pos->name))
 
980
            if (name == pos->name)
976
981
                return pos->create_callback;
977
982
        }
978
983
    }
981
986
 
982
987
 
983
988
ObjectFileCreateMemoryInstance
984
 
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const char *name)
 
989
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name)
985
990
{
986
 
    if (name && name[0])
 
991
    if (name)
987
992
    {
988
 
        llvm::StringRef name_sref(name);
989
993
        Mutex::Locker locker (GetObjectFileMutex ());
990
994
        ObjectFileInstances &instances = GetObjectFileInstances ();
991
995
        
992
996
        ObjectFileInstances::iterator pos, end = instances.end();
993
997
        for (pos = instances.begin(); pos != end; ++ pos)
994
998
        {
995
 
            if (name_sref.equals (pos->name))
 
999
            if (name == pos->name)
996
1000
                return pos->create_memory_callback;
997
1001
        }
998
1002
    }
1008
1012
    ObjectContainerInstance() :
1009
1013
        name(),
1010
1014
        description(),
1011
 
        create_callback(NULL)
 
1015
        create_callback (NULL),
 
1016
        get_module_specifications (NULL)
1012
1017
    {
1013
1018
    }
1014
1019
 
1015
 
    std::string name;
 
1020
    ConstString name;
1016
1021
    std::string description;
1017
1022
    ObjectContainerCreateInstance create_callback;
 
1023
    ObjectFileGetModuleSpecifications get_module_specifications;
 
1024
 
1018
1025
};
1019
1026
 
1020
1027
typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
1034
1041
}
1035
1042
 
1036
1043
bool
1037
 
PluginManager::RegisterPlugin
1038
 
(
1039
 
    const char *name,
1040
 
    const char *description,
1041
 
    ObjectContainerCreateInstance create_callback
1042
 
)
 
1044
PluginManager::RegisterPlugin (const ConstString &name,
 
1045
                               const char *description,
 
1046
                               ObjectContainerCreateInstance create_callback,
 
1047
                               ObjectFileGetModuleSpecifications get_module_specifications)
1043
1048
{
1044
1049
    if (create_callback)
1045
1050
    {
1046
1051
        ObjectContainerInstance instance;
1047
 
        assert (name && name[0]);
 
1052
        assert ((bool)name);
1048
1053
        instance.name = name;
1049
1054
        if (description && description[0])
1050
1055
            instance.description = description;
1051
1056
        instance.create_callback = create_callback;
 
1057
        instance.get_module_specifications = get_module_specifications;
1052
1058
        Mutex::Locker locker (GetObjectContainerMutex ());
1053
1059
        GetObjectContainerInstances ().push_back (instance);
1054
1060
    }
1087
1093
}
1088
1094
 
1089
1095
ObjectContainerCreateInstance
1090
 
PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name)
 
1096
PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name)
1091
1097
{
1092
 
    if (name && name[0])
 
1098
    if (name)
1093
1099
    {
1094
 
        llvm::StringRef name_sref(name);
1095
1100
        Mutex::Locker locker (GetObjectContainerMutex ());
1096
1101
        ObjectContainerInstances &instances = GetObjectContainerInstances ();
1097
1102
        
1098
1103
        ObjectContainerInstances::iterator pos, end = instances.end();
1099
1104
        for (pos = instances.begin(); pos != end; ++ pos)
1100
1105
        {
1101
 
            if (name_sref.equals (pos->name))
 
1106
            if (name == pos->name)
1102
1107
                return pos->create_callback;
1103
1108
        }
1104
1109
    }
1105
1110
    return NULL;
1106
1111
}
1107
1112
 
 
1113
ObjectFileGetModuleSpecifications
 
1114
PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
 
1115
{
 
1116
    Mutex::Locker locker (GetObjectContainerMutex ());
 
1117
    ObjectContainerInstances &instances = GetObjectContainerInstances ();
 
1118
    if (idx < instances.size())
 
1119
        return instances[idx].get_module_specifications;
 
1120
    return NULL;
 
1121
}
 
1122
 
1108
1123
#pragma mark LogChannel
1109
1124
 
1110
1125
struct LogInstance
1116
1131
    {
1117
1132
    }
1118
1133
 
1119
 
    std::string name;
 
1134
    ConstString name;
1120
1135
    std::string description;
1121
1136
    LogChannelCreateInstance create_callback;
1122
1137
};
1142
1157
bool
1143
1158
PluginManager::RegisterPlugin
1144
1159
(
1145
 
    const char *name,
 
1160
    const ConstString &name,
1146
1161
    const char *description,
1147
1162
    LogChannelCreateInstance create_callback
1148
1163
)
1150
1165
    if (create_callback)
1151
1166
    {
1152
1167
        LogInstance instance;
1153
 
        assert (name && name[0]);
 
1168
        assert ((bool)name);
1154
1169
        instance.name = name;
1155
1170
        if (description && description[0])
1156
1171
            instance.description = description;
1188
1203
    Mutex::Locker locker (GetLogMutex ());
1189
1204
    LogInstances &instances = GetLogInstances ();
1190
1205
    if (idx < instances.size())
1191
 
        return instances[idx].name.c_str();
 
1206
        return instances[idx].name.GetCString();
1192
1207
    return NULL;
1193
1208
}
1194
1209
 
1204
1219
}
1205
1220
 
1206
1221
LogChannelCreateInstance
1207
 
PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name)
 
1222
PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name)
1208
1223
{
1209
 
    if (name && name[0])
 
1224
    if (name)
1210
1225
    {
1211
 
        llvm::StringRef name_sref(name);
1212
1226
        Mutex::Locker locker (GetLogMutex ());
1213
1227
        LogInstances &instances = GetLogInstances ();
1214
1228
        
1215
1229
        LogInstances::iterator pos, end = instances.end();
1216
1230
        for (pos = instances.begin(); pos != end; ++ pos)
1217
1231
        {
1218
 
            if (name_sref.equals (pos->name))
 
1232
            if (name == pos->name)
1219
1233
                return pos->create_callback;
1220
1234
        }
1221
1235
    }
1234
1248
    {
1235
1249
    }
1236
1250
    
1237
 
    std::string name;
 
1251
    ConstString name;
1238
1252
    std::string description;
1239
1253
    PlatformCreateInstance create_callback;
1240
1254
    DebuggerInitializeCallback debugger_init_callback;
1258
1272
 
1259
1273
 
1260
1274
bool
1261
 
PluginManager::RegisterPlugin (const char *name,
 
1275
PluginManager::RegisterPlugin (const ConstString &name,
1262
1276
                               const char *description,
1263
1277
                               PlatformCreateInstance create_callback,
1264
1278
                               DebuggerInitializeCallback debugger_init_callback)
1268
1282
        Mutex::Locker locker (GetPlatformInstancesMutex ());
1269
1283
        
1270
1284
        PlatformInstance instance;
1271
 
        assert (name && name[0]);
 
1285
        assert ((bool)name);
1272
1286
        instance.name = name;
1273
1287
        if (description && description[0])
1274
1288
            instance.description = description;
1287
1301
    Mutex::Locker locker (GetPlatformInstancesMutex ());
1288
1302
    PlatformInstances &instances = GetPlatformInstances ();
1289
1303
    if (idx < instances.size())
1290
 
        return instances[idx].name.c_str();
 
1304
        return instances[idx].name.GetCString();
1291
1305
    return NULL;
1292
1306
}
1293
1307
 
1333
1347
}
1334
1348
 
1335
1349
PlatformCreateInstance
1336
 
PluginManager::GetPlatformCreateCallbackForPluginName (const char *name)
 
1350
PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name)
1337
1351
{
1338
 
    if (name && name[0])
 
1352
    if (name)
1339
1353
    {
1340
1354
        Mutex::Locker locker (GetPlatformInstancesMutex ());
1341
1355
        PlatformInstances &instances = GetPlatformInstances ();
1342
 
        llvm::StringRef name_sref(name);
1343
1356
 
1344
1357
        PlatformInstances::iterator pos, end = instances.end();
1345
1358
        for (pos = instances.begin(); pos != end; ++ pos)
1346
1359
        {
1347
 
            if (name_sref.equals (pos->name))
 
1360
            if (name == pos->name)
1348
1361
                return pos->create_callback;
1349
1362
        }
1350
1363
    }
1354
1367
size_t
1355
1368
PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
1356
1369
{
1357
 
    if (name && name[0])
 
1370
    if (name)
1358
1371
    {
1359
1372
        Mutex::Locker locker (GetPlatformInstancesMutex ());
1360
1373
        PlatformInstances &instances = GetPlatformInstances ();
1363
1376
        PlatformInstances::iterator pos, end = instances.end();
1364
1377
        for (pos = instances.begin(); pos != end; ++ pos)
1365
1378
        {
1366
 
            llvm::StringRef plugin_name (pos->name);
 
1379
            llvm::StringRef plugin_name (pos->name.GetCString());
1367
1380
            if (plugin_name.startswith(name_sref))
1368
1381
                matches.AppendString (plugin_name.data());
1369
1382
        }
1381
1394
    {
1382
1395
    }
1383
1396
    
1384
 
    std::string name;
 
1397
    ConstString name;
1385
1398
    std::string description;
1386
1399
    ProcessCreateInstance create_callback;
1387
1400
};
1406
1419
bool
1407
1420
PluginManager::RegisterPlugin
1408
1421
(
1409
 
 const char *name,
 
1422
 const ConstString &name,
1410
1423
 const char *description,
1411
1424
 ProcessCreateInstance create_callback
1412
1425
 )
1414
1427
    if (create_callback)
1415
1428
    {
1416
1429
        ProcessInstance instance;
1417
 
        assert (name && name[0]);
 
1430
        assert ((bool)name);
1418
1431
        instance.name = name;
1419
1432
        if (description && description[0])
1420
1433
            instance.description = description;
1431
1444
    Mutex::Locker locker (GetProcessMutex ());
1432
1445
    ProcessInstances &instances = GetProcessInstances ();
1433
1446
    if (idx < instances.size())
1434
 
        return instances[idx].name.c_str();
 
1447
        return instances[idx].name.GetCString();
1435
1448
    return NULL;
1436
1449
}
1437
1450
 
1478
1491
 
1479
1492
 
1480
1493
ProcessCreateInstance
1481
 
PluginManager::GetProcessCreateCallbackForPluginName (const char *name)
 
1494
PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
1482
1495
{
1483
 
    if (name && name[0])
 
1496
    if (name)
1484
1497
    {
1485
 
        llvm::StringRef name_sref(name);
1486
1498
        Mutex::Locker locker (GetProcessMutex ());
1487
1499
        ProcessInstances &instances = GetProcessInstances ();
1488
1500
        
1489
1501
        ProcessInstances::iterator pos, end = instances.end();
1490
1502
        for (pos = instances.begin(); pos != end; ++ pos)
1491
1503
        {
1492
 
            if (name_sref.equals (pos->name))
 
1504
            if (name == pos->name)
1493
1505
                return pos->create_callback;
1494
1506
        }
1495
1507
    }
1507
1519
    {
1508
1520
    }
1509
1521
 
1510
 
    std::string name;
 
1522
    ConstString name;
1511
1523
    std::string description;
1512
1524
    SymbolFileCreateInstance create_callback;
1513
1525
};
1532
1544
bool
1533
1545
PluginManager::RegisterPlugin
1534
1546
(
1535
 
    const char *name,
 
1547
    const ConstString &name,
1536
1548
    const char *description,
1537
1549
    SymbolFileCreateInstance create_callback
1538
1550
)
1540
1552
    if (create_callback)
1541
1553
    {
1542
1554
        SymbolFileInstance instance;
1543
 
        assert (name && name[0]);
 
1555
        assert ((bool)name);
1544
1556
        instance.name = name;
1545
1557
        if (description && description[0])
1546
1558
            instance.description = description;
1583
1595
}
1584
1596
 
1585
1597
SymbolFileCreateInstance
1586
 
PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name)
 
1598
PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name)
1587
1599
{
1588
 
    if (name && name[0])
 
1600
    if (name)
1589
1601
    {
1590
 
        llvm::StringRef name_sref(name);
1591
1602
        Mutex::Locker locker (GetSymbolFileMutex ());
1592
1603
        SymbolFileInstances &instances = GetSymbolFileInstances ();
1593
1604
        
1594
1605
        SymbolFileInstances::iterator pos, end = instances.end();
1595
1606
        for (pos = instances.begin(); pos != end; ++ pos)
1596
1607
        {
1597
 
            if (name_sref.equals (pos->name))
 
1608
            if (name == pos->name)
1598
1609
                return pos->create_callback;
1599
1610
        }
1600
1611
    }
1614
1625
    {
1615
1626
    }
1616
1627
 
1617
 
    std::string name;
 
1628
    ConstString name;
1618
1629
    std::string description;
1619
1630
    SymbolVendorCreateInstance create_callback;
1620
1631
};
1638
1649
bool
1639
1650
PluginManager::RegisterPlugin
1640
1651
(
1641
 
    const char *name,
 
1652
    const ConstString &name,
1642
1653
    const char *description,
1643
1654
    SymbolVendorCreateInstance create_callback
1644
1655
)
1646
1657
    if (create_callback)
1647
1658
    {
1648
1659
        SymbolVendorInstance instance;
1649
 
        assert (name && name[0]);
 
1660
        assert ((bool)name);
1650
1661
        instance.name = name;
1651
1662
        if (description && description[0])
1652
1663
            instance.description = description;
1690
1701
 
1691
1702
 
1692
1703
SymbolVendorCreateInstance
1693
 
PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name)
 
1704
PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name)
1694
1705
{
1695
 
    if (name && name[0])
 
1706
    if (name)
1696
1707
    {
1697
 
        llvm::StringRef name_sref(name);
1698
1708
        Mutex::Locker locker (GetSymbolVendorMutex ());
1699
1709
        SymbolVendorInstances &instances = GetSymbolVendorInstances ();
1700
1710
        
1701
1711
        SymbolVendorInstances::iterator pos, end = instances.end();
1702
1712
        for (pos = instances.begin(); pos != end; ++ pos)
1703
1713
        {
1704
 
            if (name_sref.equals (pos->name))
 
1714
            if (name == pos->name)
1705
1715
                return pos->create_callback;
1706
1716
        }
1707
1717
    }
1720
1730
    {
1721
1731
    }
1722
1732
 
1723
 
    std::string name;
 
1733
    ConstString name;
1724
1734
    std::string description;
1725
1735
    UnwindAssemblyCreateInstance create_callback;
1726
1736
};
1744
1754
bool
1745
1755
PluginManager::RegisterPlugin
1746
1756
(
1747
 
    const char *name,
 
1757
    const ConstString &name,
1748
1758
    const char *description,
1749
1759
    UnwindAssemblyCreateInstance create_callback
1750
1760
)
1752
1762
    if (create_callback)
1753
1763
    {
1754
1764
        UnwindAssemblyInstance instance;
1755
 
        assert (name && name[0]);
 
1765
        assert ((bool)name);
1756
1766
        instance.name = name;
1757
1767
        if (description && description[0])
1758
1768
            instance.description = description;
1796
1806
 
1797
1807
 
1798
1808
UnwindAssemblyCreateInstance
1799
 
PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name)
 
1809
PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name)
1800
1810
{
1801
 
    if (name && name[0])
 
1811
    if (name)
1802
1812
    {
1803
 
        llvm::StringRef name_sref(name);
1804
1813
        Mutex::Locker locker (GetUnwindAssemblyMutex ());
1805
1814
        UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
1806
1815
        
1807
1816
        UnwindAssemblyInstances::iterator pos, end = instances.end();
1808
1817
        for (pos = instances.begin(); pos != end; ++ pos)
1809
1818
        {
1810
 
            if (name_sref.equals (pos->name))
 
1819
            if (name == pos->name)
1811
1820
                return pos->create_callback;
1812
1821
        }
1813
1822
    }