From: John Baldwin <jhb@freebsd.org>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 4/5] Support 'info proc' for native FreeBSD processes.
Date: Fri, 05 Jan 2018 19:43:00 -0000 [thread overview]
Message-ID: <2876637.AoPeRzWIMe@ralph.baldwin.cx> (raw)
In-Reply-To: <eb25fb7c-c0e9-ce06-f818-3755cc197393@simark.ca>
On Thursday, January 04, 2018 10:20:05 PM Simon Marchi wrote:
> On 2018-01-03 08:49 PM, John Baldwin wrote:
> > - Command line arguments are fetched via the kern.proc.args.<pid>
> > sysctl.
> > - The 'cwd' and 'exe' values are obtained from the per-process
> > file descriptor table returned by kinfo_getfile() from libutil.
> > - 'mappings' is implemented by walking the array of VM map entries
> > returned by kinfo_getvmmap() from libutil.
> > - 'status' output is generated by outputting fields from the structure
> > returned by the kern.proc.pid.<pid> sysctl.
> > - 'stat' is aliased to 'status'.
>
> Hi John,
>
> The patch LGTM in general, I noted 2 comments, the first one could be done
> as a separate patch (after this series), if you agree with it. The second,
> I'm fine if you just fix it before pushing.
>
> > + struct kinfo_vmentry *kve = vmentl.get ();
> > + for (int i = 0; i < nvment; i++, kve++)
> > + {
> > + ULONGEST start, end;
> > +
> > + start = kve->kve_start;
> > + end = kve->kve_end;
> > +#ifdef __LP64__
> > + printf_filtered (" %18s %18s %10s %10s %9s %s\n",
> > + hex_string (start),
> > + hex_string (end),
> > + hex_string (end - start),
> > + hex_string (kve->kve_offset),
> > + fbsd_vm_map_entry_flags (kve->kve_flags,
> > + kve->kve_protection),
> > + kve->kve_path);
> > +#else
> > + printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
> > + hex_string (start),
> > + hex_string (end),
> > + hex_string (end - start),
> > + hex_string (kve->kve_offset),
> > + fbsd_vm_map_entry_flags (kve->kve_flags,
> > + kve->kve_protection),
> > + kve->kve_path);
> > +#endif
> > + }
>
> It might be a good idea to factor out the printing of vm map entries from here
> and the core code, to make sure that they will always be printed the same way.
> It's up to you.
So I thought about that (and that's why the fbsd_vm_map_entry_flags is shared
in fbsd-tdep.c). I would perhaps need some way to tell the common code which
layout to use as it's based on gdbarch_addr_bit() in the tdep code but uses
an #ifdef in this version. I also considered doing this for the 'status'
implementation, but I would probably need to export the 'kinfo_proc_layout'
structures from the tdep file and use an #ifdef in the native target to choose
which layout to use. The 'status' is also a bit trickier as some fields are
printed for native but not for cores, and the native version uses getpagesize()
to convert page counts to Kb that the core version can't do. Merging the
'mappings' probably is more doable though than 'status' as it really just
needs 'addr_bit' passed in. (I believe I can't quite pass in 'target_gdbarch()'
since I might be attached to a 32-bit process but be running 'info proc mappings'
with the PID of a 64-bit processes for which target_gdbarch() would be wrong.)
> > + }
> > + else
> > + warning (_("unable to fetch virtual memory map"));
> > + }
> > +#endif
> > + if (do_status)
> > + {
> > + if (!fbsd_fetch_kinfo_proc(pid, &kp))
>
> Missing space here. But didn't we fetch it already (line 329)?
> IIUC, we only need it in this scope, so you could move the
> relevant variables here, and only call fbsd_fetch_kinfo_proc here.
> I suppose it needed to be this way when stat and status were not
> merged.
Oh, whoops, I missed finishing that cleanup when collapsing down to a single
'status'. :-/ Yes, the intention was to remove 'kp_valid' entirely.
--
John Baldwin
next prev parent reply other threads:[~2018-01-05 19:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-04 1:50 [PATCH v2 0/5] Support for 'info proc' on FreeBSD cores and native John Baldwin
2018-01-04 1:50 ` [PATCH v2 2/5] Don't return stale data from fbsd_pid_to_exec_file for kernel processes John Baldwin
2018-01-05 2:57 ` Simon Marchi
2018-01-05 19:43 ` John Baldwin
2018-01-04 1:50 ` [PATCH v2 1/5] Support 'info proc' for FreeBSD process core dumps John Baldwin
2018-01-05 2:54 ` Simon Marchi
2018-01-05 19:43 ` John Baldwin
2018-01-09 19:29 ` Simon Marchi
2018-01-04 1:50 ` [PATCH v2 3/5] Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free() John Baldwin
2018-01-05 2:58 ` Simon Marchi
2018-01-04 1:59 ` [PATCH v2 4/5] Support 'info proc' for native FreeBSD processes John Baldwin
2018-01-05 3:20 ` Simon Marchi
2018-01-05 19:43 ` John Baldwin [this message]
2018-01-04 1:59 ` [PATCH v2 5/5] Document support for 'info proc' on FreeBSD John Baldwin
2018-01-04 16:38 ` Eli Zaretskii
2018-01-04 21:36 ` John Baldwin
2018-01-05 6:53 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2876637.AoPeRzWIMe@ralph.baldwin.cx \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox