mirror of
https://gitlab.com/procps-ng/procps.git
synced 2024-12-03 06:54:08 +08:00
ps: exploit the simplified library interface for wchan
This patch was made necessary by those library changes in support of recently revised/simplified wchan logic. In addition, this commit eliminates a broken alternate 'namelist' provision which was intended to allow users to specify a System.map file to be used in translating addresses into function names. But, the real effect of the now defunct 'N' and '-n' options was to indirectly force addresses (not names) to be displayed since such user named map files could not be successfully parsed. Besides when the required FRAME_POINTER kconfig option is absent there is no address to translate and when it is present /proc/PID/wchan is already translated. Thus an alternate mapping is unnecessary and inappropriate. [ we'll forgive POSIX for documenting '-n namelist' ] Reference(s): http://www.freelists.org/post/procps/WCHAN,11 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
6b8dc5511f
commit
caeebdc71f
@ -294,7 +294,6 @@ extern int header_type; /* none, single, multi... */
|
||||
extern int include_dead_children;
|
||||
extern int lines_to_next_header;
|
||||
extern int max_line_width;
|
||||
extern const char *namelist_file;
|
||||
extern int negate_selection;
|
||||
extern int page_size; // "int" for math reasons?
|
||||
extern unsigned personality;
|
||||
|
@ -311,10 +311,6 @@ static void lists_and_needs(void){
|
||||
if(proc_format_needs&PROC_FILLCOM) proc_format_needs |= PROC_FILLENV;
|
||||
}
|
||||
|
||||
/* FIXME broken filthy hack -- got to unify some stuff here */
|
||||
if( ( (proc_format_needs|task_format_needs|needs_for_sort) & PROC_FILLWCHAN) && !wchan_is_number)
|
||||
if (open_psdb(namelist_file)) wchan_is_number = 1;
|
||||
|
||||
if(thread_flags&TF_loose_tasks) needs_for_threads |= PROC_LOOSE_TASKS;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,6 @@ int header_gap = -1;
|
||||
int header_type = -1;
|
||||
int include_dead_children = -1;
|
||||
int lines_to_next_header = -1;
|
||||
const char *namelist_file = (const char *)0xdeadbeef;
|
||||
int negate_selection = -1;
|
||||
int running_only = -1;
|
||||
int page_size = -1; // "int" for math reasons?
|
||||
@ -388,7 +387,6 @@ void reset_global(void){
|
||||
header_type = HEAD_SINGLE;
|
||||
include_dead_children = 0;
|
||||
lines_to_next_header = 1;
|
||||
namelist_file = NULL;
|
||||
negate_selection = 0;
|
||||
page_size = getpagesize();
|
||||
running_only = 0;
|
||||
@ -512,9 +510,6 @@ void self_info(void){
|
||||
);
|
||||
|
||||
fprintf(stderr, "archdefs:%s\n", archdefs);
|
||||
|
||||
open_psdb(namelist_file);
|
||||
fprintf(stderr,"namelist_file=\"%s\"\n",namelist_file?namelist_file:"<no System.map file>");
|
||||
}
|
||||
|
||||
void __attribute__ ((__noreturn__))
|
||||
|
11
ps/output.c
11
ps/output.c
@ -720,7 +720,7 @@ static int pr_wchan(char *restrict const outbuf, const proc_t *restrict const pp
|
||||
size_t len;
|
||||
if(!(pp->wchan & 0xffffff)) return memcpy(outbuf,"-",2),1;
|
||||
if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu);
|
||||
w = lookup_wchan(pp->wchan, pp->XXXID);
|
||||
w = lookup_wchan(pp->XXXID);
|
||||
len = strlen(w);
|
||||
if(len>max_rightward) len=max_rightward;
|
||||
memcpy(outbuf, w, len);
|
||||
@ -741,7 +741,7 @@ static int pr_wname(char *restrict const outbuf, const proc_t *restrict const pp
|
||||
const char *w;
|
||||
size_t len;
|
||||
if(!(pp->wchan & 0xffffff)) return memcpy(outbuf,"-",2),1;
|
||||
w = lookup_wchan(pp->wchan, pp->XXXID);
|
||||
w = lookup_wchan(pp->XXXID);
|
||||
len = strlen(w);
|
||||
if(len>max_rightward) len=max_rightward;
|
||||
memcpy(outbuf, w, len);
|
||||
@ -1396,7 +1396,6 @@ static int pr_t_left2(char *restrict const outbuf, const proc_t *restrict const
|
||||
#define ENV PROC_FILLENV /* read environ */
|
||||
#define USR PROC_FILLUSR /* uid_t -> user names */
|
||||
#define GRP PROC_FILLGRP /* gid_t -> group names */
|
||||
#define WCH PROC_FILLWCHAN /* do WCHAN lookup */
|
||||
#define NS PROC_FILLNS /* read namespace information */
|
||||
#define LXC PROC_FILL_LXC /* value the lxc name field */
|
||||
#ifdef WITH_SYSTEMD
|
||||
@ -1526,7 +1525,7 @@ static const format_struct format_array[] = {
|
||||
{"mntns", "MNTNS", pr_mntns, sr_mntns, 10, NS, LNX, ET|RIGHT},
|
||||
{"msgrcv", "MSGRCV", pr_nop, sr_nop, 6, 0, XXX, AN|RIGHT},
|
||||
{"msgsnd", "MSGSND", pr_nop, sr_nop, 6, 0, XXX, AN|RIGHT},
|
||||
{"mwchan", "MWCHAN", pr_nop, sr_nop, 6, WCH, BSD, TO|WCHAN}, /* mutex (FreeBSD) */
|
||||
{"mwchan", "MWCHAN", pr_nop, sr_nop, 6, 0, BSD, TO|WCHAN}, /* mutex (FreeBSD) */
|
||||
{"netns", "NETNS", pr_netns, sr_netns, 10, NS, LNX, ET|RIGHT},
|
||||
{"ni", "NI", pr_nice, sr_nice, 3, 0, BSD, TO|RIGHT}, /*nice*/
|
||||
{"nice", "NI", pr_nice, sr_nice, 3, 0, U98, TO|RIGHT}, /*ni*/
|
||||
@ -1679,8 +1678,8 @@ static const format_struct format_array[] = {
|
||||
{"vm_stack", "STACK", pr_nop, sr_vm_stack, 5, 0, LNx, PO|RIGHT},
|
||||
{"vsize", "VSZ", pr_vsz, sr_vsize, 6, 0, DEC, PO|RIGHT}, /*vsz*/
|
||||
{"vsz", "VSZ", pr_vsz, sr_vm_size, 6, 0, U98, PO|RIGHT}, /*vsize*/
|
||||
{"wchan", "WCHAN", pr_wchan, sr_wchan, 6, WCH, XXX, TO|WCHAN}, /* BSD n forces this to nwchan */ /* was 10 wide */
|
||||
{"wname", "WCHAN", pr_wname, sr_nop, 6, WCH, SGI, TO|WCHAN}, /* opposite of nwchan */
|
||||
{"wchan", "WCHAN", pr_wchan, sr_wchan, 6, 0, XXX, TO|WCHAN}, /* BSD n forces this to nwchan */ /* was 10 wide */
|
||||
{"wname", "WCHAN", pr_wname, sr_nop, 6, 0, SGI, TO|WCHAN}, /* opposite of nwchan */
|
||||
{"xstat", "XSTAT", pr_nop, sr_nop, 5, 0, BSD, AN|RIGHT},
|
||||
{"zone", "ZONE", pr_context, sr_nop, 31, 0, SUN, ET|LEFT}, // Solaris zone == Linux context?
|
||||
{"zoneid", "ZONEID", pr_nop, sr_nop, 31, 0, SUN, ET|RIGHT},// Linux only offers context names
|
||||
|
12
ps/parser.c
12
ps/parser.c
@ -406,12 +406,6 @@ static const char *parse_sysv_option(void){
|
||||
/* note that AIX shows 2 lines for a normal process */
|
||||
thread_flags |= TF_U_m;
|
||||
break;
|
||||
case 'n': /* end */
|
||||
trace("-n sets namelist file\n");
|
||||
arg=get_opt_arg();
|
||||
if(!arg) return _("alternate System.map file must follow -n");
|
||||
namelist_file = arg;
|
||||
return NULL; /* can't have any more options */
|
||||
case 'o': /* end */
|
||||
/* Unix98 has gross behavior regarding this. From the following: */
|
||||
/* ps -o pid,nice=NICE,tty=TERMINAL,comm */
|
||||
@ -573,12 +567,6 @@ static const char *parse_bsd_option(void){
|
||||
trace("M MacOS X thread display, like AIX/Tru64\n");
|
||||
thread_flags |= TF_B_m;
|
||||
break;
|
||||
case 'N': /* end */
|
||||
trace("N specify namelist file\n");
|
||||
arg=get_opt_arg();
|
||||
if(!arg) return _("alternate System.map file must follow N");
|
||||
namelist_file = arg;
|
||||
return NULL; /* can't have any more options */
|
||||
case 'O': /* end */
|
||||
trace("O like o + defaults, add new columns after PID, also sort\n");
|
||||
arg=get_opt_arg();
|
||||
|
Loading…
Reference in New Issue
Block a user