Skip to content

Commit

Permalink
[lldb/Reproducers] Print more info for reproducer status
Browse files Browse the repository at this point in the history
Reproducer status now prints the capture/replay path. It will also print
the status of auto generation when enabled.
  • Loading branch information
JDevlieghere committed Jan 16, 2020
1 parent cc5efa2 commit 982a77b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lldb/include/lldb/Utility/Reproducer.h
Expand Up @@ -234,6 +234,9 @@ class Generator final {
/// Enable or disable auto generate.
void SetAutoGenerate(bool b);

/// Return whether auto generate is enabled.
bool IsAutoGenerate() const;

/// Create and register a new provider.
template <typename T> T *Create() {
std::unique_ptr<ProviderBase> provider = std::make_unique<T>(m_root);
Expand Down
12 changes: 12 additions & 0 deletions lldb/source/Commands/CommandObjectReproducer.cpp
Expand Up @@ -258,6 +258,18 @@ class CommandObjectReproducerStatus : public CommandObjectParsed {
result.GetOutputStream() << "Reproducer is off.\n";
}

if (r.IsCapturing() || r.IsReplaying()) {
result.GetOutputStream()
<< "Path: " << r.GetReproducerPath().GetPath() << '\n';
}

// Auto generate is hidden unless enabled because this is mostly for
// development and testing.
if (Generator *g = r.GetGenerator()) {
if (g->IsAutoGenerate())
result.GetOutputStream() << "Auto generate: on\n";
}

result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Utility/Reproducer.cpp
Expand Up @@ -205,6 +205,8 @@ void Generator::Discard() {

void Generator::SetAutoGenerate(bool b) { m_auto_generate = b; }

bool Generator::IsAutoGenerate() const { return m_auto_generate; }

const FileSpec &Generator::GetRoot() const { return m_root; }

void Generator::AddProvidersToIndex() {
Expand Down
6 changes: 4 additions & 2 deletions lldb/test/Shell/Reproducer/TestDriverOptions.test
Expand Up @@ -10,15 +10,17 @@
#
# RUN: %lldb --capture --capture-path %t.repro -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
# RUN: %lldb --capture -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING --check-prefix STATUS-CAPTURE
# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE
# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix WARNING --check-prefix STATUS-CAPTURE --check-prefix NOAUTOGEN
# RUN: %lldb --capture-path %t.repro -b -o 'reproducer status' --reproducer-auto-generate 2>&1 | FileCheck %s --check-prefix WARNING2
#
# NO-WARNING-NOT: warning: -capture-path specified without -capture
# WARNING: warning: -capture-path specified without -capture
# WARNING2: warning: -reproducer-auto-generate specified without -capture
# STATUS-CAPTURE: Reproducer is in capture mode.
# NOAUTOGEN-NOT: Auto generate

# Check auto generate.
# RUN: rm -rf %t.repro
# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING
# RUN: %lldb --capture --capture-path %t.repro -b --reproducer-auto-generate -o 'reproducer status' 2>&1 | FileCheck %s --check-prefix NO-WARNING --check-prefix AUTOGEN
# RUN: cat %t.repro/index.yaml
# AUTOGEN: Auto generate: on

0 comments on commit 982a77b

Please sign in to comment.