Compare commits

...

3 Commits

Author SHA1 Message Date
Lephenixnoir 8b09299c3a
gdb: interpret client disconnect as W00 (normal exit) 2024-04-06 22:55:43 +02:00
Lephenixnoir 5acef051f1
gdb: use sh4al-dsp target
Also switch the order of -ex for a slightly cleaner output
2024-04-01 00:48:58 +02:00
Lephenixnoir 5fe02b055b
fxsdk: add -g by default for new projects 2024-03-31 19:54:17 +02:00
2 changed files with 21 additions and 3 deletions

View File

@ -29,7 +29,7 @@ set(ASSETS_cg
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -g)
target_link_libraries(myaddin Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)

View File

@ -125,9 +125,9 @@ static pid_t fork_gdb(char **user_argv, char const *socket_path)
argv[0] = "sh-elf-gdb";
argv[1] = "-q";
argv[2] = "-ex";
argv[3] = target_command;
argv[3] = "set architecture sh4al-dsp";
argv[4] = "-ex";
argv[5] = "set architecture sh4a-nofpu";
argv[5] = target_command;
memcpy(argv+6, user_argv, (n+1) * sizeof *argv);
struct sigaction action = {
@ -191,6 +191,7 @@ int main(int argc, char **argv)
libusb_context *context = NULL;
struct fxlink_device *fdev = NULL;
struct fxlink_pollfds fxlink_polled_fds = { 0 };
struct fxlink_device_list device_list = { 0 };
char socket_path[256] = { 0 };
pid_t gdb_pid = -1;
int ret = 1;
@ -238,6 +239,9 @@ int main(int argc, char **argv)
};
fxlink_pollfds_track(&fxlink_polled_fds, context);
/* Track devices to find out when our device is removed */
fxlink_device_list_track(&device_list, context);
while(!interrupted_flag && !gdb_terminated_flag) {
int err = fxlink_multipoll(-1,
fxlink_polled_fds.fds, fxlink_polled_fds.count,
@ -251,6 +255,18 @@ int main(int argc, char **argv)
struct timeval zero = {0};
libusb_handle_events_timeout(context, &zero);
/* Check if our device is still in the list */
fxlink_device_list_refresh(&device_list);
bool still_there = false;
for(int i = 0; i < device_list.count; i++)
still_there = still_there || device_list.devices[i].dp == fdev->dp;
if(!still_there) {
hlog("gdb");
log_("device disconnected\n");
send(client_socket, "$W00#b7", 7, 0);
break;
}
struct fxlink_message *msg;
while((msg = fxlink_device_finish_bulk_IN(fdev)) != NULL) {
if(!fxlink_message_is_apptype(msg, "gdb", "remote")) {
@ -304,6 +320,8 @@ end:
waitpid(gdb_pid, NULL, 0);
if(socket_path[0])
unlink(socket_path);
if(device_list.ctx)
fxlink_device_list_stop(&device_list);
if(fxlink_polled_fds.ctx)
fxlink_pollfds_stop(&fxlink_polled_fds);
if(fdev) {