Closed Bug 899342 Opened 11 years ago Closed 11 years ago

Let 'mach debug' pass arguments to GDB

Categories

(Firefox Build System :: General, defect)

All
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla25

People

(Reporter: jimb, Assigned: jimb)

Details

(Whiteboard: [mach])

Attachments

(1 file, 1 obsolete file)

Attached patch mach-debug-gdbparams.patch (obsolete) — Splinter Review
'mach debug' is handy, but it's even handier if one can use it within Emacs. All that's required is the ability to pass the '-fullname' flag to GDB, before the actual command and arguments.

This patch adds a '+gdbparams' argument to 'mach debug' whose value is split at whitespace and passed to GDB before the '--args' argument. 

Note that if we support other debuggers, like lldb, they can ignore the +gdbparams argument, and take their own flag, so it'll be easy to write mach-based scripts that get the right behavior out of one debugger without confusing the others.
mach bugs go in the component that the command is related to (unless it is a bug with the mach core - which is rare).
Component: mach → Build Config
Whiteboard: [mach]
An alternative approach would be for mach to take a +emacs argument, and implement it for all debuggers (or report an error if it can't do so).
Comment on attachment 782804 [details] [diff] [review]
mach-debug-gdbparams.patch

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

LGTM. I assume you wanted review.

::: python/mozbuild/mozbuild/mach_commands.py
@@ +650,5 @@
>      @CommandArgument('+background', '+b', action='store_true',
>          help='Do not pass the -foreground argument by default on Mac')
> +    @CommandArgument('+gdbparams', default=None, metavar='params', type=str,
> +        help='Command-line arguments to pass to GDB itself; split at whitespace.')
> +    def debug(self, params, remote, background, gdbparams):

We should probably be using named arguments instead of positional. I'm kinda surprised this works!

@@ +660,5 @@
>              print(e)
>              return 1
> +        args = [debugger]
> +        if gdbparams:
> +            args.extend(gdbparams.split())

How do you feel about using shlex.split() instead? docs.python.org/2/library/shlex.html
Attachment #782804 - Flags: review+
(In reply to Gregory Szorc [:gps] from comment #3)
> How do you feel about using shlex.split() instead?
> docs.python.org/2/library/shlex.html

shlex is useless. it doesn't handle quotes. pymake.process.clinetoargv does, but it doesn't like some characters.
(In reply to Gregory Szorc [:gps] from comment #3)
> Comment on attachment 782804 [details] [diff] [review]
> mach-debug-gdbparams.patch
> 
> Review of attachment 782804 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> LGTM. I assume you wanted review.

Yes - was going to find out who to ask.

> ::: python/mozbuild/mozbuild/mach_commands.py
> @@ +650,5 @@
> >      @CommandArgument('+background', '+b', action='store_true',
> >          help='Do not pass the -foreground argument by default on Mac')
> > +    @CommandArgument('+gdbparams', default=None, metavar='params', type=str,
> > +        help='Command-line arguments to pass to GDB itself; split at whitespace.')
> > +    def debug(self, params, remote, background, gdbparams):
> 
> We should probably be using named arguments instead of positional. I'm kinda
> surprised this works!

I'm cargo-culting; if you can be a bit more specific about what should be changed, I'll happily fix it.
Revised to use pymake.process.clinetoargv.
Assignee: nobody → jimb
Attachment #782804 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #783913 - Flags: review?(gps)
Comment on attachment 783913 [details] [diff] [review]
Implement '+gdbparams' argument for 'mach debug'.

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

r+ with moved import.

::: python/mozbuild/mozbuild/mach_commands.py
@@ +8,4 @@
>  import operator
>  import os
>  import sys
> +import pymake.process

All non-stdlib and non-mach and non-mozbuild imports in mach_commands.py files should go inside the command function. This prevents import bloat at mach execution time.
Attachment #783913 - Flags: review?(gps) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/780c67f5b185
Flags: in-testsuite-
Target Milestone: --- → mozilla25
https://hg.mozilla.org/mozilla-central/rev/780c67f5b185
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: