Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill simgrid::xbt::cmdline and simgrid::xbt::binary_name
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 21 Feb 2023 14:53:00 +0000 (15:53 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 21 Feb 2023 14:53:00 +0000 (15:53 +0100)
ChangeLog
include/simgrid/Exception.hpp
include/simgrid/s4u/Engine.hpp
include/simgrid/version.h.in
include/xbt/ex.h
include/xbt/virtu.h
src/instr/instr_paje_header.cpp
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/s4u/s4u_Engine.cpp
src/smpi/internals/smpi_memory.cpp

index 73cd894..0d62c29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -44,6 +44,10 @@ Models:
 sthread:
  - Implement pthread_join in MC mode.
 
+XBT:
+ - simgrid::xbt::cmdline and simgrid::xbt::binary_name are gone.
+   Please use simgrid::s4u::Engine::get_cmdline() instead.
+
 Documentation:
  - New section in the user guide on the provided performance models.
  - New section presenting some technical good practices for (potential) contributors.
index f4d151f..66dd7a5 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef SIMGRID_EXCEPTIONS_HPP
 #define SIMGRID_EXCEPTIONS_HPP
 
+#include <simgrid/actor.h>
 #include <xbt/backtrace.hpp>
 #include <xbt/ex.h>
 #include <xbt/string.hpp>
index 94b0202..0c37740 100644 (file)
@@ -56,6 +56,7 @@ public:
   static s4u::Engine* get_instance();
   static s4u::Engine* get_instance(int* argc, char** argv);
   static bool has_instance() { return instance_ != nullptr; }
+  const std::vector<std::string>& get_cmdline() const;
 
   /**
    * Creates a new platform, including hosts, links, and the routing table.
index acd8644..daa8e9c 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef SIMGRID_VERSION_H
 #define SIMGRID_VERSION_H
 
+#include "xbt/base.h"
+
 #define SIMGRID_GIT_VERSION   "@GIT_VERSION@"
 
 /** Define the version numbers of the used header files.
index 83e90c3..f221afe 100644 (file)
@@ -11,7 +11,6 @@
 #include <xbt/base.h>
 #include <xbt/misc.h>
 #include <xbt/sysdep.h>
-#include <xbt/virtu.h>
 
 /** @addtogroup XBT_ex_c
  *  @brief Exceptions support (C)
index 136b305..0789a9a 100644 (file)
 #include <simgrid/actor.h>
 #include <xbt/base.h>
 
-#ifdef __cplusplus
-#include <string>
-#include <vector>
-
-namespace simgrid {
-namespace xbt {
-
-/* Get the name of the UNIX process englobing the world */
-XBT_PUBLIC_DATA std::string binary_name;
-/** Contains all the parameters we got from the command line (including argv[0]) */
-XBT_PUBLIC_DATA std::vector<std::string> cmdline;
-
-} // namespace xbt
-} // namespace simgrid
+// avoid deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v337)
+#ifndef XBT_VIRTU_H_NO_DEPRECATED_WARNING
+#warning xbt/virtu.h is deprecated and will be removed in v3.37.
 #endif
 
 SG_BEGIN_DECL
 
 XBT_ATTRIB_DEPRECATED_v337("Please use sg_actor_self_get_name()") static const char* xbt_procname(void)
 {
-  return sg_actor_self_get_name() ?: "maestro";
+  return sg_actor_self_get_name();
 }
 
 XBT_ATTRIB_DEPRECATED_v337("Please use sg_actor_self_get_pid()") static int xbt_getpid(void)
index 487f605..d69e4dd 100644 (file)
@@ -1,14 +1,13 @@
-/* Copyright (c) 2010-2023. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "simgrid/Exception.hpp"
 #include "simgrid/version.h"
 #include "src/instr/instr_private.hpp"
 #include "src/smpi/include/private.hpp"
-#include "xbt/virtu.h" /* xbt::cmdline */
+#include <simgrid/Exception.hpp>
+#include <simgrid/s4u/Engine.hpp>
 
 extern std::ofstream tracing_file;
 namespace simgrid::instr::paje {
@@ -18,7 +17,7 @@ void dump_generator_version()
   tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
                << "." << SIMGRID_VERSION_PATCH << '\n';
   tracing_file << "#[";
-  for (auto const& str : simgrid::xbt::cmdline) {
+  for (auto const& str : simgrid::s4u::Engine::get_instance()->get_cmdline()) {
     tracing_file << str << " ";
   }
   tracing_file << "]\n";
index 025228a..518361d 100644 (file)
@@ -193,10 +193,8 @@ void EngineImpl::initialize(int* argc, char** argv)
 
     simgrid::xbt::install_exception_handler();
 
-    if (*argc > 0)
-      simgrid::xbt::binary_name = argv[0];
     for (int i = 0; i < *argc; i++)
-      simgrid::xbt::cmdline.emplace_back(argv[i]);
+      cmdline_.emplace_back(argv[i]);
 
     sg_config_init(argc, argv);
   }
index 889f726..b84f543 100644 (file)
@@ -57,6 +57,7 @@ class EngineImpl {
   std::unique_ptr<void, std::function<int(void*)>> platf_handle_; //!< handle for platform library
   friend s4u::Engine;
 
+  std::vector<std::string> cmdline_; // Copy of the argv we got (including argv[0])
 public:
   EngineImpl() = default;
 
@@ -69,6 +70,10 @@ public:
 #endif
 
   void initialize(int* argc, char** argv);
+  const std::vector<std::string>& get_cmdline() const
+  {
+    return cmdline_;
+  }
   void load_platform(const std::string& platf);
   void load_deployment(const std::string& file) const;
   void seal_platform() const;
index 3ed3452..3d7c6cb 100644 (file)
@@ -81,6 +81,10 @@ Engine* Engine::get_instance(int* argc, char** argv)
   }
   return Engine::instance_;
 }
+const std::vector<std::string>& Engine::get_cmdline() const
+{
+  return pimpl->get_cmdline();
+}
 
 void Engine::shutdown() // XBT_ATTRIB_DEPRECATED_v335
 {
index d2d121e..fdfcb18 100644 (file)
@@ -5,9 +5,9 @@
 
 #include "private.hpp"
 #include "src/internal_config.h"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
 #include "src/xbt/memory_map.hpp"
-#include "xbt/virtu.h"
 
 #include <algorithm>
 #include <cerrno>
@@ -52,8 +52,9 @@ void smpi_prepare_global_memory_segment()
 
 static void smpi_get_executable_global_size()
 {
-  char* buffer = realpath(simgrid::xbt::binary_name.c_str(), nullptr);
-  xbt_assert(buffer != nullptr, "Could not resolve real path of binary file '%s'", simgrid::xbt::binary_name.c_str());
+  auto* binary_name = simgrid::kernel::EngineImpl::get_instance()->get_cmdline().front().c_str();
+  char* buffer      = realpath(binary_name, nullptr);
+  xbt_assert(buffer != nullptr, "Could not resolve real path of binary file '%s'", binary_name);
   std::string full_name = buffer;
   free(buffer);