Bug 226390 - Add a way to prefix output of `WTFReportBacktrace` to make log filtering easier
Summary: Add a way to prefix output of `WTFReportBacktrace` to make log filtering easier
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks: 230207
  Show dependency treegraph
 
Reported: 2021-05-28 12:41 PDT by Devin Rousso
Modified: 2021-09-12 21:16 PDT (History)
10 users (show)

See Also:


Attachments
Patch (5.18 KB, patch)
2021-05-28 12:42 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (5.18 KB, patch)
2021-05-28 12:43 PDT, Devin Rousso
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (5.20 KB, patch)
2021-05-28 15:25 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2021-05-28 12:41:41 PDT
Often times while debugging I add `WTFLogAlways("<DR> ...")` to various places as indicators that "logic has reached here". This is especially useful when debugging iOS as unlike macOS there's no console output from `run-safari`, meaning that I have to use system logging, which is often a deluge of unrelated information. Having "<DR>" as a prefix makes filtering through the system logging trivial as I can ignore logs that don't have it. Unfortunately, `WTFReportBacktrace` does not have a way to add this prefix, so it becomes much harder to find in the logs.
Comment 1 Devin Rousso 2021-05-28 12:42:10 PDT
Created attachment 430042 [details]
Patch
Comment 2 Devin Rousso 2021-05-28 12:43:28 PDT
Created attachment 430043 [details]
Patch
Comment 3 Devin Rousso 2021-05-28 15:25:48 PDT
Created attachment 430062 [details]
Patch
Comment 4 Megan Gardner 2021-06-02 12:30:52 PDT
Comment on attachment 430062 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430062&action=review

> Source/WTF/wtf/Assertions.cpp:291
>  void WTFReportBacktrace()

Could you make it so this isn't duplicated code?
Comment 5 Devin Rousso 2021-06-02 17:33:01 PDT
Comment on attachment 430062 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430062&action=review

>> Source/WTF/wtf/Assertions.cpp:291
>>  void WTFReportBacktrace()
> 
> Could you make it so this isn't duplicated code?

I thought about doing this by having `WTFReportBacktrace` call `WTFReportBacktraceWithPrefix("")`, but I think the issue there is that we'd then want to adjust `framesToSkip`.  I'll take a stab at maybe using a `template` or something.
Comment 6 Devin Rousso 2021-06-04 10:20:44 PDT
Comment on attachment 430062 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430062&action=review

>>> Source/WTF/wtf/Assertions.cpp:291
>>>  void WTFReportBacktrace()
>> 
>> Could you make it so this isn't duplicated code?
> 
> I thought about doing this by having `WTFReportBacktrace` call `WTFReportBacktraceWithPrefix("")`, but I think the issue there is that we'd then want to adjust `framesToSkip`.  I'll take a stab at maybe using a `template` or something.

Turns out that I can't use a `template` because it's `extern "C"` :/

I did experiment with something like `#define WTFReportBacktrace() WTFReportBacktraceWithPrefix("")`, but it was pointed out to me that that could have issues if WebKit clients (e.g. Safari) depend on that symbol.
Comment 7 EWS 2021-06-04 10:58:44 PDT
Committed r278474 (238492@main): <https://commits.webkit.org/238492@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430062 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-04 10:59:19 PDT
<rdar://problem/78876754>
Comment 9 Fujii Hironori 2021-09-12 21:16:18 PDT
Comment on attachment 430062 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430062&action=review

> Source/WTF/wtf/StackTrace.h:104
> +    const char* m_prefix;

Adding a new member here is problematic.
Filed: Bug 230207 – StackTrace outputs a garbage prefix because WTF::StackTrace::m_prefix is filled with the stack content