Changeset View
Standalone View
usr.sbin/bhyve/gdb.c
Show All 26 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#endif | #endif | ||||
#include <sys/endian.h> | |||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <machine/atomic.h> | #include <machine/atomic.h> | ||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
▲ Show 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | while (len > 0) { | ||||
v <<= 4; | v <<= 4; | ||||
v |= parse_digit(*p); | v |= parse_digit(*p); | ||||
p++; | p++; | ||||
len--; | len--; | ||||
} | } | ||||
return (v); | return (v); | ||||
} | } | ||||
static uint8_t | static uint8_t | ||||
cem: Oh, I guess I'd say please use "unsigned" in new code, if you go this route. | |||||
Not Done Inline ActionsI would tend to agree. Also, we have many examples of both static unsigned and static unsigned int. Probably good to document our preference in style.9. emaste: I would tend to agree.
Also, we have many examples of both `static unsigned` and `static… | |||||
Not Done Inline ActionsI'd rather leave unsigned vs unsigned int unspecified in style(9), because I prefer the shorter form and I'm not sure that's the majority opinion ¯\_(ツ)_/¯. cem: I'd rather leave `unsigned` vs `unsigned int` unspecified in style(9), because I prefer the… | |||||
Done Inline ActionsSo bhyve itself is already split between u_int vs 'unsigned foo'. However, this file already uses both 'unsigned int' and 'unsigned char', so 'unsigned int' is probably most consistent within the file. Looking in sys/sys/*, a bare unsigned is generally unused. jhb: So bhyve itself is already split between u_int vs 'unsigned foo'. However, this file already… | |||||
parse_byte(const uint8_t *p) | parse_byte(const uint8_t *p) | ||||
{ | { | ||||
return (parse_digit(p[0]) << 4 | parse_digit(p[1])); | return (parse_digit(p[0]) << 4 | parse_digit(p[1])); | ||||
} | } | ||||
static void | static void | ||||
send_pending_data(int fd) | send_pending_data(int fd) | ||||
▲ Show 20 Lines • Show All 542 Lines • ▼ Show 20 Lines | if (cp != NULL) { | ||||
* aligned writes of words when possible. | * aligned writes of words when possible. | ||||
*/ | */ | ||||
while (todo > 0) { | while (todo > 0) { | ||||
if (gpa & 1 || todo == 1) { | if (gpa & 1 || todo == 1) { | ||||
bytes = 1; | bytes = 1; | ||||
val = parse_byte(data); | val = parse_byte(data); | ||||
} else if (gpa & 2 || todo == 2) { | } else if (gpa & 2 || todo == 2) { | ||||
bytes = 2; | bytes = 2; | ||||
val = parse_byte(data) | | val = be16toh(parse_integer(data, 4)); | ||||
(parse_byte(data + 2) << 8); | |||||
} else { | } else { | ||||
bytes = 4; | bytes = 4; | ||||
val = parse_byte(data) | | val = be32toh(parse_integer(data, 8)); | ||||
cemUnsubmitted Not Done Inline ActionsMaybe just be32dec() and be16dec()? cem: Maybe just be32dec() and be16dec()? | |||||
jhbAuthorUnsubmitted Done Inline ActionsThe data are not binary, but ASCII hex, so parse_integer is doing a loop of parse_byte with shifts, but it assumes it is parsing BE data (as GDB's protocol sends integer values in BE). As such, I can't use the *dec routines directly. jhb: The data are not binary, but ASCII hex, so parse_integer is doing a loop of parse_byte with… | |||||
cemUnsubmitted Not Done Inline ActionsAh, ok. sscanf(data, "%08lx", &ulong); be32toh() then? :) I'm just joking around, it's fine as is. cem: Ah, ok. `sscanf(data, "%08lx", &ulong); be32toh()` then? :) I'm just joking around, it's fine… | |||||
(parse_byte(data + 2) << 8) | | |||||
(parse_byte(data + 4) << 16) | | |||||
(parse_byte(data + 6) << 24); | |||||
} | } | ||||
error = write_mem(ctx, cur_vcpu, gpa, val, | error = write_mem(ctx, cur_vcpu, gpa, val, | ||||
bytes); | bytes); | ||||
if (error == 0) { | if (error == 0) { | ||||
gpa += bytes; | gpa += bytes; | ||||
gva += bytes; | gva += bytes; | ||||
resid -= bytes; | resid -= bytes; | ||||
todo -= bytes; | todo -= bytes; | ||||
▲ Show 20 Lines • Show All 528 Lines • Show Last 20 Lines |
Oh, I guess I'd say please use "unsigned" in new code, if you go this route.