kdump: Decode cpuset_t.
Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D34982 MFC after: 2 weeks
This commit is contained in:
parent
c8b5c478f6
commit
586ed32106
@ -34,6 +34,7 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
|
#include "opt_ktrace.h"
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -61,6 +62,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
#include <sys/interrupt.h>
|
#include <sys/interrupt.h>
|
||||||
#include <sys/vmmeter.h>
|
#include <sys/vmmeter.h>
|
||||||
|
#include <sys/ktrace.h>
|
||||||
|
|
||||||
#include <vm/uma.h>
|
#include <vm/uma.h>
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
@ -1995,6 +1997,10 @@ kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef KTRACE
|
||||||
|
if ( KTRPOINT(td, KTR_STRUCT))
|
||||||
|
ktrcpuset(mask, size);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
free(mask, M_TEMP);
|
free(mask, M_TEMP);
|
||||||
@ -2028,6 +2034,10 @@ kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
|||||||
struct proc *p;
|
struct proc *p;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
#ifdef KTRACE
|
||||||
|
if (KTRPOINT(td, KTR_STRUCT))
|
||||||
|
ktrcpuset(mask, sizeof(cpuset_t));
|
||||||
|
#endif
|
||||||
error = cpuset_check_capabilities(td, level, which, id);
|
error = cpuset_check_capabilities(td, level, which, id);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -307,6 +307,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *,
|
|||||||
ktrstruct("stat", (s), sizeof(struct stat))
|
ktrstruct("stat", (s), sizeof(struct stat))
|
||||||
#define ktrstat_error(s, error) \
|
#define ktrstat_error(s, error) \
|
||||||
ktrstruct_error("stat", (s), sizeof(struct stat), error)
|
ktrstruct_error("stat", (s), sizeof(struct stat), error)
|
||||||
|
#define ktrcpuset(s, l) \
|
||||||
|
ktrstruct("cpuset_t", (s), l)
|
||||||
extern u_int ktr_geniosize;
|
extern u_int ktr_geniosize;
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
extern int ktr_filesize_limit_signal;
|
extern int ktr_filesize_limit_signal;
|
||||||
|
@ -48,8 +48,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define _WANT_KEVENT32
|
#define _WANT_KEVENT32
|
||||||
#endif
|
#endif
|
||||||
#define _WANT_FREEBSD11_KEVENT
|
#define _WANT_FREEBSD11_KEVENT
|
||||||
|
#define _WANT_FREEBSD_BITSET
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
|
#include <sys/_bitset.h>
|
||||||
|
#include <sys/bitset.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@ -119,6 +122,7 @@ void ktrfault(struct ktr_fault *);
|
|||||||
void ktrfaultend(struct ktr_faultend *);
|
void ktrfaultend(struct ktr_faultend *);
|
||||||
void ktrkevent(struct kevent *);
|
void ktrkevent(struct kevent *);
|
||||||
void ktrstructarray(struct ktr_struct_array *, size_t);
|
void ktrstructarray(struct ktr_struct_array *, size_t);
|
||||||
|
void ktrbitset(char *, struct bitset *, size_t);
|
||||||
void usage(void);
|
void usage(void);
|
||||||
|
|
||||||
#define TIMESTAMP_NONE 0x0
|
#define TIMESTAMP_NONE 0x0
|
||||||
@ -1967,6 +1971,30 @@ ktrstat(struct stat *statp)
|
|||||||
printf(" }\n");
|
printf(" }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ktrbitset(char *name, struct bitset *set, size_t setlen)
|
||||||
|
{
|
||||||
|
int i, maxi, c = 0;
|
||||||
|
|
||||||
|
if (setlen > INT32_MAX)
|
||||||
|
setlen = INT32_MAX;
|
||||||
|
maxi = setlen * CHAR_BIT;
|
||||||
|
printf("%s [ ", name);
|
||||||
|
for (i = 0; i < maxi; i++) {
|
||||||
|
if (!BIT_ISSET(setlen, i, set))
|
||||||
|
continue;
|
||||||
|
if (c == 0)
|
||||||
|
printf("%d", i);
|
||||||
|
else
|
||||||
|
printf(", %d", i);
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
if (c == 0)
|
||||||
|
printf(" empty ]\n");
|
||||||
|
else
|
||||||
|
printf(" ]\n");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ktrstruct(char *buf, size_t buflen)
|
ktrstruct(char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
@ -1977,6 +2005,7 @@ ktrstruct(char *buf, size_t buflen)
|
|||||||
struct itimerval it;
|
struct itimerval it;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
|
struct bitset *set;
|
||||||
|
|
||||||
for (name = buf, namelen = 0;
|
for (name = buf, namelen = 0;
|
||||||
namelen < buflen && name[namelen] != '\0';
|
namelen < buflen && name[namelen] != '\0';
|
||||||
@ -1992,7 +2021,7 @@ ktrstruct(char *buf, size_t buflen)
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
for (i = 0; i < (int)namelen; ++i)
|
for (i = 0; i < (int)namelen; ++i)
|
||||||
if (!isalpha(name[i]))
|
if (!isalpha(name[i]) && name[i] != '_')
|
||||||
goto invalid;
|
goto invalid;
|
||||||
if (strcmp(name, "caprights") == 0) {
|
if (strcmp(name, "caprights") == 0) {
|
||||||
if (datalen != sizeof(cap_rights_t))
|
if (datalen != sizeof(cap_rights_t))
|
||||||
@ -2016,6 +2045,15 @@ ktrstruct(char *buf, size_t buflen)
|
|||||||
if (datalen != ss.ss_len)
|
if (datalen != ss.ss_len)
|
||||||
goto invalid;
|
goto invalid;
|
||||||
ktrsockaddr((struct sockaddr *)&ss);
|
ktrsockaddr((struct sockaddr *)&ss);
|
||||||
|
} else if (strcmp(name, "cpuset_t") == 0) {
|
||||||
|
if (datalen < 1)
|
||||||
|
goto invalid;
|
||||||
|
set = malloc(datalen);
|
||||||
|
if (set == NULL)
|
||||||
|
errx(1, "%s", strerror(ENOMEM));
|
||||||
|
memcpy(set, data, datalen);
|
||||||
|
ktrbitset(name, set, datalen);
|
||||||
|
free(set);
|
||||||
} else {
|
} else {
|
||||||
printf("unknown structure\n");
|
printf("unknown structure\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user