gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t
Pass %x as uint32_t and %lx as uint64_t; pass the address of %s as uint64_t and the length as uint32_t. Add casts in semihosting/syscalls.c from target_ulong to uint64_t; add casts from int to uint32_t for clarity. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230303025805.625589-28-richard.henderson@linaro.org>
This commit is contained in:
parent
2f70f2d791
commit
0820a075af
@ -110,14 +110,14 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
|
|||||||
*(p++) = 'F';
|
*(p++) = 'F';
|
||||||
while (*fmt) {
|
while (*fmt) {
|
||||||
if (*fmt == '%') {
|
if (*fmt == '%') {
|
||||||
target_ulong addr;
|
|
||||||
uint64_t i64;
|
uint64_t i64;
|
||||||
|
uint32_t i32;
|
||||||
|
|
||||||
fmt++;
|
fmt++;
|
||||||
switch (*fmt++) {
|
switch (*fmt++) {
|
||||||
case 'x':
|
case 'x':
|
||||||
addr = va_arg(va, target_ulong);
|
i32 = va_arg(va, uint32_t);
|
||||||
p += snprintf(p, p_end - p, TARGET_FMT_lx, addr);
|
p += snprintf(p, p_end - p, "%" PRIx32, i32);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (*(fmt++) != 'x') {
|
if (*(fmt++) != 'x') {
|
||||||
@ -127,9 +127,9 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
|
|||||||
p += snprintf(p, p_end - p, "%" PRIx64, i64);
|
p += snprintf(p, p_end - p, "%" PRIx64, i64);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
addr = va_arg(va, target_ulong);
|
i64 = va_arg(va, uint64_t);
|
||||||
p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x",
|
i32 = va_arg(va, uint32_t);
|
||||||
addr, va_arg(va, int));
|
p += snprintf(p, p_end - p, "%" PRIx64 "/%x" PRIx32, i64, i32);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bad_format:
|
bad_format:
|
||||||
|
@ -139,46 +139,48 @@ static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete,
|
|||||||
|
|
||||||
gdb_open_complete = complete;
|
gdb_open_complete = complete;
|
||||||
gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x",
|
gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x",
|
||||||
fname, len, (target_ulong)gdb_flags, (target_ulong)mode);
|
(uint64_t)fname, (uint32_t)len,
|
||||||
|
(uint32_t)gdb_flags, (uint32_t)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf)
|
GuestFD *gf)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "close,%x", (target_ulong)gf->hostfd);
|
gdb_do_syscall(complete, "close,%x", (uint32_t)gf->hostfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf, target_ulong buf, target_ulong len)
|
GuestFD *gf, target_ulong buf, target_ulong len)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "read,%x,%x,%x",
|
gdb_do_syscall(complete, "read,%x,%lx,%lx",
|
||||||
(target_ulong)gf->hostfd, buf, len);
|
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf, target_ulong buf, target_ulong len)
|
GuestFD *gf, target_ulong buf, target_ulong len)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "write,%x,%x,%x",
|
gdb_do_syscall(complete, "write,%x,%lx,%lx",
|
||||||
(target_ulong)gf->hostfd, buf, len);
|
(uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf, int64_t off, int gdb_whence)
|
GuestFD *gf, int64_t off, int gdb_whence)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "lseek,%x,%lx,%x",
|
gdb_do_syscall(complete, "lseek,%x,%lx,%x",
|
||||||
(target_ulong)gf->hostfd, off, (target_ulong)gdb_whence);
|
(uint32_t)gf->hostfd, off, (uint32_t)gdb_whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf)
|
GuestFD *gf)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "isatty,%x", (target_ulong)gf->hostfd);
|
gdb_do_syscall(complete, "isatty,%x", (uint32_t)gf->hostfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
GuestFD *gf, target_ulong addr)
|
GuestFD *gf, target_ulong addr)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "fstat,%x,%x", (target_ulong)gf->hostfd, addr);
|
gdb_do_syscall(complete, "fstat,%x,%lx",
|
||||||
|
(uint32_t)gf->hostfd, (uint64_t)addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
@ -191,7 +193,8 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_do_syscall(complete, "stat,%s,%x", fname, len, addr);
|
gdb_do_syscall(complete, "stat,%s,%lx",
|
||||||
|
(uint64_t)fname, (uint32_t)len, (uint64_t)addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
@ -203,7 +206,7 @@ static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_do_syscall(complete, "unlink,%s", fname, len);
|
gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
@ -223,7 +226,9 @@ static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_do_syscall(complete, "rename,%s,%s", oname, olen, nname, nlen);
|
gdb_do_syscall(complete, "rename,%s,%s",
|
||||||
|
(uint64_t)oname, (uint32_t)olen,
|
||||||
|
(uint64_t)nname, (uint32_t)nlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
@ -235,13 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_do_syscall(complete, "system,%s", cmd, len);
|
gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
|
static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
|
||||||
target_ulong tv_addr, target_ulong tz_addr)
|
target_ulong tv_addr, target_ulong tz_addr)
|
||||||
{
|
{
|
||||||
gdb_do_syscall(complete, "gettimeofday,%x,%x", tv_addr, tz_addr);
|
gdb_do_syscall(complete, "gettimeofday,%lx,%lx",
|
||||||
|
(uint64_t)tv_addr, (uint64_t)tz_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user