dump_syms: add a -v flag
dump_syms generates a lot of warnings. This CL puts logging behind a command line flag URL=https://android-review.googlesource.com/181558 BUG=b:25460551 BUG=google-breakpad:441 R=mark@chromium.org Review URL: https://codereview.chromium.org/1437763002 .
This commit is contained in:
parent
f217ae431f
commit
dc16e41747
1 changed files with 16 additions and 1 deletions
|
@ -27,7 +27,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include <paths.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -44,6 +46,7 @@ int usage(const char* self) {
|
||||||
fprintf(stderr, "Options:\n");
|
fprintf(stderr, "Options:\n");
|
||||||
fprintf(stderr, " -c Do not generate CFI section\n");
|
fprintf(stderr, " -c Do not generate CFI section\n");
|
||||||
fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
|
fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
|
||||||
|
fprintf(stderr, " -v Print all warnings to stderr\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
bool cfi = true;
|
bool cfi = true;
|
||||||
bool handle_inter_cu_refs = true;
|
bool handle_inter_cu_refs = true;
|
||||||
|
bool log_to_stderr = false;
|
||||||
int arg_index = 1;
|
int arg_index = 1;
|
||||||
while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
|
while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
|
||||||
argv[arg_index][0] == '-') {
|
argv[arg_index][0] == '-') {
|
||||||
|
@ -60,6 +64,8 @@ int main(int argc, char **argv) {
|
||||||
cfi = false;
|
cfi = false;
|
||||||
} else if (strcmp("-r", argv[arg_index]) == 0) {
|
} else if (strcmp("-r", argv[arg_index]) == 0) {
|
||||||
handle_inter_cu_refs = false;
|
handle_inter_cu_refs = false;
|
||||||
|
} else if (strcmp("-v", argv[arg_index]) == 0) {
|
||||||
|
log_to_stderr = true;
|
||||||
} else {
|
} else {
|
||||||
return usage(argv[0]);
|
return usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +74,15 @@ int main(int argc, char **argv) {
|
||||||
if (arg_index == argc)
|
if (arg_index == argc)
|
||||||
return usage(argv[0]);
|
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;
|
const char* binary;
|
||||||
std::vector<string> debug_dirs;
|
std::vector<string> debug_dirs;
|
||||||
binary = argv[arg_index];
|
binary = argv[arg_index];
|
||||||
|
@ -80,7 +95,7 @@ int main(int argc, char **argv) {
|
||||||
SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
|
SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
|
||||||
google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
|
google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
|
||||||
if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue