aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2019-02-21 16:12:40 -0500
committerGitHub <noreply@github.com>2019-02-21 16:12:40 -0500
commit4c4ad39c0dca8621c6f8c00a9402b28cc760306c (patch)
treeed43472e904232b5f1524a7e2822c69f5a7c0502 /samples
parent585cb72d9bf34b038ba82e39284d96f0bf6f2c42 (diff)
downloadamber-4c4ad39c0dca8621c6f8c00a9402b28cc760306c.tar.gz
Output requested images/buffers on probe failure. (#316)
This Cl updates the sample app to allow dumping of image and buffer data even if the probes fail to execute. Fixes #314.
Diffstat (limited to 'samples')
-rw-r--r--samples/amber.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/samples/amber.cc b/samples/amber.cc
index 9bfa950..7f27d00 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -339,7 +339,8 @@ int main(int argc, const char** argv) {
if (!result.IsSuccess()) {
std::cerr << file << ": " << result.Error() << std::endl;
failures.push_back(file);
- continue;
+ // Note, we continue after failure to allow dumping the buffers which may
+ // give clues as to the failure.
}
if (!options.image_filename.empty()) {
@@ -360,19 +361,20 @@ int main(int argc, const char** argv) {
break;
}
}
- if (!result.IsSuccess()) {
+ if (result.IsSuccess()) {
+ std::ofstream image_file;
+ image_file.open(options.image_filename,
+ std::ios::out | std::ios::binary);
+ if (!image_file.is_open()) {
+ std::cerr << "Cannot open file for image dump: ";
+ std::cerr << options.image_filename << std::endl;
+ continue;
+ }
+ image_file << image;
+ image_file.close();
+ } else {
std::cerr << result.Error() << std::endl;
- continue;
- }
- std::ofstream image_file;
- image_file.open(options.image_filename, std::ios::out | std::ios::binary);
- if (!image_file.is_open()) {
- std::cerr << "Cannot open file for image dump: ";
- std::cerr << options.image_filename << std::endl;
- continue;
}
- image_file << image;
- image_file.close();
}
if (!options.buffer_filename.empty()) {