Skip to content

Commit

Permalink
make AdbgRegFormat enum
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Mar 10, 2024
1 parent 9b6e7a0 commit 53fda43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/shell.d
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@ int command_regs(int argc, const(char) **argv) {
bool show = rselect == null || strcmp(rselect, reg.info.name) == 0;
if (show == false) continue;
char[20] normal = void, hexdec = void;
adbg_register_format(normal.ptr, 20, reg, FORMAT_DEC);
adbg_register_format(hexdec.ptr, 20, reg, FORMAT_HEXPADDED);
adbg_register_format(normal.ptr, 20, reg, AdbgRegFormat.dec);
adbg_register_format(hexdec.ptr, 20, reg, AdbgRegFormat.hexPadded);
printf("%-8s 0x%8s %s\n", reg.info.name, hexdec.ptr, normal.ptr);
found = true;
}
Expand Down
20 changes: 10 additions & 10 deletions src/adbg/debugger/thread.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ enum AdbgRegType : ubyte {
f32, f64
}

//TODO: Rename to AdbgRegFormat
enum {
FORMAT_DEC,
FORMAT_HEX,
FORMAT_HEXPADDED,
/// Register
enum AdbgRegFormat {
dec,
hex,
hexPadded,
}

/// Register name and type.
Expand Down Expand Up @@ -232,13 +232,13 @@ version (Windows) {
/// reg = Register.
/// format = String format.
/// Returns: Number of characters written.
size_t adbg_register_format(char *buffer, size_t len, adbg_register_t *reg, int format) {
size_t adbg_register_format(char *buffer, size_t len, adbg_register_t *reg, AdbgRegFormat format) {
if (reg == null || buffer == null || len == 0)
return 0;

const(char) *sformat = void;
switch (format) {
case FORMAT_DEC:
switch (format) with (AdbgRegFormat) {
case dec:
switch (reg.info.type) with (AdbgRegType) {
case u8, u16, u32, u64:
sformat = "%llu"; break;
Expand All @@ -249,10 +249,10 @@ size_t adbg_register_format(char *buffer, size_t len, adbg_register_t *reg, int
return 0;
}
break;
case FORMAT_HEX:
case hex:
sformat = "%llx";
break;
case FORMAT_HEXPADDED:
case hexPadded:
switch (reg.info.type) with (AdbgRegType) {
case u8: sformat = "%02x"; break;
case u16: sformat = "%04x"; break;
Expand Down

0 comments on commit 53fda43

Please sign in to comment.