Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: add --debug-cycle to help debug print #256

Open
wants to merge 1 commit into
base: xs-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ AddOption('--pgo-prof', action='store_true',
help='Enable pgo profiling generation')
AddOption('--pgo-use', action='store', default=None,
help='Use pgo profiling results')
AddOption('--debug-cycle', action='store_true',
help='Enable print cycle in DPRINTF')

# Inject the built_tools directory into the python path.
sys.path[1:1] = [ Dir('#build_tools').abspath ]
Expand Down
7 changes: 7 additions & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ envs['debug'].Append(CPPDEFINES=['DEBUG', 'TRACING_ON=1'])
envs['opt'].Append(CCFLAGS=['-g'], CPPDEFINES=['TRACING_ON=1'])
envs['fast'].Append(CPPDEFINES=['NDEBUG', 'TRACING_ON=0'])

if GetOption('debug_cycle'):
for target in ['debug', 'opt', 'fast']:
envs[target].Append(CPPDEFINES=['DEBUG_SHOW_CYCLES=1'])
else:
for target in ['debug', 'opt', 'fast']:
envs[target].Append(CPPDEFINES=['DEBUG_SHOW_CYCLES=0'])

# For Link Time Optimization, the optimisation flags used to compile
# individual files are decoupled from those used at link time
# (i.e. you can compile with -O3 and perform LTO with -O0), so we need
Expand Down
24 changes: 18 additions & 6 deletions src/base/trace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,24 @@ struct StringWrap
::gem5::curTick(), name(), data, count, #x); \
} while (0)

#define DPRINTF(x, ...) do { \
if (GEM5_UNLIKELY(TRACING_ON && (::gem5::debug::x))) { \
::gem5::Trace::getDebugLogger()->dprintf_flag( \
::gem5::curTick(), name(), #x, __VA_ARGS__); \
} \
} while (0)
#if DEBUG_SHOW_CYCLES
#define DPRINTF(x, ...) do { \
if (GEM5_UNLIKELY(TRACING_ON && (::gem5::debug::x))) { \
::gem5::Trace::getDebugLogger()->dprintf_flag( \
::gem5::curTick(), name(), #x, \
"[c: %llu] %s", \
::gem5::curTick()/333, \
::gem5::csprintf(__VA_ARGS__).c_str()); \
} /* todo: remove 333, use cpu->clockPeriod() */ \
} while (0)
#else
#define DPRINTF(x, ...) do { \
if (GEM5_UNLIKELY(TRACING_ON && (::gem5::debug::x))) { \
::gem5::Trace::getDebugLogger()->dprintf_flag( \
::gem5::curTick(), name(), #x, __VA_ARGS__); \
} \
} while (0)
#endif

#define DPRINTFS(x, s, ...) do { \
if (GEM5_UNLIKELY(TRACING_ON && (::gem5::debug::x))) { \
Expand Down