radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.29k stars 2.97k forks source link

radare2 does not show console on remote debugging the gameboy #18329

Open gogo2464 opened 3 years ago

gogo2464 commented 3 years ago

Environment

# copypaste this script into your shell and replace it with the output
$ date
mer. 03 févr. 2021 13:24:41 CET
$ radare2 -v
radare2 5.1.0 25632 @ linux-x86-64 git.5.1.0
commit: ecb6b6477787b7809b96a24993459bfc93025ba3 build: 2021-01-28__02:45:39
$ uname -ms
Linux x86_64

Description

I do not see the console on the radare2 terminal. I expect to see the console of radare2 on the terminal. I mean the [0x00000000]>.

Test

$ VisualBoyAdvance -Gtcp pokered.gbc;
VisualBoyAdvance version 1.8.0 [SDL]
Searching for file VisualBoyAdvance.cfg
Searching current directory: /home/ME/MYFOLDERS/pokered
Searching home directory: /home/ME/.vba
Searching system config directory: /etc
Reading configuration file.
Listening for a connection at port 55555
Got a connection from 127.0.0.1 39546
Color depth: 32
Shutting down
Closing remote socket
Closing listen socket

$ radare2 -d gdb://localhost:55555;
gdb.io.open: Cannot connect to host.
WARNING: r_file_exists: assertion '!R_STR_ISEMPTY (str)' failed (line 192)
[r] Cannot open 'gdb://localhost:55555'

I also tried with mgba-sdl:

$sudo apt install mgba-sdl;
$mgba --gdb pokered.gbc;
$radare2 -a gb -b 32 -d gdb://localhost:2345;

Could not resolve address 'localhost' or failed to connect
gdb.io.open: Cannot connect to host.
WARNING: r_file_exists: assertion '!R_STR_ISEMPTY (str)' failed (line 192)
gdbr_get_reg_profile: unsupported x86 bits: 16
WARNING: r_reg_set_profile_string: assertion 'reg && str' failed (line 135)
WARNING: r_reg_set_profile_string: assertion 'reg && str' failed (line 135)
WARNING: r_reg_set_profile_string: assertion 'reg && str' failed (line 135)
WARNING: r_reg_set_profile_string: assertion 'reg && str' failed (line 135)
[r] Cannot open 'gdb://localhost:2345'

With no asserts (R2_DEBUG_ASSERT=1) you have :

$ radare2 R2_DEBUG_ASSERT=1 -d gdb://localhost:55555;
gdb.io.open: Cannot connect to host.
[r] Cannot open 'gdb://localhost:55555

for visual boy advance and you have


$ radare2 R2_DEBUG_ASSERT=1 -a gb -b 32 -d gdb://localhost:2345;Could not resolve address 'localhost' or failed to connect
gdb.io.open: Cannot connect to host.
[r] Cannot open 'gdb://localhost:2345'

for mgba

trufae commented 3 years ago

environment variables must be defined before the program like this:

R2_DEBUG_ASSERT=1 gdb --args radare2 -a gb -b 32 -d gdb://localhost:2345

when you get the gdb prompt type the following commands:

run
.. wait until crash ..
i r
bt
up
up
up
...
print str 

with this info you may be able to see why this null ptr is reaching the assert and add an if in the caller to avoid this to happen, this is sometimes useful to identify code that is being executed when it shouldnt.

gogo2464 commented 3 years ago

Thank you very much I will try as soon as possible.

gogo2464 commented 3 years ago

EDIT : I think VisualBoy advance nor mgba supports remote debugging server for gameboy color. They do only support that for gameboy advance.