wchan for multithreaded process is now ~0ull or "*"

This commit is contained in:
albert
2004-07-21 21:17:35 +00:00
parent 9e52b5aa29
commit 266d5b708a
7 changed files with 23 additions and 12 deletions

View File

@@ -109,9 +109,6 @@ typedef struct symb {
unsigned KLONG addr;
} symb;
static const symb fail = { "?", 0 };
static const char dash[] = "-";
/* These mostly rely on POSIX to make them zero. */
static symb hashtable[256];
@@ -602,10 +599,14 @@ static const char * read_wchan_file(unsigned pid){
/***************************************/
static const symb fail = { .name = "?" };
static const char dash[] = "-";
static const char star[] = "*";
#define MAX_OFFSET (0x1000*sizeof(long)) /* past this is generally junk */
/* return pointer to temporary static buffer with function name */
const char * wchan(unsigned KLONG address, unsigned pid) {
const char * lookup_wchan(unsigned KLONG address, unsigned pid) {
const symb *mod_symb;
const symb *map_symb;
const symb *good_symb;
@@ -615,7 +616,8 @@ const char * wchan(unsigned KLONG address, unsigned pid) {
// can't cache it due to a race condition :-(
if(use_wchan_file) return read_wchan_file(pid);
if(!address) return dash;
if(!address) return dash;
if(!~address) return star;
read_and_parse();
hash = (address >> 4) & 0xff; /* got 56/63 hits & 7/63 misses */

View File

@@ -1,3 +1,6 @@
# for --version-script
# WTF is the syntax for this file?
# Give me a BNF, man!
_3_1_14 {
global:
__cyg_profile_func_enter; __cyg_profile_func_exit; main;
@@ -5,7 +8,7 @@ global:
readproc; readtask; readproctab; readproctab2; look_up_our_self; escape_command;
escape_str; escape_strlist;
openproc; closeproc;
tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; wchan;
tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; lookup_wchan;
display_version; procps_version; linux_version_code;
Hertz; smp_num_cpus;
sprint_uptime; uptime; user_from_uid; print_uptime; loadavg;

View File

@@ -521,7 +521,12 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
}
}
/* some number->text resolving which is time consuming */
// if multithreaded, some values are crap
if(p->nlwp > 1){
p->wchan = (KLONG)~0ull;
}
/* some number->text resolving which is time consuming and kind of insane */
if (flags & PROC_FILLUSR){
memcpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
if(flags & PROC_FILLSTATUS) {
@@ -531,7 +536,7 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
}
}
/* some number->text resolving which is time consuming */
/* some number->text resolving which is time consuming and kind of insane */
if (flags & PROC_FILLGRP){
memcpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
if(flags & PROC_FILLSTATUS) {

View File

@@ -5,7 +5,7 @@
EXTERN_C_BEGIN
extern const char * wchan(unsigned KLONG address, unsigned pid);
extern const char * lookup_wchan(unsigned KLONG address, unsigned pid);
extern int open_psdb(const char *restrict override);
extern int open_psdb_message(const char *restrict override, void (*message)(const char *, ...));