From 1b805a31720727008b32b1129a167758519fd4db Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 2 May 2022 16:04:21 +0200 Subject: New upstream version 3.2.0 --- freebsd/FreeBSDProcess.c | 11 +++++++++-- freebsd/FreeBSDProcess.h | 1 + freebsd/FreeBSDProcessList.c | 8 +++++++- freebsd/Platform.c | 9 ++++++++- freebsd/Platform.h | 4 +++- freebsd/ProcessField.h | 5 +++-- 6 files changed, 31 insertions(+), 7 deletions(-) (limited to 'freebsd') diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c index 345edff..2746540 100644 --- a/freebsd/FreeBSDProcess.c +++ b/freebsd/FreeBSDProcess.c @@ -37,8 +37,8 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, }, [M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, }, [ST_UID] = { .name = "ST_UID", .title = "UID", .description = "User ID of the process owner", .flags = 0, }, - [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, }, - [PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, .defaultSortDesc = true, }, + [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, .autoWidth = true, }, + [PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, .defaultSortDesc = true, .autoWidth = true, }, [PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, .defaultSortDesc = true, }, [USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, }, [TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, .defaultSortDesc = true, }, @@ -49,6 +49,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [CWD] = { .name = "CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_CWD, }, [JID] = { .name = "JID", .title = "JID", .description = "Jail prison ID", .flags = 0, .pidColumn = true, }, [JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, }, + [EMULATION] = { .name = "EMULATION", .title = "EMULATION ", .description = "System call emulation environment (ABI)", .flags = 0, }, }; Process* FreeBSDProcess_new(const Settings* settings) { @@ -61,6 +62,7 @@ Process* FreeBSDProcess_new(const Settings* settings) { void Process_delete(Object* cast) { FreeBSDProcess* this = (FreeBSDProcess*) cast; Process_done((Process*)cast); + free(this->emul); free(this->jname); free(this); } @@ -77,6 +79,9 @@ static void FreeBSDProcess_writeField(const Process* this, RichString* str, Proc case JAIL: Process_printLeftAlignedField(str, attr, fp->jname ? fp->jname : "N/A", 11); return; + case EMULATION: + Process_printLeftAlignedField(str, attr, fp->emul ? fp->emul : "N/A", 16); + return; default: Process_writeField(this, str, field); return; @@ -94,6 +99,8 @@ static int FreeBSDProcess_compareByKey(const Process* v1, const Process* v2, Pro return SPACESHIP_NUMBER(p1->jid, p2->jid); case JAIL: return SPACESHIP_NULLSTR(p1->jname, p2->jname); + case EMULATION: + return SPACESHIP_NULLSTR(p1->emul, p2->emul); default: return Process_compareByKey_Base(v1, v2, key); } diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h index 2443f89..654f9cf 100644 --- a/freebsd/FreeBSDProcess.h +++ b/freebsd/FreeBSDProcess.h @@ -18,6 +18,7 @@ typedef struct FreeBSDProcess_ { Process super; int jid; char* jname; + char* emul; } FreeBSDProcess; extern const ProcessClass FreeBSDProcess_class; diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 507f480..f58f338 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -509,6 +509,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { proc->pgrp = kproc->ki_pgid; proc->st_uid = kproc->ki_uid; proc->starttime_ctime = kproc->ki_start.tv_sec; + if (proc->starttime_ctime < 0) { + proc->starttime_ctime = super->realtimeMs / 1000; + } Process_fillStarttimeBuffer(proc); proc->user = UsersTable_getRef(super->usersTable, proc->st_uid); ProcessList_add(super, proc); @@ -516,7 +519,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { FreeBSDProcessList_updateExe(kproc, proc); FreeBSDProcessList_updateProcessName(fpl->kd, kproc, proc); - if (settings->flags & PROCESS_FLAG_CWD) { + if (settings->ss->flags & PROCESS_FLAG_CWD) { FreeBSDProcessList_updateCwd(kproc, proc); } @@ -549,6 +552,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { } } + free_and_xStrdup(&fp->emul, kproc->ki_emul); + // from FreeBSD source /src/usr.bin/top/machine.c proc->m_virt = kproc->ki_size / ONE_K; proc->m_resident = kproc->ki_rssize * pageSizeKb; @@ -557,6 +562,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { proc->percent_cpu = 100.0 * ((double)kproc->ki_pctcpu / (double)kernelFScale); proc->percent_mem = 100.0 * proc->m_resident / (double)(super->totalMem); + Process_updateCPUFieldWidths(proc->percent_cpu); if (kproc->ki_stat == SRUN && kproc->ki_oncpu != NOCPU) { proc->processor = kproc->ki_oncpu; diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 6c82bc2..d21fc80 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -50,8 +50,15 @@ in the source distribution for its full text. #include "zfs/ZfsArcMeter.h" #include "zfs/ZfsCompressedArcMeter.h" +const ScreenDefaults Platform_defaultScreens[] = { + { + .name = "Main", + .columns = "PID USER PRIORITY NICE M_VIRT M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command", + .sortKey = "PERCENT_CPU", + }, +}; -const ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; +const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); const SignalItem Platform_signals[] = { { .name = " 0 Cancel", .number = 0 }, diff --git a/freebsd/Platform.h b/freebsd/Platform.h index a1aa31b..c0292d9 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -25,7 +25,9 @@ in the source distribution for its full text. #include "generic/uname.h" -extern const ProcessField Platform_defaultFields[]; +extern const ScreenDefaults Platform_defaultScreens[]; + +extern const unsigned int Platform_numberOfDefaultScreens; extern const SignalItem Platform_signals[]; diff --git a/freebsd/ProcessField.h b/freebsd/ProcessField.h index 8ed2746..d20900d 100644 --- a/freebsd/ProcessField.h +++ b/freebsd/ProcessField.h @@ -9,8 +9,9 @@ in the source distribution for its full text. #define PLATFORM_PROCESS_FIELDS \ - JID = 100, \ - JAIL = 101, \ + JID = 100, \ + JAIL = 101, \ + EMULATION = 102, \ \ DUMMY_BUMP_FIELD = CWD, \ // End of list -- cgit v1.2.3