[llvm] fa90a0a - [llvm-exegesis] Improve error handling for shm_open calls
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 13:25:51 PDT 2024
Author: Aiden Grossman
Date: 2024-03-27T13:25:44-07:00
New Revision: fa90a0aa0e12aaf657d0f6f7626e05f90ba6f999
URL: https://github.com/llvm/llvm-project/commit/fa90a0aa0e12aaf657d0f6f7626e05f90ba6f999
DIFF: https://github.com/llvm/llvm-project/commit/fa90a0aa0e12aaf657d0f6f7626e05f90ba6f999.diff
LOG: [llvm-exegesis] Improve error handling for shm_open calls
This patch adds error handling for shm_open failures in one case where
they were not handled before and also makes an error handler in another
case report the value of errno for diagnosis.
Added:
Modified:
llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
index 1fd81bd407becb..0a947f6e206fef 100644
--- a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
@@ -63,6 +63,10 @@ Error SubprocessMemory::addMemoryDefinition(
SharedMemoryNames.push_back(SharedMemoryName);
int SharedMemoryFD =
shm_open(SharedMemoryName.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (SharedMemoryFD == -1)
+ return make_error<Failure>(
+ "Failed to create shared memory object for memory definition: " +
+ Twine(strerror(errno)));
if (ftruncate(SharedMemoryFD, MemVal.SizeBytes) != 0) {
return make_error<Failure>("Truncating a memory definiton failed: " +
Twine(strerror(errno)));
@@ -100,7 +104,8 @@ Expected<int> SubprocessMemory::setupAuxiliaryMemoryInSubprocess(
shm_open(AuxiliaryMemoryName.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
if (AuxiliaryMemoryFileDescriptor == -1)
return make_error<Failure>(
- "Getting file descriptor for auxiliary memory failed");
+ "Getting file descriptor for auxiliary memory failed: " +
+ Twine(strerror(errno)));
// set up memory value file descriptors
int *AuxiliaryMemoryMapping =
(int *)mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED,
More information about the llvm-commits
mailing list