Skip to content

Commit

Permalink
[dsymutil] Keep DSYMUTIL_REPRODUCER_PATH in addition to LLVM_DIAGNOST…
Browse files Browse the repository at this point in the history
…IC_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.
  • Loading branch information
JDevlieghere committed Oct 10, 2023
1 parent 3a6cc52 commit bd206a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions llvm/test/tools/dsymutil/X86/reproducer.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions llvm/tools/dsymutil/Reproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit bd206a3

Please sign in to comment.