Skip to content

Commit

Permalink
[Reproducer] Implement dumping packets.
Browse files Browse the repository at this point in the history
This patch completes the dump functionality by adding support for
dumping a reproducer's GDB remote packets.

Differential revision: https://reviews.llvm.org/D67636

llvm-svn: 372046
  • Loading branch information
JDevlieghere committed Sep 16, 2019
1 parent 3cabfb3 commit 8fc8d3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lldb/lit/Reproducer/TestDump.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
# COMMANDS: target create
# COMMANDS: command source

# RUN: %lldb -b -o 'reproducer dump -p gdb -f %t.repro' | FileCheck %s --check-prefix GDB
# GDB: send packet: $QStartNoAckMode#b0
# GDB: read packet: $OK#9a

# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix FILES
24 changes: 21 additions & 3 deletions lldb/source/Commands/CommandObjectReproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "lldb/Host/OptionParser.h"
#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/GDBRemote.h"

#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
Expand Down Expand Up @@ -310,9 +311,26 @@ class CommandObjectReproducerDump : public CommandObjectParsed {
return true;
}
case eReproducerProviderGDB: {
// FIXME: Dumping the GDB remote packets means moving the
// (de)serialization code out of the GDB-remote plugin.
result.AppendMessage("Dumping GDB remote packets isn't implemented yet.");
FileSpec gdb_file = loader->GetFile<ProcessGDBRemoteProvider::Info>();
auto error_or_file = MemoryBuffer::getFile(gdb_file.GetPath());
if (auto err = error_or_file.getError()) {
SetError(result, errorCodeToError(err));
return false;
}

std::vector<GDBRemotePacket> packets;
yaml::Input yin((*error_or_file)->getBuffer());
yin >> packets;

if (auto err = yin.error()) {
SetError(result, errorCodeToError(err));
return false;
}

for (GDBRemotePacket& packet : packets) {
packet.Dump(result.GetOutputStream());
}

result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
}
Expand Down

0 comments on commit 8fc8d3f

Please sign in to comment.