@@ -556,6 +556,25 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
556556 else if (std::strcmp (argv[i], " --debug-lookup" ) == 0 )
557557 mSettings .debuglookup = true ;
558558
559+ else if (std::strncmp (argv[i], " --debug-lookup=" , 15 ) == 0 ) {
560+ const std::string lookup = argv[i] + 15 ;
561+ if (lookup == " all" )
562+ mSettings .debuglookup = true ;
563+ else if (lookup == " addon" )
564+ mSettings .debuglookupAddon = true ;
565+ else if (lookup == " config" )
566+ mSettings .debuglookupConfig = true ;
567+ else if (lookup == " library" )
568+ mSettings .debuglookupLibrary = true ;
569+ else if (lookup == " platform" )
570+ mSettings .debuglookupPlatform = true ;
571+ else
572+ {
573+ mLogger .printError (" unknown lookup '" + lookup + " '" );
574+ return Result::Fail;
575+ }
576+ }
577+
559578 // Flag used for various purposes during debugging
560579 else if (std::strcmp (argv[i], " --debug-simplified" ) == 0 )
561580 mSettings .debugSimplified = true ;
@@ -928,7 +947,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
928947
929948 std::string errstr;
930949 const std::vector<std::string> paths = {argv[0 ]};
931- if (!mSettings .platform .set (platform, errstr, paths)) {
950+ if (!mSettings .platform .set (platform, errstr, paths, mSettings . debuglookup || mSettings . debuglookupPlatform )) {
932951 mLogger .printError (errstr);
933952 return Result::Fail;
934953 }
@@ -1022,7 +1041,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10221041 if (!platform.empty ()) {
10231042 std::string errstr;
10241043 const std::vector<std::string> paths = {projectFile, argv[0 ]};
1025- if (!mSettings .platform .set (platform, errstr, paths)) {
1044+ if (!mSettings .platform .set (platform, errstr, paths, mSettings . debuglookup || mSettings . debuglookupPlatform )) {
10261045 mLogger .printError (errstr);
10271046 return Result::Fail;
10281047 }
@@ -1820,7 +1839,7 @@ std::string CmdLineParser::getVersion() const {
18201839
18211840bool CmdLineParser::isCppcheckPremium () const {
18221841 if (mSettings .cppcheckCfgProductName .empty ())
1823- Settings::loadCppcheckCfg (mSettings , mSettings .supprs );
1842+ Settings::loadCppcheckCfg (mSettings , mSettings .supprs , mSettings . debuglookup || mSettings . debuglookupConfig );
18241843 return startsWith (mSettings .cppcheckCfgProductName , " Cppcheck Premium" );
18251844}
18261845
@@ -1873,7 +1892,7 @@ bool CmdLineParser::tryLoadLibrary(Library& destination, const std::string& base
18731892
18741893bool CmdLineParser::loadLibraries (Settings& settings)
18751894{
1876- if (!tryLoadLibrary (settings.library , settings.exename , " std.cfg" , settings.debuglookup )) {
1895+ if (!tryLoadLibrary (settings.library , settings.exename , " std.cfg" , settings.debuglookup || settings. debuglookupLibrary )) {
18771896 const std::string msg (" Failed to load std.cfg. Your Cppcheck installation is broken, please re-install." );
18781897#ifdef FILESDIR
18791898 const std::string details (" The Cppcheck binary was compiled with FILESDIR set to \" "
@@ -1891,7 +1910,7 @@ bool CmdLineParser::loadLibraries(Settings& settings)
18911910
18921911 bool result = true ;
18931912 for (const auto & lib : settings.libraries ) {
1894- if (!tryLoadLibrary (settings.library , settings.exename , lib.c_str (), settings.debuglookup )) {
1913+ if (!tryLoadLibrary (settings.library , settings.exename , lib.c_str (), settings.debuglookup || settings. debuglookupLibrary )) {
18951914 result = false ;
18961915 }
18971916 }
@@ -1903,7 +1922,7 @@ bool CmdLineParser::loadAddons(Settings& settings)
19031922 bool result = true ;
19041923 for (const std::string &addon: settings.addons ) {
19051924 AddonInfo addonInfo;
1906- const std::string failedToGetAddonInfo = addonInfo.getAddonInfo (addon, settings.exename );
1925+ const std::string failedToGetAddonInfo = addonInfo.getAddonInfo (addon, settings.exename , settings. debuglookup || settings. debuglookupAddon );
19071926 if (!failedToGetAddonInfo.empty ()) {
19081927 mLogger .printRaw (failedToGetAddonInfo); // TODO: do not print as raw
19091928 result = false ;
@@ -1916,7 +1935,7 @@ bool CmdLineParser::loadAddons(Settings& settings)
19161935
19171936bool CmdLineParser::loadCppcheckCfg ()
19181937{
1919- const std::string cfgErr = Settings::loadCppcheckCfg (mSettings , mSuppressions );
1938+ const std::string cfgErr = Settings::loadCppcheckCfg (mSettings , mSuppressions , mSettings . debuglookup || mSettings . debuglookupConfig );
19201939 if (!cfgErr.empty ()) {
19211940 mLogger .printError (" could not load cppcheck.cfg - " + cfgErr);
19221941 return false ;
0 commit comments