Changeset View
Standalone View
usr.sbin/bhyve/gdb.c
Show First 20 Lines • Show All 388 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 u_int | ||||
cem: Oh, I guess I'd say please use "unsigned" in new code, if you go this route. | |||||
emasteUnsubmitted 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… | |||||
cemUnsubmitted 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… | |||||
jhbAuthorUnsubmitted 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 543 Lines • ▼ Show 20 Lines | if (cp != NULL) { | ||||
*/ | */ | ||||
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 = parse_byte(data) | | ||||
(parse_byte(data + 2) << 8); | (parse_byte(data + 2) << 8); | ||||
} else { | } else { | ||||
bytes = 4; | bytes = 4; | ||||
val = parse_byte(data) | | val = parse_byte(data) | | ||||
(parse_byte(data + 2) << 8) | | (parse_byte(data + 2) << 8) | | ||||
(parse_byte(data + 4) << 16) | | (parse_byte(data + 4) << 16) | | ||||
(parse_byte(data + 6) << 24); | (parse_byte(data + 6) << 24); | ||||
Not Done Inline ActionsMaybe just be32dec() and be16dec()? cem: Maybe just be32dec() and be16dec()? | |||||
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… | |||||
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… | |||||
} | } | ||||
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.