0x0000000000400835
0x0000000000400838
0x000000000040083c
0x0000000000400841
0x0000000000400848
0x000000000040084d
0x0000000000400851
0x0000000000400856
0x0000000000400858
0x000000000040085d
0x0000000000400862
0x0000000000400867
0x000000000040086e
0x0000000000400873
0x0000000000400877
0x000000000040087c
0x000000000040087e
0x0000000000400883
0x0000000000400888
0x000000000040088d
0x0000000000400892
0x0000000000400893
End of assembler dump.
(gdb) n
The program is not being run.
(gdb) r
Starting program: /share/suse linux/root/c/a.out
Breakpoint 1, main () at t1.cpp:10
10 p1=new (std::nothrow)int[-1];
(gdb) n
11 if(p1==NULL)
(gdb) n
13 printf("\r\n p1 error....");
(gdb) n
16 p = new int[-1];
(gdb) n
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
p1 error....
Program received signal SIGABRT, Aborted.
0x00002b591b4bcbb5 in raise () from /lib64/libc.so.6
(gdb)
t2.cpp //c++
int main()
{
int* p;
int* p1;
p1=new (std::nothrow)int[-1];
if(p1==NULL)
{
printf("\r\n p1 error....");
}
try{
p = new int[-1];
}catch(const std::bad_alloc&e){
printf("\r\n p error............");
}
return(0);
}
gridserver1:/share/suse linux/root/c # g++ -g t2.cpp
gridserver1:/share/suse linux/root/c # gdb a.out
This GDB was configured as "x86_64-suse-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) disass main
Dump of assembler code for function main:
0x00000000004009a4
0x00000000004009a5
0x00000000004009a8
0x00000000004009a9
0x00000000004009ad
0x00000000004009b2
0x00000000004009b9
0x00000000004009be
0x00000000004009c2
0x00000000004009c7
0x00000000004009c9
0x00000000004009ce
0x00000000004009d3
0x00000000004009d8
0x00000000004009df
0x00000000004009e4
0x00000000004009e8
0x00000000004009ea
0x00000000004009ee
0x00000000004009f2
0x00000000004009f4
0x00000000004009f8
0x00000000004009fd
0x0000000000400a01
0x0000000000400a06
0x0000000000400a0a
0x0000000000400a0f
0x0000000000400a14
0x0000000000400a19
0x0000000000400a1e
0x0000000000400a20
0x0000000000400a24
0x0000000000400a28
0x0000000000400a2d
0x0000000000400a31
0x0000000000400a35
0x0000000000400a3a
0x0000000000400a3f
0x0000000000400a43
0x0000000000400a44
0x0000000000400a45
End of assembler dump.
(gdb) b main
Breakpoint 1 at 0x4009ad: file t2.cpp, line 10.
(gdb) n
The program is not being run.
(gdb) r
Starting program: /share/suse linux/root/c/a.out
Breakpoint 1, main () at t2.cpp:10
10 p1=new (std::nothrow)int[-1];
(gdb) n
11 if(p1==NULL)
(gdb) n
13 printf("\r\n p1 error....");
(gdb) n
16 p = new int[-1];
(gdb) n
p1 error....
p error............
Program exited normally.
(gdb)