diff --git a/src/formatting.cpp b/src/formatting.cpp index 5758fdd..ef7db8a 100644 --- a/src/formatting.cpp +++ b/src/formatting.cpp @@ -208,18 +208,19 @@ namespace cpptrace { const auto yellow = color ? YELLOW : ""; const auto blue = color ? BLUE : ""; if(frame.is_inline) { - microfmt::print(stream, "{<{}}", 2 * sizeof(frame_ptr) + 2, "(inlined)"); - } else { + microfmt::print(stream, "{<{}} ", 2 * sizeof(frame_ptr) + 2, "(inlined)"); + } else if(options.addresses != address_mode::none) { auto address = options.addresses == address_mode::raw ? frame.raw_address : frame.object_address; - microfmt::print(stream, "{}0x{>{}:0h}{}", blue, 2 * sizeof(frame_ptr), address, reset); + microfmt::print(stream, "{}0x{>{}:0h}{} ", blue, 2 * sizeof(frame_ptr), address, reset); } if(!frame.symbol.empty()) { - microfmt::print(stream, " in {}{}{}", yellow, frame.symbol, reset); + microfmt::print(stream, "in {}{}{}", yellow, frame.symbol, reset); } if(!frame.filename.empty()) { microfmt::print( stream, - " at {}{}{}", + "{}at {}{}{}", + frame.symbol.empty() ? "" : " ", green, options.paths == path_mode::full ? frame.filename : detail::basename(frame.filename, true), reset diff --git a/test/unit/lib/formatting.cpp b/test/unit/lib/formatting.cpp index 25e1f1d..f718a7a 100644 --- a/test/unit/lib/formatting.cpp +++ b/test/unit/lib/formatting.cpp @@ -96,6 +96,21 @@ TEST(FormatterTest, ObjectAddresses) { ); } +TEST(FormatterTest, NoAddresses) { + auto formatter = cpptrace::formatter{} + .addresses(cpptrace::formatter::address_mode::none); + auto res = split(formatter.format(make_test_stacktrace()), "\n"); + EXPECT_THAT( + res, + ElementsAre( + "Stack trace (most recent call first):", + "#0 in foo() at foo.cpp:20:30", + "#1 in bar() at bar.cpp:30:40", + "#2 in main at foo.cpp:40:25" + ) + ); +} + TEST(FormatterTest, PathShortening) { cpptrace::stacktrace trace; trace.frames.push_back({0x1, 0x1001, {20}, {30}, "/home/foo/foo.cpp", "foo()", false});