Skip to content

Commit

Permalink
Fix debugger build with GDC
Browse files Browse the repository at this point in the history
dd86k committed Aug 11, 2024
1 parent fe6fff9 commit 2e0e7a9
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions common/utils.d
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
/// License: BSD-3-Clause-Clear
module common.utils;

import core.stdc.stdio : sscanf;
import adbg.include.c.stdio : sscanf;
import core.stdc.ctype : isprint;

char hexc0(ubyte upper) {
@@ -143,18 +143,22 @@ unittest {
/// result = Long pointer.
/// str = Input.
/// Returns: True if could not parse number.
bool unformat(int *result, const(char) *str) {
bool parse32(int *result, const(char) *str) {
return sscanf(str, "%i", result) != 1;
}
// Old alias
alias unformat = parse32;

/// Unformat text number.
/// Params:
/// result = Long pointer.
/// str = Input.
/// Returns: True if could not parse number.
bool unformat64(long *result, const(char) *str) {
bool parse64(long *result, const(char) *str) {
return sscanf(str, "%lli", result) != 1;
}
// Old alias
alias unformat64 = parse64;

/// Read entire file into memory using the C FILE API.
///
4 changes: 3 additions & 1 deletion debugger/term.d
Original file line number Diff line number Diff line change
@@ -6,16 +6,18 @@
module term;

import core.stdc.stdlib;
import core.stdc.stdio;
import adbg.include.c.stdio;

//TODO: Consider using PDCurses instead

// NOTE: Functions prefixed with "con" to avoid clashing with the "tc" POSIX stuff

extern (C):

// Avoid some bad definitions.
private int putchar(int);
private int getchar();
private int sscanf(const(char)* format, ...); // GDC specifically

version (Windows) {
private import core.sys.windows.windows;
4 changes: 3 additions & 1 deletion src/adbg/debugger/memory.d
Original file line number Diff line number Diff line change
@@ -572,7 +572,9 @@ LRETRY:

//TODO: Check for (deleted) column (last)
// NOTE: GDC (tested with 11.4) is likely getting the wrong types
// D definitions aliases size_t (%zx) to uint/ulong.
// Affects: Likely GDC 11 and earlier.
// D definitions aliases size_t (%zx) to uint/ulong and
// pointer types aren't properly passed.
if (sscanf(line.ptr, "%zx-%zx %4s %x %x:%x %u %512s",
&range_start, &range_end,
perms.ptr, &offset,

0 comments on commit 2e0e7a9

Please sign in to comment.