mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-02 21:30:40 +00:00
debugger: Work around Xcode Terminal.app issue.
If debugging with Xcode using Terminal.app for the console, Terminal.app may send empty lines to the dingusppc debugger while resizing the Terminal.app window and it will do this forever. As a workaround, use std::cin.clear() to clear the input buffer before getline and loop until the terminal window size is not changing or the input line is not empty.
This commit is contained in:
parent
229509a067
commit
11e0bd79b0
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
Copyright (C) 2018-22 divingkatae and maximum
|
Copyright (C) 2018-23 divingkatae and maximum
|
||||||
(theweirdo) spatium
|
(theweirdo) spatium
|
||||||
|
|
||||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||||
@ -413,6 +413,7 @@ static void print_mmu_regs()
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
static struct sigaction old_act_sigint, new_act_sigint;
|
static struct sigaction old_act_sigint, new_act_sigint;
|
||||||
static struct sigaction old_act_sigterm, new_act_sigterm;
|
static struct sigaction old_act_sigterm, new_act_sigterm;
|
||||||
@ -449,17 +450,37 @@ void enter_debugger() {
|
|||||||
cout << "Welcome to the DingusPPC command line debugger." << endl;
|
cout << "Welcome to the DingusPPC command line debugger." << endl;
|
||||||
cout << "Please enter a command or 'help'." << endl << endl;
|
cout << "Please enter a command or 'help'." << endl << endl;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
struct winsize win_size_previous;
|
||||||
|
ioctl(0, TIOCGWINSZ, &win_size_previous);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
cout << "dingusdbg> ";
|
cout << "dingusdbg> ";
|
||||||
|
|
||||||
/* reset string stream */
|
while (1) {
|
||||||
ss.str("");
|
/* reset string stream */
|
||||||
ss.clear();
|
ss.str("");
|
||||||
|
ss.clear();
|
||||||
|
|
||||||
cmd = "";
|
cmd = "";
|
||||||
getline(cin, inp, '\n');
|
std::cin.clear();
|
||||||
ss.str(inp);
|
getline(cin, inp, '\n');
|
||||||
ss >> cmd;
|
ss.str(inp);
|
||||||
|
ss >> cmd;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
struct winsize win_size_current;
|
||||||
|
ioctl(0, TIOCGWINSZ, &win_size_current);
|
||||||
|
if (win_size_current.ws_col != win_size_previous.ws_col || win_size_current.ws_row != win_size_previous.ws_row) {
|
||||||
|
win_size_previous = win_size_current;
|
||||||
|
if (cmd.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd.empty() && !last_cmd.empty()) {
|
if (cmd.empty() && !last_cmd.empty()) {
|
||||||
cmd = last_cmd;
|
cmd = last_cmd;
|
||||||
|
Loading…
Reference in New Issue
Block a user