Tak, uczę się programowania w C, i mam (lub elastycznie, starając się) zabawę z GDB.GDB <Adres 0xblablabla out of bounds> error
Więc napisałem ten prosty kod:
#include <stdio.h>
int main (int argc, char *argv[]){
int i;
int n = atoi(argv[2]);
for (i=0; i<n ; i++){
printf("%s \n",i+1,argv[1]); // prints the string provided in
} // the arguments for n times
return 0;
}
i starałem USD GDB aby uzyskać pewne infos na nim. Więc użyłem go, aby spróbować i dostać argumenty z adresami pamięci, ale to, co mam:
(gdb) break main
Breakpoint 1 at 0x4005d7: file repeat2.c, line 14.
(gdb) break 17
Breakpoint 2 at 0x40062c: file repeat2.c, line 17.
(gdb) run hello 5
Starting program: /root/Scrivania/Programmazione/repeat2 hello 5
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
Breakpoint 1, main (argc=3, argv=0x7fffffffe948) at repeat2.c:14
14 int n = atoi(argv[2]);
(gdb) cont
Continuing.
1 ------> hello
2 ------> hello
3 ------> hello
4 ------> hello
5 ------> hello
Breakpoint 2, main (argc=3, argv=0x7fffffffe948) at repeat2.c:18
18 return 0;
(gdb) x/3xw 0x7fffffffe948 (I try to read what argv contains)
0x7fffffffe948: 0xffffebbc 0x00007fff 0xffffebe3
(gdb) x/s 0xffffebbc (I try to read one of the argoments in the array)
0xffffebbc: <Address 0xffffebbc out of bounds>
Dlaczego wciąż otrzymuję ten błąd? Jestem na 64-bitowym i używam Kali Linux
Program, jeśli jest skompilowany, działa, po prostu nie mogę zrozumieć, dlaczego nie mogę odczytać tych wartości za pomocą GDB.
Wielkie dzięki, śledziłem książkę napisaną dla maszyny 32-bitowej! – DoubleCat