Skip to content

[lldb] Move GetEnvironment function into common code #122173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Jan 8, 2025

No description provided.

@brad0 brad0 requested a review from labath January 8, 2025 21:26
@brad0 brad0 requested a review from JDevlieghere as a code owner January 8, 2025 21:26
@llvmbot llvmbot added the lldb label Jan 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/122173.diff

5 Files Affected:

  • (modified) lldb/source/Host/common/Host.cpp (+6)
  • (modified) lldb/source/Host/freebsd/Host.cpp (-6)
  • (modified) lldb/source/Host/linux/Host.cpp (-2)
  • (modified) lldb/source/Host/netbsd/HostNetBSD.cpp (-6)
  • (modified) lldb/source/Host/openbsd/Host.cpp (-6)
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 03ea2f242d3c78..01749f4919de56 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -114,6 +114,12 @@ void LogChannelSystem::Initialize() {
 void LogChannelSystem::Terminate() { g_system_log.Disable(); }
 
 #if !defined(__APPLE__) && !defined(_WIN32)
+extern "C" {
+extern char **environ;
+}
+
+Environment Host::GetEnvironment() { return Environment(environ); }
+
 static thread_result_t
 MonitorChildProcessThreadFunction(::pid_t pid,
                                   Host::MonitorChildProcessCallback callback);
diff --git a/lldb/source/Host/freebsd/Host.cpp b/lldb/source/Host/freebsd/Host.cpp
index 89ebe714f095f8..14c0e9f2209d24 100644
--- a/lldb/source/Host/freebsd/Host.cpp
+++ b/lldb/source/Host/freebsd/Host.cpp
@@ -33,10 +33,6 @@
 
 #include "llvm/TargetParser/Host.h"
 
-extern "C" {
-extern char **environ;
-}
-
 namespace lldb_private {
 class ProcessLaunchInfo;
 }
@@ -241,8 +237,6 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
   return false;
 }
 
-Environment Host::GetEnvironment() { return Environment(environ); }
-
 Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
   return Status::FromErrorString("unimplemented");
 }
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index f5ec2e187af196..25bef9b0e7151b 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -411,8 +411,6 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
   return GetProcessAndStatInfo(pid, process_info, State, tracerpid);
 }
 
-Environment Host::GetEnvironment() { return Environment(environ); }
-
 Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
   return Status::FromErrorString("unimplemented");
 }
diff --git a/lldb/source/Host/netbsd/HostNetBSD.cpp b/lldb/source/Host/netbsd/HostNetBSD.cpp
index 49ff342fe152f6..8904df5eba03eb 100644
--- a/lldb/source/Host/netbsd/HostNetBSD.cpp
+++ b/lldb/source/Host/netbsd/HostNetBSD.cpp
@@ -35,10 +35,6 @@
 #include "llvm/Object/ELF.h"
 #include "llvm/TargetParser/Host.h"
 
-extern "C" {
-extern char **environ;
-}
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -46,8 +42,6 @@ namespace lldb_private {
 class ProcessLaunchInfo;
 }
 
-Environment Host::GetEnvironment() { return Environment(environ); }
-
 static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
                                  ProcessInstanceInfo &process_info) {
   if (!process_info.ProcessIDIsValid())
diff --git a/lldb/source/Host/openbsd/Host.cpp b/lldb/source/Host/openbsd/Host.cpp
index 24650ff97075ea..2b66a3c8696b10 100644
--- a/lldb/source/Host/openbsd/Host.cpp
+++ b/lldb/source/Host/openbsd/Host.cpp
@@ -30,10 +30,6 @@
 
 #include "llvm/TargetParser/Host.h"
 
-extern "C" {
-extern char **environ;
-}
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -41,8 +37,6 @@ namespace lldb_private {
 class ProcessLaunchInfo;
 }
 
-Environment Host::GetEnvironment() { return Environment(environ); }
-
 static bool
 GetOpenBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
                       ProcessInstanceInfo &process_info) {

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@brad0 brad0 force-pushed the lldb_environment branch from 43784f2 to d6663bd Compare January 9, 2025 14:23
@brad0 brad0 merged commit cb04bc0 into llvm:main Jan 9, 2025
5 of 6 checks passed
@brad0 brad0 deleted the lldb_environment branch January 9, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants