-
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) Please make sure to run cstyle as part of git pbchk. The way that these functions are put together isn't correct, it should look like:
static int pct(ushort_t pct)
I haven't commented on this for the other occurrences in this file.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) If we're calculating this as a uint_t, then why are we returning a signed value? Shouldn't it be an unsigned value?
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I'm not sure that I follow all the calculations that you're doing here. I get that you're trying to conver the 16-bit integer floating point value to something else, but it's not clear where 0x7000 comes from or why you do the check on value below. Would you mind writing a comment that better explains the conversion and what you're expecting as output?
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) This should be replaced with a call to proc_sysname(3PROC). Please don't encode the table here.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) This should be replaced with a call to proc_sysname(3PROC). Longer term we should put the name in the note, since the numbers aren't stable.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I'm not sure it's worth bothering with leading zeros. Importantly, in a 64-bit process, this can be a 64-bit value so the choice of 8 seems a bit arbitrary, as that only makes sense for a 32-bit process.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) tv_sec and tv_nsec are signed values, not unsigned. Also, both of these are technically long values.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) See other notes on the choice of 8 leading zeros.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I think with dmodel strings we should do the same with the libproc bits I mention below.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I think in all the cases where we're trying to add new tables, we should look to other ways to do this. For example, a lot of the various signal and fault codes are in libproc, so we should add those there so we don't duplicate these again. If that's something you'd like some help with, let me know. I'd be happy to help with that part. Though maybe we should add the errno to error string to libc.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) Note, this structure should generally be constructed as:
... case ILL_ILLOPC: code = "ILL_ILLOPC"; break; ...
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) With all of these, I think we should be printing out the actual name of the signal we received, not just the subcode. We can get the name of the signal via proc_signame(3PROC).
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) cstyle nit: The indentation here (and with others) is incorrect, the continuation should be indented four spaces, you have it right with the following line, though the last two lines can be joined together.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I think it's worth a comment describing where you get these values from and how you figured them out.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) So, a general note on this. Right now, this has been implemented in a way that it exists for mdb on a process, core file, live kernel, kernel crash dump, and the kernel debugger. However, the process information and having this only makes sense in the first two cases. To deal with this, the dcmd needs to be defined as part of the process target.
While there's not a great place for this, I'd probalby use the libc module as a place to implement this.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I would probably consider structuring the arguments for this in a different way. I'd probalby have ::psinfo show the summary version by default and then add a '-v' flag that describes having verbosity. I don't think it makes sense to have to specify an argument to get something.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) I would probably declare these variables at the top, with everything else.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) So, mdb_warn() has an interesting behavior. If you don't have a new line character at the end ('\n'), then it will append the most recent mdb error. If you were trying to get it in this particular case, then you have to keep in mind that it might have been generated by the first one, but was clobbered by the second call.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) Have you tested what happens when you have a core file of a different bitness in mdb? It seems like this is relying on the sizing of these structures being the same as the underlying host type. Also, what if you're debugging a core file where the elf note is larger that the underlying structure? Wouldn't that end up clobbering memory on the stack? I suspect that this will impact how many of the members and offsets are printed.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) Minor stylistic thing, but since these are exclusive options, I'd probably suggest that you use an 'else if' for the second case.
-
usr/src/cmd/mdb/common/mdb/mdb_cmds.c (Diff revision 1) The help message here is supposed to be a short summary of the options. However, you can supply a function that is run when someone asks for full help (via the ::help dcmd) which is where this additional explanation should be.
7780 mdb could extract NT_PRPSINFO information from core files
Review Request #1478 — Created Feb. 15, 2019 and submitted
Information | |
---|---|
cneira | |
illumos-gate | |
master | |
7780 | |
49a5821... | |
Reviewers | |
general | |
This patch add this feature to mdb https://www.illumos.org/issues/7780
It extracts psinfo_t from xdata buffers to present relevant information, also it prints most info that belongs to a NT_PRPSINFO note from elfdump using psinfo_t data.
cneira@Trixie:...illumos-omnios/usr/src/cmd/mdb$ /build/illumos-omnios/proto/root_i386-nd/usr/bin/amd64/mdb /home/cneira/core Loading modules: [ libc.so.1 ld.so.1 ] > ::psinfo Usage: psinfo [sum: print summary of psinfo_t data | raw: print relevant information of NT_PRPSINFO ] > ::psinfo raw [ NT_PRPSINFO ] pr_state: 6 pr_sname: O pr_zomb: 0 pr_nice: 20 pr_uid: 100 pr_gid: 1 pr_pid: 383885 pr_ppid: 340440 pr_pgid: 1 pr_sid: 340440 pr_addr: 0x00000000 pr_size: 0x6d0 pr_rssize: 0x38c pr_wchan: 0 pr_start: tv_sec: 1549649231 tv_nsec: 683629550 pr_time: tv_sec: 0 tv_nsec: 1054142 pr_pri: 59 pr_oldpri: 40 pr_cpu: 0 pr_clname: TS pr_fname: test pr_psargs: ./test pr_syscall: [ SYS#0 ] pr_ctime: tv_sec: 0 tv_nsec: 0 pr_argc: 1 pr_argv: 0x08039654 pr_envp: 0x0803965c pr_wstat: 139 pr_pctcpu: 0.0% pr_pctmem: 0.0% pr_euid: 100 pr_egid: 1 pr_dmodel: [PR_MODEL_ILP32] > ::psinfo sum PID: 383885 (process id) UID: 100 (real user id) PPID: 340440 (parent process id) EUID: 100 (effective user id) PGID: 383885 (process group id) GID: 1 (real group id) SID: 340440 (session id) EGID: 1 (effective group id) ZONEID: 0 CONTRACT: 94 PROJECT: 3 TASK: 87 START: 2019 Feb 8 15:07:11 (wall timestamp when the process started) TIME: 0.000000001 seconds (CPU time used by this process) CTIME: 0.000000000 seconds (CPU time used by child processes) FNAME: "test" (name of the program executed) PSARGS: "./test" > cneira@Trixie:...illumos-omnios/usr/src/cmd/mdb$ /build/illumos-omnios/proto/root_i386-nd/usr/bin/amd64/mdb /home/cneira/core.26853 Loading modules: [ libc.so.1 ld.so.1 ] > ::psinfo sum PID: 26853 (process id) UID: 100 (real user id) PPID: 891 (parent process id) EUID: 100 (effective user id) PGID: 26853 (process group id) GID: 1 (real group id) SID: 891 (session id) EGID: 1 (effective group id) ZONEID: 0 CONTRACT: 78 PROJECT: 3 TASK: 69 START: 2019 Jan 30 16:23:46 (wall timestamp when the process started) TIME: 0.000000009 seconds (CPU time used by this process) CTIME: 0.000000000 seconds (CPU time used by child processes) FNAME: "vim" (name of the program executed) PSARGS: "vim t.txt" > ::psinfo raw [ NT_PRPSINFO ] pr_state: 4 pr_sname: T pr_zomb: 0 pr_nice: 20 pr_uid: 100 pr_gid: 1 pr_pid: 26853 pr_ppid: 891 pr_pgid: 1 pr_sid: 891 pr_addr: 0xfffffe12cc0b0070 pr_size: 0x1b88 pr_rssize: 0xf64 pr_wchan: 0 pr_start: tv_sec: 1548876226 tv_nsec: 683326865 pr_time: tv_sec: 0 tv_nsec: 9875073 pr_pri: 59 pr_oldpri: 40 pr_cpu: 0 pr_clname: TS pr_fname: vim pr_psargs: vim t.txt pr_syscall: [ pollsys ] pr_ctime: tv_sec: 0 tv_nsec: 0 pr_argc: 2 pr_argv: 0xfffffc7fffdf5c48 pr_envp: 0xfffffc7fffdf5c60 pr_wstat: 0 pr_pctcpu: 0.0% pr_pctmem: 0.0% pr_euid: 100 pr_egid: 1 pr_dmodel: [PR_MODEL_LP64]32 bit core test
cneira@Trixie:~$ file 15\-dlmgmtd\-44 15-dlmgmtd-44: ELF 32-bit LSB core file 80386 Version 1, from 'dlmgmtd' cneira@Trixie:~$ /build/illumos-omnios/proto/root_i386-nd/usr/bin/amd64/mdb /home/cneira/15\-dlmgmtd\-44 Loading modules: [ libc.so.1 libavl.so.1 libnvpair.so.1 libsysevent.so.1 ld.so.1 ] > ::psinfo PID: 44 (process id) UID: 0 (real user id) PPID: 1 (parent process id) EUID: 15 (effective user id) PGID: 44 (process group id) GID: 0 (real group id) SID: 44 (session id) EGID: 65 (effective group id) ZONEID: 0 CONTRACT: 8 PROJECT: 0 TASK: 3 START: 2019 Feb 2 12:27:16 (wall timestamp when the process started) TIME: 0.21 seconds (CPU time used by this process) CTIME: 0.0 seconds (CPU time used by child processes) FNAME: dlmgmtd (name of the program executed) PSARGS: "/sbin/dlmgmtd" > ::psinfo -v [ NT_PRPSINFO ] pr_state: 6 pr_sname: O pr_zomb: 0 pr_nice: 20 pr_uid: 0 pr_gid: 0 pr_pid: 44 pr_ppid: 1 pr_pgid: 0 pr_sid: 44 pr_addr: 0x0 pr_size: 0xbd0 pr_rssize: 0x4fc pr_wchan: 0 pr_start: tv_sec: 1549121236 tv_nsec: 943744935 pr_time: tv_sec: 0 tv_nsec: 21095691 pr_pri: 60 pr_oldpri: 39 pr_cpu: 0 pr_clname: TS pr_fname: dlmgmtd pr_psargs: /sbin/dlmgmtd pr_syscall: [ lwp_kill ] pr_ctime: tv_sec: 0 tv_nsec: 0 pr_argc: 1 pr_argv: 0x8047e10 pr_envp: 0x8047e18 pr_wstat: 134 pr_pctcpu: 0.0% pr_pctmem: 0.1% pr_euid: 15 pr_egid: 65 pr_dmodel: [PR_MODEL_ILP32]
Change Summary:
I have addressed most of the comments in this revision, siginfo information was removed as it's already available using ::status dcmd.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+201 -1) |
Description: |
|
---|
-
Thanks, this looks pretty good. I only have a few inor follow ups.
-
-
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) The
static uint_t
value should be on one line andpct_value
should begin the next (see all the other functions in this file for an example). -
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) Same thing about the function declaration cstyle as with pct_value.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) A couple of notes on this: Shouldn't we be usying the buff that we used up above to print the data? Otherwise don't we still have the same problem with printing 8 digits in a 64-bit program case? Also, there should be a space between the '10' and '?'.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) It appears that we set up buff, but then don't do anything with it.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) It seems we're filling in buff, but then not using it.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) A couple of style notes: you don't need parens around this line and there should be a space before the '?'.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) In this case, I think you actually don't want the '\n' character so that way mdb_warn can include the more detailed error reason that mdb_get_xdata() failed automatically.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 2) I'd still recommend adding a more detailed help message if you'd like to. The help information you had before was useful, just that it should be in the usage function callback that you can define with a dcmd.
Change Summary:
cstyle issues fixes, most comments addressed.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+221 -1) |
Change Summary:
Updated with test case for 32-bit core
Testing Done: |
|
---|
Testing Done: |
|
---|
Change Summary:
added proc_dmodelname system call to return the data model value for a process.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+287 -9) |
-
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) Please use
SYS2STR_MAX
preprocessor constant instead of arbitrary value to set the size of this array.This line should be:
char sysname[SYS2STR_MAX];
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) Format string signedness mismatch,
pr_uid
andpr_gid
are unsigned values.
This line should look like:mdb_printf("\tpr_uid: %u\t\t\tpr_gid: %u\n",
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) pr_sid
is signed.mdb_printf("\tpr_pgid: %u\t\t\tpr_sid: %d\n",
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) Type of
pr_size
issize_t
, should be casted toulong_t
:mdb_printf("\tpr_addr: %s%*spr_size: %#lx\n", buff, strlen(buff) > spbcols ? minspaces : (spbcols - bufflen), " ", (ulong_t)psinfo.pr_size);
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) pr_rssize
also should be casted toulong_t
, and length modifiers are missing.mdb_printf("\tpr_rssize: %#lx\t\tpr_wchan: %#lx\n", (ulong_t)psinfo.pr_rssize, (ulong_t)psinfo.pr_lwp.pr_wchan);
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) Type of
tv_nsec
islong
andtv_sec
also derived from that type.(Just to make these type-correct. Of course, I'm aware the practical limit of
tv_nsec
. In the case oftv_sec
, maybe somebody after this date and time: Tue, 19 Jan 2038 03:14:07 GMT [without leap seconds] want to see correct value :) .)mdb_printf("\tpr_start:\n\t tv_sec: %ld\t\ttv_nsec: %ld\n",
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("\tpr_time:\n\t tv_sec: %ld\t\t\ttv_nsec: %ld\n", psinfo.pr_time.tv_sec, psinfo.pr_time.tv_nsec);
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("\tpr_ctime:\n\t tv_sec: %ld\t\t\ttv_nsec: %ld\n", psinfo.pr_ctime.tv_sec, psinfo.pr_ctime.tv_nsec);
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("\tpr_argc: %d\t\t\tpr_argv: 0x%lx\n", psinfo.pr_argc, (ulong_t)psinfo.pr_argv);
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("\tpr_euid: %u\t\t\tpr_egid: %u\n",
-
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("PGID: %6d (process group id)\tGID: %4u"
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_printf("SID: %6d (session id)\t\tEGID: %4u"
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_snprintf(buff, sizeof (buff), "%ld.%d seconds",
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) Please remove one from the two whitespace after the
=
operator. -
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 4) mdb_snprintf(buff, sizeof (buff), "%ld.%d seconds",
-
usr/src/lib/libproc/common/libproc.h (Diff revision 4) Typo in comment and reference to
SIG2STR_MAX
was removed to make this comment shorter.
(I think this reference should be in the block comment, a few lines above.)Trailing comment separated by the rest of the line with a tab, see here: C Style and Coding Standards for SunOS, Section 7.3. Trailing Comments, Page 8 (the rules that cstyle (1onbld) try to check, comes from this document).
#define DMODELSTR_MAX 32 /* max. string length of data model */
-
usr/src/lib/libproc/common/mapfile-vers (Diff revision 4) This should be between
proc_content2str
(line 208) andproc_finistdio
(should be in alphabetical order). -
usr/src/lib/libproc/common/proc_names.c (Diff revision 4) See the style of how
systable[]
initializied (one line - one value, and line indentation). -
usr/src/man/man3lib/libproc.3lib (Diff revision 4) Typo and should be in in alphabetical order.
.It Sy Perror_printf Ta Sy proc_arg_grab .It Sy proc_arg_psinfo Ta Sy proc_arg_xgrab .It Sy proc_arg_xpsinfo Ta Sy proc_content2str .It Sy proc_dmodelname Ta Sy proc_finistdio .It Sy proc_fltname Ta Sy proc_fltset2str .It Sy proc_flushstdio Ta Sy proc_get_auxv .It Sy proc_get_cred Ta Sy proc_get_priv .It Sy proc_get_psinfo Ta Sy proc_get_status .It Sy proc_initstdio Ta Sy proc_lwp_in_set .It Sy proc_lwp_range_valid Ta Sy proc_signame .It Sy proc_sigset2str Ta Sy proc_str2content .It Sy proc_str2flt Ta Sy proc_str2fltset .It Sy proc_str2sig Ta Sy proc_str2sigset .It Sy proc_str2sys Ta Sy proc_str2sysset .It Sy proc_sysname Ta Sy proc_sysset2str .It Sy proc_unctrl_psinfo Ta Sy proc_walk
-
usr/src/man/man3lib/libproc.3lib (Diff revision 4) This should be in line 1223 instead of 1236 (should be listed in alphabetical order).
Change Summary:
Fixes for last review comments
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+404 -21) |
-
-
usr/src/lib/libproc/common/libproc.h (Diff revision 5) A typo in the comment still persist:
's/syscalls/data models/'
(
DMODELSTR_MAX
is for data model strings and not for syscalls, even if these constans at this moment expands to the same value.) -
usr/src/man/man3proc/proc_dmodelname.3proc (Diff revision 5) You don't have to duplicate the same file again.
Instead, you have to create links to the common manual page (in this case it's proc_fltname.3proc).
Please, edit these files:
- usr/src/man/man3proc/Makefile:
395 395 proc_flushstdio.3proc := LINKSRC = proc_initstdio.3proc 396 396 proc_finistdio.3proc := LINKSRC = proc_initstdio.3proc 397 397 398 + proc_dmodelname.3proc := LINKSRC = proc_fltname.3proc 398 399 proc_signame.3proc := LINKSRC = proc_fltname.3proc 399 400 proc_sysname.3proc := LINKSRC = proc_fltname.3proc 400 401 401 402 proc_sigset2str.3proc := LINKSRC = proc_fltset2str.3proc
- usr/src/pkg/manifests/system-library.man3proc.inc:
230 230 link path=usr/share/man/man3proc/proc_arg_xgrab.3proc target=proc_arg_grab.3proc 231 231 link path=usr/share/man/man3proc/proc_arg_xpsinfo.3proc target=proc_arg_psinfo.3proc 232 + link path=usr/share/man/man3proc/proc_dmodelname.3proc target=proc_fltname.3proc 232 233 link path=usr/share/man/man3proc/proc_finistdio.3proc target=proc_initstdio.3proc 233 234 link path=usr/share/man/man3proc/proc_flushstdio.3proc target=proc_initstdio.3proc 234 235 link path=usr/share/man/man3proc/proc_free_priv.3proc target=proc_get_priv.3proc
See in the illumos Developer's Guide, Adding a new manual page section:
A single manual page may be used for multiple manuals. For example, the manual page...
Change Summary:
latest issues fixed.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+309 -22) |
-
Thanks, this looks pretty good. Thank you for writing the manual page for the new libproc function. I have a few minor notes, some stylistic, some correctness based. Thank you for all the work on this.
-
usr/src/cmd/mdb/common/modules/libc/libc.c (Diff revision 6) I don't think you want the '\n' on this, that way you can get the underlying mdb error printed out that occurred automatically for you.
-
usr/src/lib/libproc/common/libproc.h (Diff revision 6) Is there a reason this isn't joined to the previous line like others?
-
usr/src/lib/libproc/common/proc_names.c (Diff revision 6) So, I think we have an interesting question here. The kernel represents the model usually as a uint_t (see ddi_model_convert_from(9F) for example). However, in procfs we end up representing it as a signed character. That's kind of unfortunate. I guess we should probably keep it as a char to match the procfs version. I might actually increase it to an int to match the other versions as we can always place a char argument in an int.
-
usr/src/lib/libproc/common/proc_names.c (Diff revision 6) A couple of notes here and some questions. In new code, I would pretty much avoid strcpy and always use strlcpy even when it means doing extra work as it'll end up keeping the code safer against refactoring.
However, is there a reason that you're copying the string into the name buffer to then copy it out to the user buffer? Rather than copying it to an intermediate buffer, you can just use a pointer to index into dmdls, or just keep track of the offset and pass that to strncpy. I think you're basing this off of proc_signame(); however, that case actually is modifying the string to make sure that "SIG" is there where as here we don't have to. Instead, I would model this more off of proc_fltname().
Finally, I don't think it's correct to use PR_MODEL_UNKNOWN in the case where we don't recognize the value. I would probably treat this like proc_fltname and proc_signame and instead of using dmdls[0], do something like:
len = snprintf(buf, bufsz, "DMODEL#%d", dmodel);
Change Summary:
fixed last comments.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+306 -22) |
Change Summary:
changes addressing latest comments
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 8 (+306 -22) |