Skip to content

Commit

Permalink
runtime: document that Caller and Frame.File always use forward slashes
Browse files Browse the repository at this point in the history
Document that Caller and Frame.File always use forward slashes
as path separators, even on Windows.

Fixes #3335

Change-Id: Ic5bbf8a1f14af64277dca4783176cd8f70726b91
Reviewed-on: https://go-review.googlesource.com/c/go/+/603275
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Pratt <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
  • Loading branch information
qmuntal committed Oct 25, 2024
1 parent bb07aa6 commit 0addb2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/runtime/extern.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ import (

// Caller reports file and line number information about function invocations on
// the calling goroutine's stack. The argument skip is the number of stack frames
// to ascend, with 0 identifying the caller of Caller. (For historical reasons the
// meaning of skip differs between Caller and [Callers].) The return values report the
// program counter, file name, and line number within the file of the corresponding
// call. The boolean ok is false if it was not possible to recover the information.
// to ascend, with 0 identifying the caller of Caller. (For historical reasons the
// meaning of skip differs between Caller and [Callers].) The return values report
// the program counter, the file name (using forward slashes as path separator, even
// on Windows), and the line number within the file of the corresponding call.
// The boolean ok is false if it was not possible to recover the information.
func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
rpc := make([]uintptr, 1)
n := callers(skip+1, rpc)
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type Frame struct {
// File and Line are the file name and line number of the
// location in this frame. For non-leaf frames, this will be
// the location of a call. These may be the empty string and
// zero, respectively, if not known.
// zero, respectively, if not known. The file name uses
// forward slashes, even on Windows.
File string
Line int

Expand Down

0 comments on commit 0addb2a

Please sign in to comment.