Closed Bug 1388807 Opened 7 years ago Closed 7 years ago

StackWalk.h can't be included from C files, despite claiming it is intended to be

Categories

(Core :: mozglue, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: keeler, Assigned: froydnj)

References

Details

Attachments

(1 file)

StackWalk.h says: /* WARNING: This file is intended to be included from C or C++ files. */

and yet uses bool and namespace, which means it can't actually be included from C files.
Yeah, we stopped actually testing that it could be included from C files when we removed trace-malloc in bug 1014341.
What do you need it to be callable from C code for?  It's probably not difficult to make things C-compatible, but it is a little unusual.
Component: MFBT → mozglue
Flags: needinfo?(dkeeler)
I'm trying to debug a test failure that only reproduces on treeherder, so I wanted to dump some stack traces from NSS, which happens to be C. I later realized this wouldn't be possible since it would create a circular library dependency, so in this case it wouldn't help anyway. What I really want is a standalone utility function callable from pretty much anywhere that will dump the stack, but that's probably a bit out of scope here. For this bug, I think it might just be best to fix the documentation to not be misleading :)
Flags: needinfo?(dkeeler)
We use C++ constructs in this file, we shouldn't advertise C
compatibility in the comments.
Attachment #8895474 - Flags: review?(dkeeler)
Comment on attachment 8895474 [details] [diff] [review]
fix StackWalk.h documentation

Review of attachment 8895474 [details] [diff] [review]:
-----------------------------------------------------------------

Cool - thanks!

::: mozglue/misc/StackWalk.h
@@ -3,5 @@
>  /* This Source Code Form is subject to the terms of the Mozilla Public
>   * License, v. 2.0. If a copy of the MPL was not distributed with this
>   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
>  
> -/* API for getting a stack trace of the C/C++ stack on the current thread */

There are a couple of other comments that reference the "C/C++ stack" of the current or other threads. I guess they're not technically wrong since while code using this API would be C++, there could be C frames on this/other threads? (although maybe they should all just say "stack trace" and not mention C/C++)
Attachment #8895474 - Flags: review?(dkeeler) → review+
Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e5b80827a4db
fix StackWalk.h documentation; r=keeler
Assignee: nobody → nfroyd
https://hg.mozilla.org/mozilla-central/rev/e5b80827a4db
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: