From 199264441fb966752d44df546dcb2015f6c273e5 Mon Sep 17 00:00:00 2001 From: Pierre Gimalac Date: Thu, 22 Aug 2024 16:48:31 +0200 Subject: [PATCH] feat: parse StartCode, EndCode, and StartStack in /proc/pid/stat Signed-off-by: Pierre Gimalac --- proc_stat.go | 12 +++++++++--- proc_stat_test.go | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/proc_stat.go b/proc_stat.go index 06a8d931c..3328556bd 100644 --- a/proc_stat.go +++ b/proc_stat.go @@ -101,6 +101,12 @@ type ProcStat struct { RSS int // Soft limit in bytes on the rss of the process. RSSLimit uint64 + // The address above which program text can run. + StartCode uint64 + // The address below which program text can run. + EndCode uint64 + // The address of the start (i.e., bottom) of the stack. + StartStack uint64 // CPU number last executed on. Processor uint // Real-time scheduling priority, a number in the range 1 to 99 for processes @@ -177,9 +183,9 @@ func (p Proc) Stat() (ProcStat, error) { &s.VSize, &s.RSS, &s.RSSLimit, - &ignoreUint64, - &ignoreUint64, - &ignoreUint64, + &s.StartCode, + &s.EndCode, + &s.StartStack, &ignoreUint64, &ignoreUint64, &ignoreUint64, diff --git a/proc_stat_test.go b/proc_stat_test.go index 8abd67f60..6cfa1cc42 100644 --- a/proc_stat_test.go +++ b/proc_stat_test.go @@ -55,6 +55,9 @@ func TestProcStat(t *testing.T) { have uint64 }{ {name: "RSS Limit", want: 18446744073709551615, have: s.RSSLimit}, + {name: "Start Code", want: 4194304, have: s.StartCode}, + {name: "End Code", want: 6294284, have: s.EndCode}, + {name: "Start Stack", want: 140736914091744, have: s.StartStack}, {name: "delayacct_blkio_ticks", want: 31, have: s.DelayAcctBlkIOTicks}, } { if test.want != test.have {