Closed Bug 1457057 Opened 2 years ago Closed 1 month ago

./mach gtest --debug breaks if no debugger name is specified (debugger not found)

Categories

(Testing :: GTest, defect, P2)

defect

Tracking

(firefox77 fixed)

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: Dexter, Assigned: gbrown)

Details

(Whiteboard: dev-prod-2020)

Attachments

(1 file)

Running the following command

> ./mach gtest Telemetry* --debug

breaks on Windows with the following error:

> $ ./mach gtest Telemetry* --debug
>  0:01.22 c:\mozilla-build\mozmake\mozmake.EXE -C testing/gtest -j8 -s gtest
>  0:03.40 force-cargo-library-build
>  0:05.15 force-cargo-library-build
>  0:12.09 [m[m[36m[1m    Blocking[m waiting for file lock on build directory
>  0:14.18 [m[m[32m[1m    Finished[m release [optimized] target(s) in 0.6 secs
>  0:15.01 [m[m[32m[1m    Finished[m release [optimized] target(s) in 0.3 secs
> Error running mach:
> 
>     ['gtest', 'Telemetry*', '--debug']
> 
> The error occurred in the implementation of the invoked mach command.
> 
> This should never occur and is likely a bug in the implementation of that
> command. Consider filing a bug for this issue.
> 
> If filing a bug, please include the full output of mach, including this error
> message.
> 
> The details of the failure are as follows:
> 
> UnboundLocalError: local variable 'debuggerInfo' referenced before assignment
> 
>   File "e:\mozilla-unified\python/mozbuild/mozbuild/mach_commands.py", line 602, in gtest
>     args = self.prepend_debugger_args(args, debugger, debugger_args)
>   File "e:\mozilla-unified\python/mozbuild/mozbuild/mach_commands.py", line 705, in prepend_debugger_args
>     args = [debuggerInfo.path] + debuggerInfo.args + args

Looks like [1] cannot find a debugger, so we don't get into [2] (and don't fail there). We eventually break hard at [3] as debuggerInfo is None.

[1] - https://searchfox.org/mozilla-central/rev/78dbe34925f04975f16cb9a5d4938be714d41897/python/mozbuild/mozbuild/mach_commands.py#685
[2] - https://searchfox.org/mozilla-central/rev/78dbe34925f04975f16cb9a5d4938be714d41897/python/mozbuild/mozbuild/mach_commands.py#688-689
[3] - https://searchfox.org/mozilla-central/rev/78dbe34925f04975f16cb9a5d4938be714d41897/python/mozbuild/mozbuild/mach_commands.py#705
Whiteboard: dev-prod-2020

Verified this is working fine on Ubuntu 18.04, where the default debugger is found:

./mach gtest 'Telemetry*' --debug
 0:00.47 /usr/bin/make -j8 -s recurse_gtest
 0:00.49 /home/gbrown/src/config/recurse.mk:101: warning: overriding recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.49 /home/gbrown/src/config/recurse.mk:74: warning: ignoring old recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.49 toolkit/library/gtest/rust/force-cargo-library-build
 0:02.31     Finished release [optimized] target(s) in 1.81s
 0:02.64 296 compiler warnings present.
 0:02.78 Overall system resources - Wall time: 2s; CPU: 95%; Read bytes: 4096; Write bytes: 3547136; Read time: 0; Write time: 0
 0:02.78 Swap in/out (MB): 0/0
To view resource usage of the build, run |mach resource-usage|.
 0:02.79 Your build was successful!
One or more Android-only options will be ignored
 0:02.80 /usr/bin/gdb -q --args /home/gbrown/objdirs/firefox/dist/bin/firefox -unittest --gtest_death_test_style=threadsafe
Reading symbols from /home/gbrown/objdirs/firefox/dist/bin/firefox...done.
(gdb) 
Assignee: nobody → gbrown
Priority: -- → P2

Behavior with a specified non-existent debugger is not too bad, but could be confusing:

./mach gtest 'Telemetry*' --debug --debugger=jjj
 0:00.46 /usr/bin/make -j8 -s recurse_gtest
 0:00.48 /home/gbrown/src/config/recurse.mk:101: warning: overriding recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.48 /home/gbrown/src/config/recurse.mk:74: warning: ignoring old recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.48 toolkit/library/gtest/rust/force-cargo-library-build
 0:02.31     Finished release [optimized] target(s) in 1.82s
 0:02.63 296 compiler warnings present.
 0:02.73 Overall system resources - Wall time: 2s; CPU: 96%; Read bytes: 4096; Write bytes: 40960; Read time: 0; Write time: 80
 0:02.73 Swap in/out (MB): 0/0
To view resource usage of the build, run |mach resource-usage|.
 0:02.75 Your build was successful!
One or more Android-only options will be ignored
Error: Could not find debugger jjj.
Is it installed? Is it in your PATH?
Could not find a suitable debugger in your PATH.
Error running mach:

    ['gtest', 'Telemetry*', '--debug', '--debugger=jjj']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.
You can invoke |./mach busted| to check if this issue is already on file. If it
isn't, please use |./mach busted file| to report it. If |./mach busted| is
misbehaving, you can also inspect the dependencies of bug 1543241.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

AssertionError

  File "/home/gbrown/src/python/mozbuild/mozbuild/mach_commands.py", line 568, in gtest
    pass_thru=True)
  File "/home/gbrown/src/python/mach/mach/mixin/process.py", line 78, in run_process
    args = self._normalize_command(args, require_unix_environment)
  File "/home/gbrown/src/python/mach/mach/mixin/process.py", line 163, in _normalize_command
    assert isinstance(args, list) and len(args)

Summary: ./mach gtest --debug breaks if no debugger name is specified → ./mach gtest --debug breaks if no debugger name is specified (debugger not found)

Simple update to gtest mach command handling of debugger arguments.

Now I see:

$ ./mach gtest 'Telemetry*' --debugger=jjj
 0:00.51 /usr/bin/make -j8 -s recurse_gtest
 0:00.54 /home/gbrown/src/config/recurse.mk:101: warning: overriding recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.54 /home/gbrown/src/config/recurse.mk:74: warning: ignoring old recipe for target 'toolkit/library/gtest/rust/gtest'
 0:00.54 toolkit/library/gtest/rust/force-cargo-library-build
 0:02.34     Finished release [optimized] target(s) in 1.80s
 0:02.78 296 compiler warnings present.
 0:02.83 Overall system resources - Wall time: 2s; CPU: 96%; Read bytes: 0; Write bytes: 221184; Read time: 0; Write time: 4
To view resource usage of the build, run |mach resource-usage|.
 0:02.84 Your build was successful!
One or more Android-only options will be ignored
Error: Could not find debugger jjj.
Is it installed? Is it in your PATH?
Could not find a suitable debugger in your PATH.
$

I expect the same handling if only --debug is specified but the default debugger is not found (as in the original bug report).

Pushed by gbrown@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3bdbd621b5ab
Exit 'mach gtest' with error if debugger not found; r=bc
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77

Thanks for doing this!

You need to log in before you can comment on or make changes to this bug.