mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Re-arrange and consolidate some random debugging stuff
This commit is contained in:
parent
4d4a286cba
commit
774114995e
6 changed files with 61 additions and 53 deletions
|
|
@ -64,7 +64,6 @@ static int udf_strategy(struct vop_strategy_args *);
|
|||
static int udf_bmap(struct vop_bmap_args *);
|
||||
static int udf_lookup(struct vop_cachedlookup_args *);
|
||||
static int udf_reclaim(struct vop_reclaim_args *);
|
||||
static void udf_dumpblock(void *, int) __unused;
|
||||
static int udf_readatoffset(struct udf_node *, int *, int, struct buf **, uint8_t **);
|
||||
static int udf_bmap_internal(struct udf_node *, uint32_t, daddr_t *, uint32_t *);
|
||||
|
||||
|
|
@ -429,24 +428,6 @@ udf_read(struct vop_read_args *a)
|
|||
return (error);
|
||||
}
|
||||
|
||||
/* Convienience routine to dump a block in hex */
|
||||
static void
|
||||
udf_dumpblock(void *data, int len)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("\noffset= %d: ", i);
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (i + j == len)
|
||||
break;
|
||||
printf("0x%02x ", (uint8_t)((uint8_t*)(data))[i + j]);
|
||||
}
|
||||
i += j - 1;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Call the OSTA routines to translate the name from a CS0 dstring to a
|
||||
* 16-bit Unicode String. Hooks need to be placed in here to translate from
|
||||
|
|
@ -758,7 +739,7 @@ udf_readdir(struct vop_readdir_args *a)
|
|||
/* XXX Should we return an error on a bad fid? */
|
||||
if (udf_checktag(&fid->tag, TAGID_FID)) {
|
||||
printf("Invalid FID tag\n");
|
||||
udf_dumpblock(fid, UDF_FID_SIZE);
|
||||
hexdump(fid, UDF_FID_SIZE, NULL, 0);
|
||||
error = EIO;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,6 @@ void g_dev_print(void);
|
|||
struct g_provider *g_dev_getprovider(dev_t dev);
|
||||
|
||||
/* geom_dump.c */
|
||||
void g_hexdump(void *ptr, int length);
|
||||
void g_trace(int level, const char *, ...);
|
||||
# define G_T_TOPOLOGY 1
|
||||
# define G_T_BIO 2
|
||||
|
|
|
|||
|
|
@ -281,34 +281,3 @@ g_trace(int level, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
g_hexdump(void *ptr, int length)
|
||||
{
|
||||
int i, j, k;
|
||||
unsigned char *cp;
|
||||
|
||||
cp = ptr;
|
||||
for (i = 0; i < length; i+= 16) {
|
||||
printf("%04x ", i);
|
||||
for (j = 0; j < 16; j++) {
|
||||
k = i + j;
|
||||
if (k < length)
|
||||
printf(" %02x", cp[k]);
|
||||
else
|
||||
printf(" ");
|
||||
}
|
||||
printf(" |");
|
||||
for (j = 0; j < 16; j++) {
|
||||
k = i + j;
|
||||
if (k >= length)
|
||||
printf(" ");
|
||||
else if (cp[k] >= ' ' && cp[k] <= '~')
|
||||
printf("%c", cp[k]);
|
||||
else
|
||||
printf(".");
|
||||
}
|
||||
printf("|\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ g_pc98_print(int i, struct pc98_partition *dp)
|
|||
strncpy(sname, dp->dp_name, 16);
|
||||
sname[16] = '\0';
|
||||
|
||||
g_hexdump(dp, sizeof(dp[0]));
|
||||
hexdump(dp, sizeof(dp[0]), NULL, 0);
|
||||
printf("[%d] mid:%d(0x%x) sid:%d(0x%x)",
|
||||
i, dp->dp_mid, dp->dp_mid, dp->dp_sid, dp->dp_sid);
|
||||
printf(" s:%d/%d/%d", dp->dp_scyl, dp->dp_shd, dp->dp_ssect);
|
||||
|
|
|
|||
|
|
@ -898,3 +898,56 @@ DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
|
|||
}
|
||||
|
||||
#endif /* DDB */
|
||||
|
||||
void
|
||||
hexdump(void *ptr, int length, const char *hdr, int flags)
|
||||
{
|
||||
int i, j, k;
|
||||
int cols;
|
||||
unsigned char *cp;
|
||||
char delim;
|
||||
|
||||
if ((flags & HD_DELIM_MASK) != 0)
|
||||
delim = (flags & HD_DELIM_MASK) >> 8;
|
||||
else
|
||||
delim = ' ';
|
||||
|
||||
if ((flags & HD_COLUMN_MASK) != 0)
|
||||
cols = flags & HD_COLUMN_MASK;
|
||||
else
|
||||
cols = 16;
|
||||
|
||||
cp = ptr;
|
||||
for (i = 0; i < length; i+= cols) {
|
||||
if (hdr != NULL)
|
||||
printf("%s", hdr);
|
||||
|
||||
if ((flags & HD_OMIT_COUNT) == 0)
|
||||
printf("%04x ", i);
|
||||
|
||||
if ((flags & HD_OMIT_HEX) == 0) {
|
||||
for (j = 0; j < cols; j++) {
|
||||
k = i + j;
|
||||
if (k < length)
|
||||
printf("%c%02x", delim, cp[k]);
|
||||
else
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & HD_OMIT_CHARS) == 0) {
|
||||
printf(" |");
|
||||
for (j = 0; j < cols; j++) {
|
||||
k = i + j;
|
||||
if (k >= length)
|
||||
printf(" ");
|
||||
else if (cp[k] >= ' ' && cp[k] <= '~')
|
||||
printf("%c", cp[k]);
|
||||
else
|
||||
printf(".");
|
||||
}
|
||||
printf("|\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,12 @@ u_long strtoul(const char *, char **, int) __nonnull(1);
|
|||
quad_t strtoq(const char *, char **, int) __nonnull(1);
|
||||
u_quad_t strtouq(const char *, char **, int) __nonnull(1);
|
||||
void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
|
||||
void hexdump(void *ptr, int length, const char *hdr, int flags);
|
||||
#define HD_COLUMN_MASK 0xff
|
||||
#define HD_DELIM_MASK 0xff00
|
||||
#define HD_OMIT_COUNT (1 << 16)
|
||||
#define HD_OMIT_HEX (1 << 17)
|
||||
#define HD_OMIT_CHARS (1 << 18)
|
||||
|
||||
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
|
||||
void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
|
||||
|
|
|
|||
Loading…
Reference in a new issue