[Tracing] Add THIS_FUNCTION_WITH_TEMPLATE_ARGS tracing helper macro [chromium/src : main]

0 views
Skip to first unread message

Justin Novosad (Gerrit)

unread,
Jul 8, 2026, 5:57:12 PMJul 8
to Etienne Pierre-Doray, Rohit Rao, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org
Attention needed from Etienne Pierre-Doray and Rohit Rao

Justin Novosad voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Etienne Pierre-Doray
  • Rohit Rao
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ie18e7452679449e2ad5dfb6a8496d50701c23c21
Gerrit-Change-Number: 8067556
Gerrit-PatchSet: 2
Gerrit-Owner: Justin Novosad <ju...@chromium.org>
Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Reviewer: Justin Novosad <ju...@chromium.org>
Gerrit-Reviewer: Rohit Rao <rohi...@chromium.org>
Gerrit-Attention: Rohit Rao <rohi...@chromium.org>
Gerrit-Attention: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Comment-Date: Wed, 08 Jul 2026 21:57:05 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Etienne Pierre-Doray (Gerrit)

unread,
Jul 10, 2026, 2:50:29 PMJul 10
to Justin Novosad, Rohit Rao, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org
Attention needed from Justin Novosad and Rohit Rao

Etienne Pierre-Doray added 2 comments

File base/trace_event/func_name_util.h
Line 21, Patchset 2 (Latest):constexpr std::string_view ExtractFunctionNameViewWithTemplateArgs(
Etienne Pierre-Doray . unresolved

This approach seems a bit fragile and error prone
As-is, it doesn't work with `void MyClass<void()>::Method()`

File ios/chrome/browser/tabs/model/tab_helper_attacher.h
Line 39, Patchset 2 (Latest): TRACE_EVENT("ui", THIS_FUNCTION_WITH_TEMPLATE_ARGS);
Etienne Pierre-Doray . unresolved

I think 2 common patterns that we could add simpler utils for (and might be more flexible)

1- constexpr string concatenation, something like
```
template <size_t N1, size_t N2>
constexpr auto ConcatHelper(std::string_view s1, std::string_view s2) {
std::array<char, N1 - 1 + N2 + 1> result{};
auto it = std::copy(s1.begin(), s1.end(), result.begin()); // No allocation
std::copy(s2.begin(), s2.end(), it);
return result;
}
#define BASE_CONST_STR_CAT(s1, s2)                                             
([&]() {
constexpr std::string_view macro_s1 = (s1);
constexpr std::string_view macro_s2 = (s2);
return ConcatHelper<macro_s1.size(),macro_s2.size()>(macro_s1, macro_s2);
}())
```

2- If plumbing a name from the caller is too difficult, we could add a "T to string" utility, something like (this also relies on parsing PRETTY_FUNCTION, but complexity is bounded because we're always in GetTypeName):

```

template <typename T>
constexpr std::string_view GetTypeName() {
std::string_view name = PRETTY_FUNCTION;
// Clang: "... [T = MyType]"
// GCC: "... [with T = MyType]"
size_t start = name.find("T = ");
if (start == std::string_view::npos) return "Unknown";
start += 4;
size_t end = name.rfind(']');
if (end == std::string_view::npos) return "Unknown";
return name.substr(start, end - start);
}
```

Then we can do something like:

```
TRACE_EVENT("ui", BASE_CONST_STR_CAT("TypedTabHelperAttacher:", GetTypeName<T>()));
```

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Novosad
  • Rohit Rao
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie18e7452679449e2ad5dfb6a8496d50701c23c21
    Gerrit-Change-Number: 8067556
    Gerrit-PatchSet: 2
    Gerrit-Owner: Justin Novosad <ju...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Justin Novosad <ju...@chromium.org>
    Gerrit-Reviewer: Rohit Rao <rohi...@chromium.org>
    Gerrit-Attention: Justin Novosad <ju...@chromium.org>
    Gerrit-Attention: Rohit Rao <rohi...@chromium.org>
    Gerrit-Comment-Date: Fri, 10 Jul 2026 18:50:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Justin Novosad (Gerrit)

    unread,
    Jul 22, 2026, 2:47:21 PMJul 22
    to Etienne Pierre-Doray, Rohit Rao, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org

    Justin Novosad abandoned this change.

    View Change

    Abandoned Don't really need this

    Justin Novosad abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: abandon
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages