Fix a bug about debug launch mode 75/315975/1
authorHwankyu Jhun <h.jhun@samsung.com>
Sun, 8 Dec 2024 23:30:02 +0000 (08:30 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Sun, 8 Dec 2024 23:30:02 +0000 (08:30 +0900)
The TIZEN_ASAN_ACTIVATION environment must be set if the target
application is included in the asan app list.

Change-Id: I3a24213e712ff914aeb59c6028ecff1044626aec
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/app_executor.cc
src/launchpad-process-pool/debug.cc
src/launchpad-process-pool/debug.hh
src/lib/launchpad-core/util.cc

index ec90b6a7ef0305383e73692a4a299f87e310a8ab..657584a9533cf3a93556f74f67582310e9826a28 100644 (file)
@@ -310,11 +310,13 @@ int AppExecutor::StepSendStartupSignal() {
 }
 
 void AppExecutor::CheckAndPrepareDebugging() {
+  auto& debug = Debug::GetInst();
   auto& b = app_info_->GetBundle();
   if (b.GetType(kAulSdk) != BUNDLE_TYPE_NONE)
-     Debug::GetInst().Prepare(b);
+     debug.Prepare(b);
 
-  Debug::GetInst().CheckWebAppDebugging(b);
+  debug.CheckAndSetAsanActivation(app_info_->GetAppId());
+  debug.CheckWebAppDebugging(b);
 }
 
 LauncherInfoPtr AppExecutor::FindLauncherInfo(const std::string& app_type) {
index f9e3a316f929a7857d7f26f5afad6700f6cf9bc6..ef6b7ae1c73790c80c587259c4b8cef1ebb93de7 100644 (file)
@@ -177,10 +177,6 @@ bool Debug::PrepareDebugger(const tizen_base::Bundle& b) {
                                            debugger_info_->GetExtraEnvList());
   }
 
-  auto appid = b.GetString(kAulAppId);
-  if (CheckAsanApp(appid))
-    const_cast<tizen_base::Bundle&>(b).Add(kAulTizenAsanActivation, "true");
-
   debug_argv_ = debugger_info_->GetDefaultOptList();
   if (!debugger_info_->GetExe().empty())
     debug_argv_.insert(debug_argv_.begin(), debugger_info_->GetExe());
@@ -198,6 +194,13 @@ bool Debug::CheckAsanApp(const std::string& appid) {
   return asan_app_map_.find(appid) != asan_app_map_.end();
 }
 
+void Debug::CheckAndSetAsanActivation(const std::string& appid) {
+  if (CheckAsanApp(appid)) {
+    _W("Set TIZEN_ASAN_ACTIVATION. appid: %s", appid.c_str());
+    setenv(kTizenAsanActivation, "1", 1);
+  }
+}
+
 std::vector<std::string> Debug::GetExtraArgv() const { return extra_argv_; }
 
 std::vector<std::string> Debug::GetArgv() const { return debug_argv_; }
@@ -285,8 +288,7 @@ void Debug::Prepare(const tizen_base::Bundle& request) {
   auto debugger = request.GetString(kAulSdk);
   if (debugger.empty()) return;
 
-  if (debugger == "ASAN" ||
-      request.GetString(kAulTizenAsanActivation) == "true")
+  if (debugger == "ASAN")
     setenv(kTizenAsanActivation, "1", 1);
 
   ParseAndRedirectStandardFds(request);
index fdf431815f6d88afa4bfebf6fe658795f7cc5cdf..e9412be6cc86904e7ffbfaa37461a7ed8539e562 100644 (file)
@@ -47,6 +47,7 @@ class Debug : public FileMonitor::IEvent {
   std::vector<std::string> GetArgv() const;
   bool ShouldAttach() const;
   bool CheckAsanApp(const std::string& appid);
+  void CheckAndSetAsanActivation(const std::string& appid);
   void Prepare(const tizen_base::Bundle& request);
   void ChangeMountNamespace();
   void CheckWebAppDebugging(const tizen_base::Bundle& request);
index e442f15cc3d010d62113e7baa8ebc0a593988560..728013493496d6d85b7581e254e2020022300226 100644 (file)
@@ -709,6 +709,7 @@ void Util::RemoveAulKeys(tizen_base::Bundle* b) {
   b->Delete(kAulMountLibDir);
   b->Delete(kAulMountGadgetPaths);
   b->Delete(kAulMountGadgetPkgIds);
+  b->Delete(kAulDebugExtraEnvList);
 }
 
 }  // namespace launchpad