citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 8172e1b82d397f945be4450530ab853cc46eb533
parent e1ab4fe0bc055483f50409987107226776b3438c
Author: Kyle Milz <kyle@0x30.net>
Date:   Sat, 13 Aug 2016 03:55:28 -0600

src: break out link check into function

Diffstat:
Msrc/inst_main.cc | 27++++++++++++++++-----------
Msrc/inst_main.h | 1+
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -209,6 +209,21 @@ CitrunInst::save_if_srcfile(char *arg) } } +bool +CitrunInst::is_link_cmd(bool object_arg, bool compile_arg) +{ + if (!object_arg && !compile_arg && m_source_files.size() > 0) + // Assume single line a.out compilation + // $ gcc main.c + return true; + else if (object_arg && !compile_arg) + // gcc -o main main.o fib.o while.o + // gcc -o main main.c fib.c + return true; + + return false; +} + void CitrunInst::process_cmdline() { @@ -237,17 +252,7 @@ CitrunInst::process_cmdline() m_log << "Object arg = " << object_arg << ", " << "compile arg = " << compile_arg << "\n"; - bool linking = false; - if (!object_arg && !compile_arg && m_source_files.size() > 0) - // Assume single line a.out compilation - // $ gcc main.c - linking = true; - else if (object_arg && !compile_arg) - // gcc -o main main.o fib.o while.o - // gcc -o main main.c fib.c - linking = true; - - if (linking) { + if (is_link_cmd(object_arg, compile_arg)) { m_log << "Link detected, adding '"; #ifndef __APPLE__ // OSX always links this. diff --git a/src/inst_main.h b/src/inst_main.h @@ -17,6 +17,7 @@ private: int fork_compiler(); void restore_original_src(); void save_if_srcfile(char *); + bool is_link_cmd(bool, bool); std::vector<char *> m_args; InstrumentLogger m_log;