diff options
author | John Baldwin <jhb@FreeBSD.org> | 2021-08-30 11:08:38 -0700 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2021-08-30 11:08:38 -0700 |
commit | 6fc590e1f5e43a7ea7d466c18ebb97515baa497f (patch) | |
tree | 52654cfeddfe73f5f58803802a6f702a67838d6f /gdb/fbsd-nat.c | |
parent | 00894ecf4636a242fbd11536acdf50f7891b374a (diff) | |
download | gdb-6fc590e1f5e43a7ea7d466c18ebb97515baa497f.zip gdb-6fc590e1f5e43a7ea7d466c18ebb97515baa497f.tar.gz gdb-6fc590e1f5e43a7ea7d466c18ebb97515baa497f.tar.bz2 |
fbsd-nat: Don't use '%jd' and '%ju' with printf_filtered.
The handler for 'info proc status' for native processes on FreeBSD
uses the 'j' size modifier along with uintmax_t / intmax_t casts to
output integer values for types such as off_t that are not aliases of
a basic C type such as 'int' or 'long'. printf_filtered does not
support the 'j' modifer, so this resulted in runtime errors in
practice:
(gdb) info proc stat
process 8674
Name: ls
State: T (stopped)
Parent process: 8673
Process group: 8674
Session id: 2779
Unrecognized format specifier 'j' in printf
Instead, use plongest and pulongest to generate the output strings of
these integer values.
Diffstat (limited to 'gdb/fbsd-nat.c')
-rw-r--r-- | gdb/fbsd-nat.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 4b2d01f..e0ab3f0 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -365,7 +365,7 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what) printf_filtered ("Parent process: %d\n", kp.ki_ppid); printf_filtered ("Process group: %d\n", kp.ki_pgid); printf_filtered ("Session id: %d\n", kp.ki_sid); - printf_filtered ("TTY: %ju\n", (uintmax_t) kp.ki_tdev); + printf_filtered ("TTY: %s\n", pulongest (kp.ki_tdev)); printf_filtered ("TTY owner process group: %d\n", kp.ki_tpgid); printf_filtered ("User IDs (real, effective, saved): %d %d %d\n", kp.ki_ruid, kp.ki_uid, kp.ki_svuid); @@ -383,34 +383,35 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what) kp.ki_rusage.ru_majflt); printf_filtered ("Major faults, children: %ld\n", kp.ki_rusage_ch.ru_majflt); - printf_filtered ("utime: %jd.%06ld\n", - (intmax_t) kp.ki_rusage.ru_utime.tv_sec, + printf_filtered ("utime: %s.%06ld\n", + plongest (kp.ki_rusage.ru_utime.tv_sec), kp.ki_rusage.ru_utime.tv_usec); - printf_filtered ("stime: %jd.%06ld\n", - (intmax_t) kp.ki_rusage.ru_stime.tv_sec, + printf_filtered ("stime: %s.%06ld\n", + plongest (kp.ki_rusage.ru_stime.tv_sec), kp.ki_rusage.ru_stime.tv_usec); - printf_filtered ("utime, children: %jd.%06ld\n", - (intmax_t) kp.ki_rusage_ch.ru_utime.tv_sec, + printf_filtered ("utime, children: %s.%06ld\n", + plongest (kp.ki_rusage_ch.ru_utime.tv_sec), kp.ki_rusage_ch.ru_utime.tv_usec); - printf_filtered ("stime, children: %jd.%06ld\n", - (intmax_t) kp.ki_rusage_ch.ru_stime.tv_sec, + printf_filtered ("stime, children: %s.%06ld\n", + plongest (kp.ki_rusage_ch.ru_stime.tv_sec), kp.ki_rusage_ch.ru_stime.tv_usec); printf_filtered ("'nice' value: %d\n", kp.ki_nice); - printf_filtered ("Start time: %jd.%06ld\n", kp.ki_start.tv_sec, + printf_filtered ("Start time: %s.%06ld\n", + plongest (kp.ki_start.tv_sec), kp.ki_start.tv_usec); pgtok = getpagesize () / 1024; - printf_filtered ("Virtual memory size: %ju kB\n", - (uintmax_t) kp.ki_size / 1024); - printf_filtered ("Data size: %ju kB\n", - (uintmax_t) kp.ki_dsize * pgtok); - printf_filtered ("Stack size: %ju kB\n", - (uintmax_t) kp.ki_ssize * pgtok); - printf_filtered ("Text size: %ju kB\n", - (uintmax_t) kp.ki_tsize * pgtok); - printf_filtered ("Resident set size: %ju kB\n", - (uintmax_t) kp.ki_rssize * pgtok); - printf_filtered ("Maximum RSS: %ju kB\n", - (uintmax_t) kp.ki_rusage.ru_maxrss); + printf_filtered ("Virtual memory size: %s kB\n", + pulongest (kp.ki_size / 1024)); + printf_filtered ("Data size: %s kB\n", + pulongest (kp.ki_dsize * pgtok)); + printf_filtered ("Stack size: %s kB\n", + pulongest (kp.ki_ssize * pgtok)); + printf_filtered ("Text size: %s kB\n", + pulongest (kp.ki_tsize * pgtok)); + printf_filtered ("Resident set size: %s kB\n", + pulongest (kp.ki_rssize * pgtok)); + printf_filtered ("Maximum RSS: %s kB\n", + pulongest (kp.ki_rusage.ru_maxrss)); printf_filtered ("Pending Signals: "); for (int i = 0; i < _SIG_WORDS; i++) printf_filtered ("%08x ", kp.ki_siglist.__bits[i]); |