Open Bug 1641799 Opened 4 years ago Updated 4 years ago

Devtool do not show function name for dynamic named function in call stack

Categories

(DevTools :: Debugger, defect, P3)

78 Branch
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: mmis1000, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

  1. Create a function with dynamic generated Function::name
{
  function withName(name, cb, ...args) {
    var obj = {
      [name]: function () {
        return cb.apply(this, arguments)
      }
    }

    return obj[name]
  }

  const name = `南無喝囉怛那哆囉夜耶`

  const makeError = () => { debugger; throw new Error() }

  let decorated = makeError

  withName(name, makeError)()
}
  1. invoke it and see the both call stack in devtool and Error::stack

Actual results:

They both show the function named as we supplied 南無喝囉怛那哆囉夜耶

Expected results:

The devtool shows it as withName (wrong)

The Error::stack shows as we expect. (correct)

The devtool shows it as withName (wrong)
https://i.imgur.com/qiUyZc5.png

The Error::stack shows as we expect. (correct)
https://i.imgur.com/O2h6unN.png

Images

Oops.. I write the Actual results: ans the Expected results: in wrong section.
Someone help?

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Debugger
Product: Firefox → DevTools

The severity field is not set for this bug.
:jlast, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jlaster)

This is a debugger frontend issue. We get the right name from the server, but our code in https://searchfox.org/mozilla-central/rev/8d55e18875b89cdf2a22a7cba60dc40999c18356/devtools/client/debugger/src/actions/pause/mapDisplayNames.js#31 is then overriding the good name from the server with a worse name.

This logic exists to give better names to things in the context of sourcemaps, but it's clearly too aggressive here. It looks like it uses "closest", so that is probably what we need to change. We should only use the original function name if the location is an exact match. I assume the "closest" ends up being the parent function, hence the strange behavior here.

Blocks: dbg-frontend
Severity: -- → S3
Flags: needinfo?(jlaster)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.