Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: src/tools/linux/dump_syms/dump_syms.cc

Issue 1437763002: dump_syms: add a -v flag (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: address mark's comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tools/linux/dump_syms/dump_syms.cc
diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc
index c8ade33a404d7f171b53779a055c8476594429dd..c51ae8cde4fa58fc78c188a8e85e80cbd8ab052b 100644
--- a/src/tools/linux/dump_syms/dump_syms.cc
+++ b/src/tools/linux/dump_syms/dump_syms.cc
@@ -27,7 +27,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <paths.h>
#include <stdio.h>
+#include <unistd.h>
#include <cstring>
#include <iostream>
@@ -44,6 +46,7 @@ int usage(const char* self) {
fprintf(stderr, "Options:\n");
fprintf(stderr, " -c Do not generate CFI section\n");
fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
+ fprintf(stderr, " -v Print all warnings to stderr\n");
return 1;
}
@@ -53,6 +56,7 @@ int main(int argc, char **argv) {
bool cfi = true;
bool handle_inter_cu_refs = true;
+ bool log_to_stderr = false;
int arg_index = 1;
while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
argv[arg_index][0] == '-') {
@@ -60,6 +64,8 @@ int main(int argc, char **argv) {
cfi = false;
} else if (strcmp("-r", argv[arg_index]) == 0) {
handle_inter_cu_refs = false;
+ } else if (strcmp("-v", argv[arg_index]) == 0) {
+ log_to_stderr = true;
} else {
return usage(argv[0]);
}
@@ -68,6 +74,15 @@ int main(int argc, char **argv) {
if (arg_index == argc)
return usage(argv[0]);
+ // Save stderr so it can be used below.
+ FILE* saved_stderr = fdopen(dup(fileno(stderr)), "w");
+ if (!log_to_stderr) {
+ if (freopen(_PATH_DEVNULL, "w", stderr)) {
+ // If it fails, not a lot we can (or should) do.
+ // Add this brace section to silence gcc warnings.
+ }
+ }
+
const char* binary;
std::vector<string> debug_dirs;
binary = argv[arg_index];
@@ -80,7 +95,7 @@ int main(int argc, char **argv) {
SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
- fprintf(stderr, "Failed to write symbol file.\n");
+ fprintf(saved_stderr, "Failed to write symbol file.\n");
return 1;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698