Quindi, sto imparando come programmare in C, e sto avendo (o ad elast, provando a) divertirmi con GDB.GDB <Indirizzo 0xblablabla fuori limite> errore
Così ho scritto questo semplice codice:
#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;
}
e stavo cercando di usd GDB per ottenere alcune informazioni su di esso. Così ho usato per cercare di ottenere gli argomenti da indirizzi di memoria, ma questo è ciò che ottengo:
(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>
Perché continuo a ricevere questo errore? Sono su un 64-bit, e sto usando Kali Linux
Il programma, se compilato, funziona, è solo che non riesco a capire perché non riesco a leggere quei valori con GDB.
Grazie mille, stavo seguendo un libro scritto per una macchina a 32 bit! – DoubleCat