Closed Bug 1771213 Opened 2 years ago Closed 2 years ago

lldb won't let me call profiler_save_profile_to_file from the debugger because of baseprofiler ambiguity

Categories

(Core :: Gecko Profiler, defect, P3)

defect

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: mstange, Assigned: mozbugz)

Details

Attachments

(1 file)

I was trying to get a profile of a hung Firefox parent process today.

Target 0: (firefox) stopped.
(lldb) p (void)profiler_save_profile_to_file("/Users/mstange/Desktop/hang.json") 
error: expression failed to parse:
error: <user expression 0>:1:7: call to 'profiler_save_profile_to_file' is ambiguous
(void)profiler_save_profile_to_file("/Users/mstange/Desktop/hang.json")
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: candidate function

note: candidate function

(lldb)

To work around this, I commented out the baseprofiler version of this function and the call from TestBaseProfiler.cpp.

The Base Profiler version is in the mozilla::baseprofiler namespace, while the other one is in the root namespace.

Markus, could you please try adding an explicit namespace, i.e. ::profiler_save_profile_to_file(...)?

If it's still not working, or just to avoid these annoyances, we could rename clashing Base Profiler functions anyway.

Flags: needinfo?(mstange.moz)

I think I tried that and it gave me the same error.

Flags: needinfo?(mstange.moz)

Ah, probably because both have the extern "C" declaration, and C exports don't know anything about namespaces.

(In reply to Markus Stange [:mstange] from comment #4)

Ah, probably because both have the extern "C" declaration, and C exports don't know anything about namespaces.

I only see extern "C" around the Gecko Profiler's profiler_save_profile_to_file.
The Base Profiler one is declared with MFBT_API, is that acting like a C export as well?

Anyway, it sounds like it's causing troubles, so we should consider renaming...

Severity: -- → S4
Priority: -- → P3

Calling profiler_save_profile_to_file from lldb errored with "call to 'profiler_save_profile_to_file' is ambiguous", even though they're in different namespaces.

Assignee: nobody → gsquelart
Status: NEW → ASSIGNED

(In reply to Gerald Squelart [:gerald] (he/him) from comment #5)

(In reply to Markus Stange [:mstange] from comment #4)

Ah, probably because both have the extern "C" declaration, and C exports don't know anything about namespaces.

I only see extern "C" around the Gecko Profiler's profiler_save_profile_to_file.
The Base Profiler one is declared with MFBT_API, is that acting like a C export as well?

Oh, huh, no idea. Then I'm not exactly sure what causes the collision.

Pushed by gsquelart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f72b87839142
mozilla::baseprofiler::baseprofiler_save_profile_to_file now has prefix "base" to avoid lldb call ambiguity - r=mstange
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: