[dsymutil] Keep DSYMUTIL_REPRODUCER_PATH in addition to LLVM_DIAGNOSTIC_DIR

For LLVM_DIAGNOSTIC_DIR we want to create a subdirectory while for
DSYMUTIL_REPRODUCER_PATH we want to use the directory specified. The
latter makes writing a test a whole lot easier. Keep both to support
both scenarios.
This commit is contained in:
Jonas Devlieghere 2023-10-10 15:42:39 -07:00
parent 3a6cc52fe3
commit bd206a363a
No known key found for this signature in database
GPG Key ID: 49CC0BD90FDEED4D
2 changed files with 14 additions and 4 deletions

View File

@ -21,9 +21,14 @@ RUN: env TMPDIR="%t/tempdir" dsymutil -o - -f %t/Inputs/basic.macho.x86_64
RUN: not ls %t/tempdir/dsymutil-*
# Create a reproducer.
RUN: env LLVM_DIAGNOSTIC_DIR=%t.repro dsymutil -gen-reproducer -f -o %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefixes=REPRODUCER
RUN: rm -rf %t.repro
RUN: env DSYMUTIL_REPRODUCER_PATH=%t.repro dsymutil -gen-reproducer -f -o %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefixes=REPRODUCER
RUN: llvm-dwarfdump -a %t.generate | FileCheck %s
RUN: rm -rf %t.diags
RUN: env LLVM_DIAGNOSTIC_DIR=%t.diags dsymutil -gen-reproducer -f -o %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefixes=REPRODUCER
RUN: ls %t.diags | grep 'dsymutil-' | count 1
# Remove the input files and verify that was successful.
RUN: rm -rf %t
RUN: not dsymutil -f -o %t.error -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=ERROR
@ -32,7 +37,6 @@ RUN: not dsymutil --linker llvm -f -o %t.error -oso-prepend-path=%t %t/Inputs/ba
# Use the reproducer.
RUN: dsymutil -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s
RUN: dsymutil --linker llvm -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s
# Using a reproducer takes precedence.

View File

@ -8,15 +8,21 @@
#include "Reproducer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
using namespace llvm;
using namespace llvm::dsymutil;
static std::string createReproducerDir(std::error_code &EC) {
SmallString<128> Root;
if (const char *Path = getenv("LLVM_DIAGNOSTIC_DIR")) {
if (const char *Path = getenv("DSYMUTIL_REPRODUCER_PATH")) {
Root.assign(Path);
EC = sys::fs::create_directory(Root);
EC = sys::fs::create_directories(Root);
} else if (const char *Path = getenv("LLVM_DIAGNOSTIC_DIR")) {
Root.assign(Path);
llvm::sys::path::append(
Root, "dsymutil-" + llvm::Twine(llvm::sys::Process::getProcessId()));
EC = sys::fs::create_directories(Root);
} else {
EC = sys::fs::createUniqueDirectory("dsymutil", Root);
}