+ /* Do not intercept the main when run from SMPI: it will initialize the simulation properly */
+ for (int i = 0; envp[i] != nullptr; i++)
+ if (std::string_view(envp[i]).rfind("SMPI_GLOBAL_SIZE", 0) == 0) {
+ printf("sthread refuses to intercept the SMPI application %s directly, as its interception is done otherwise.\n",
+ argv[0]);
+ return raw_main(argc, argv, envp);
+ }
+
+ /* Do not intercept system binaries such as valgrind step 1 */
+ std::vector<std::string> binaries = {"/usr/bin/valgrind.bin", "/bin/sh", "/bin/bash", "gdb", "addr2line"};
+ for (int i = 0; envp[i] != nullptr; i++) {
+ auto view = std::string_view(envp[i]);
+ /* If you want to ignore more than one binary, export STHREAD_IGNORE_BINARY1=toto STHREAD_IGNORE_BINARY2=tutu */
+ /* Note that this cannot be configured with --cfg because we are before the main() */
+ if (view.rfind("STHREAD_IGNORE_BINARY", 0) == 0) {
+ view.remove_prefix(std::min(view.rfind("=") + 1, view.size()));
+ binaries.push_back(std::string(view));
+ }
+ }
+ auto binary_view = std::string_view(argv[0]);
+ for (auto binary : binaries) {
+ if (binary_view.rfind(binary) != std::string_view::npos) {
+ printf("sthread refuses to intercept the execution of %s. Running the application unmodified.\n", argv[0]);
+ fflush(stdout);
+ return raw_main(argc, argv, envp);
+ }
+ }