In this video, we'll be looking into how can we keep a breakpoint for underscore start.
So I have a simple, uh, code which is printing 11 db.
I'm going to compile this user space dot c and with hyphen g.
And I will load this in user space.
And then I say keep a breakpoint with the mean and I'll run the program.
Now if I see a bit uh, it is not giving me full stack trace who is calling me.
It is just printing main.
Right.
If I want to know who is calling main, we know from the entry point address the start underscore start
is a function which is calling main.
But here from the gdb I am not able to verify that.
How can I verify using gdb?
Okay.
So for that, uh, in gdb you have a start command.
If you run the start command, it will set a breakpoint at the main and it will also invoke the run
command.
Here we have executed two commands which it did break main.
And then we said run.
If I do a start we'll keep a breakpoint on the main and it will also invoke run command.
There is a command known as start.
I uh, this will set the breakpoint at the first instruction of the program execution and then invoke
run okay.
And I can also verify that information.
What is the first execution instruction using info files you have a entry point and I can keep the.
So there are two ways.
Either you start I which will keep the breakpoint at the first instruction, or get the entry point
from info files and keep the breakpoint here.
Okay, now I'll just show you that one.
So I have start command, which will just uh, keep the breakpoint at the main and then it will uh.
Also called run.
So there is one more command which is, uh, start I, which will keep the breakpoint at underscore
start and it will, uh, keep it underscore start and then also starts execution.
And as it got executed it has stopped.
Now I can keep a breakpoint at main and I say continue.
And if I say backtrace still it is not working.
Let's fine.
We'll see how we can resolve that one.
I mean here you are not still seeing start.
We know start is calling main, but still you are not seeing this here.
Okay, now there is another way I say info files.
I get the entry point which is uh, 1060 and I keep a break at 01060 and if I see info break it is kept.
Data underscore start.
Okay.
But we need this one.
So I say continue run and it says cannot insert breakpoint one cannot access address 10060.
Let's see this one.
So it is not able to access uh this one.
So okay now the there is a command uh set backtrace passed main on.
So by default the GDB thinks like whatever is before main is of no interest.
So it will not display you the backtrace of the before main.
What happens.
But if you want to see this what is happening before main, you can set this command in the GDB.
And then you can see what is happening before main.
So I'll run this command and now I'll say start.
Now this will keep a breakpoint at main and it will stop at the main function.
Now if I say backtrace now you can see first underscore start got executed.
And then at underscore start libc start main got executed and then main function got executed.
So you can now see the full backtrace who is calling main underscore.
Start is the first function which gets executed.
And then comes uh start main and then comes main.
So start calls this function.
This function is called by calling main function.