1

00:00:00,900  -->  00:00:05,090
Let's not look at a very important I know very interesting topic.

2

00:00:05,520  -->  00:00:13,020
It's about losing eclipses debugger as the name suggests a debugger is a tool that aids in application

3

00:00:13,020  -->  00:00:14,140
debugging.

4

00:00:14,250  -->  00:00:19,890
That is if there is a bug which is nothing but a defect in your application then you would debug it

5

00:00:19,900  -->  00:00:20,290
.

6

00:00:20,670  -->  00:00:26,370
So if you see any defects in your application then you can run the debugger to investigate the issue

7

00:00:27,000  -->  00:00:32,130
and then identify the exact problem area and then subsequently fix it.

8

00:00:32,250  -->  00:00:39,540
The application will be run by more when you're running the debugger debugger is also useful in understanding

9

00:00:39,540  -->  00:00:41,120
the program flow.

10

00:00:41,190  -->  00:00:46,500
So if you're looking at some code that you are not familiar with then you can use a debugger to get

11

00:00:46,500  -->  00:00:49,670
a good understanding of how the program works.

12

00:00:49,680  -->  00:00:55,290
That's a really effective way to understand code written by someone else in this lesson we will learn

13

00:00:55,290  -->  00:00:58,470
how to use a debugger effectively.

14

00:00:58,830  -->  00:01:01,760
So let's get started now.

15

00:01:02,020  -->  00:01:03,900
Good debugging application.

16

00:01:03,990  -->  00:01:10,740
The first thing you would do is set one or more breakpoints a break point is the place with the debugger

17

00:01:10,740  -->  00:01:11,980
with boss.

18

00:01:12,000  -->  00:01:17,770
So when you start a debugger it would run the application on would stop at the first break point.

19

00:01:18,240  -->  00:01:23,000
So a break point is essentially the point where you want to investigate the code.

20

00:01:23,520  -->  00:01:28,370
So let's just go ahead and place on a breakpoint in the student test class.

21

00:01:28,470  -->  00:01:33,300
So here we are in the Student class and we are iterating over all the students and printing the name

22

00:01:33,300  -->  00:01:34,160
and gender.

23

00:01:34,470  -->  00:01:39,170
So let's just go ahead and place our break for point here in line 35.

24

00:01:39,540  -->  00:01:42,160
And all we need to do is just double click here.

25

00:01:42,360  -->  00:01:43,850
And that's a break point.

26

00:01:43,860  -->  00:01:46,840
Now if you want to remove it just double click again.

27

00:01:47,100  -->  00:01:47,510
OK.

28

00:01:47,670  -->  00:01:53,940
So let's just go ahead double quick here and to start the debugger all we need to do is press this button

29

00:01:53,940  -->  00:02:02,310
over here ARE WE CAN DO IT RIGHT CLICK HERE answered run debug ass java application.

30

00:02:02,310  -->  00:02:07,120
Now if you do run as to our application it would simply run the application without the debugger.

31

00:02:07,500  -->  00:02:10,140
OK so let's just go here.

32

00:02:10,560  -->  00:02:13,930
Press this button here.

33

00:02:14,070  -->  00:02:21,360
Now what happened was earlier we were in Djala perspective now because we have started a debug session

34

00:02:21,570  -->  00:02:23,240
it opened a debug perspective.

35

00:02:23,250  -->  00:02:25,480
OK so we are here in the book Wisbech.

36

00:02:25,740  -->  00:02:32,980
Sometimes this would invoke a pop up on you with a dialog and you would have to hit okay for that.

37

00:02:33,390  -->  00:02:36,480
And if that happens or you can go ahead and do it.

38

00:02:36,480  -->  00:02:37,160
OK.

39

00:02:37,440  -->  00:02:40,020
So here we are in debug perspective.

40

00:02:40,150  -->  00:02:41,930
And it shows different views here.

41

00:02:41,970  -->  00:02:44,950
So this is the debug view here.

42

00:02:45,150  -->  00:02:46,530
This is a debug view.

43

00:02:46,860  -->  00:02:50,010
And here are sites variables view.

44

00:02:50,030  -->  00:02:51,840
I will get back to that later.

45

00:02:52,070  -->  00:02:53,810
And here is the editor.

46

00:02:54,220  -->  00:02:58,820
And here is a concern as application is running we will see the output here.

47

00:02:58,830  -->  00:03:01,770
So let's just go ahead and close this outline.

48

00:03:01,770  -->  00:03:06,240
So the debugger has started on it has stopped at the first big point here.

49

00:03:06,420  -->  00:03:07,900
So that's like totally fine.

50

00:03:08,240  -->  00:03:13,570
And here within the debug view what this means is it's telling.

51

00:03:13,580  -->  00:03:19,920
This is called It's a stack frame and it is telling that we are inside the main method at line 35 and

52

00:03:19,920  -->  00:03:24,850
these are all the local variables of attend the main matter first.

53

00:03:25,020  -->  00:03:28,910
I would like to talk about is about these three features here.

54

00:03:28,950  -->  00:03:33,070
So let's just go and then this is called a step into step over step here.

55

00:03:33,070  -->  00:03:40,350
And so let's just begin with this step over which has a shortcut of F 6 also and what it means is what

56

00:03:40,440  -->  00:03:43,290
exactly the current line in the statement.

57

00:03:43,470  -->  00:03:46,210
And it would more move to the next statement.

58

00:03:46,320  -->  00:03:49,990
OK so let's just do that.

59

00:03:50,040  -->  00:03:55,620
So as you can see we are at line 36 now and even here it has changed to 36.

60

00:03:55,620  -->  00:03:58,100
Now let's look at the variables here.

61

00:03:58,170  -->  00:04:00,380
So we just executed this here.

62

00:04:00,510  -->  00:04:03,900
This line the statement in line 35 on its name.

63

00:04:04,110  -->  00:04:10,530
And if you see a free highlighted here where here Howard the name variable we can see that it is the

64

00:04:10,530  -->  00:04:12,130
name is initialized to John.

65

00:04:12,240  -->  00:04:12,960
OK.

66

00:04:12,960  -->  00:04:19,030
So this is a student and you can see the same output here also name value is Jo-Anne.

67

00:04:19,190  -->  00:04:19,870
OK.

68

00:04:19,950  -->  00:04:23,040
Now let's step over once again.

69

00:04:23,040  -->  00:04:29,040
So we don't we have just executed the second statement and gender is male ungenerous male here so new

70

00:04:29,040  -->  00:04:30,390
variable got created.

71

00:04:30,870  -->  00:04:32,830
And here is a method right.

72

00:04:32,850  -->  00:04:37,860
So if we want to investigate the matter what we can do is we can step into.

73

00:04:37,890  -->  00:04:41,510
Which means that we are telling the debugger to step into that matter.

74

00:04:41,580  -->  00:04:42,830
So let's just do that.

75

00:04:44,890  -->  00:04:51,010
Now here we are in the first statement of the method and you can see that this has changed do you know

76

00:04:51,070  -->  00:04:57,040
the main method the stack frame corresponding to main method of went down and then we have a new stack

77

00:04:57,040  -->  00:04:59,150
frame corresponding to the numerator.

78

00:04:59,170  -->  00:05:02,230
So it's here right now and we are at line 48.

79

00:05:02,230  -->  00:05:05,360
And these are the variables corresponding to the numerator.

80

00:05:05,540  -->  00:05:06,150
OK.

81

00:05:06,340  -->  00:05:10,190
So let's just head step or.

82

00:05:10,420  -->  00:05:13,260
And you can see that the output is also getting printed here.

83

00:05:13,270  -->  00:05:19,750
The new output in the console let's it step on again and let's step or again.

84

00:05:19,780  -->  00:05:27,420
So we will go back and the control comes here and then it goes with the next declaration.

85

00:05:27,910  -->  00:05:31,120
So let's head control stapler.

86

00:05:31,180  -->  00:05:39,370
This is the second student step over this time not just do a step or so the loop continues again and

87

00:05:39,370  -->  00:05:44,280
it's good booze once again step over step or step over.

88

00:05:44,360  -->  00:05:52,210
Let's do a step into here and one other thing I wanted to show you here as it's printing the name and

89

00:05:52,210  -->  00:05:52,900
gender.

90

00:05:53,140  -->  00:05:58,480
But you can see that it's also blending the student also so if you click on this student as here it's

91

00:05:58,480  -->  00:06:00,520
the local variable of the for loop.

92

00:06:00,700  -->  00:06:08,080
So if you click click here you can see the all the elements of the student object itself.

93

00:06:08,310  -->  00:06:08,630
OK.

94

00:06:08,650  -->  00:06:12,110
So you can see that ID's thousand three name is Anita.

95

00:06:12,250  -->  00:06:15,220
So these are all the variables within the student.

96

00:06:15,220  -->  00:06:21,070
So here variables would show both residue variables as well as object references.

97

00:06:21,070  -->  00:06:24,050
Now let's go here step into.

98

00:06:24,130  -->  00:06:31,930
Now let's look at step written step written words simply execute the methhead and it would take the

99

00:06:31,930  -->  00:06:38,830
control back to the caller and it would move to the next statement after the after the Invoke in location

100

00:06:38,830  -->  00:06:39,340
statement.

101

00:06:39,370  -->  00:06:41,610
OK so let's just head this here now.

102

00:06:41,800  -->  00:06:45,080
So the control came back here and it went to the next iteration.

103

00:06:45,210  -->  00:06:45,750
OK.

104

00:06:45,970  -->  00:06:47,110
So that's separate.

105

00:06:47,410  -->  00:06:55,770
Now let's do one more time step or step or step or up do step or where.

106

00:06:55,810  -->  00:07:02,170
Now here we are at the closing brace at this point it doesn't matter whether we step over or step breakdown

107

00:07:02,230  -->  00:07:03,320
or step in.

108

00:07:03,370  -->  00:07:08,480
So all three would work in the same way sort of just head step over.

109

00:07:08,620  -->  00:07:17,820
And so since we have four students now when I hit a step or so control goes back here to set M..

110

00:07:18,040  -->  00:07:24,200
So we don't how any other any any other big points we can search more than one break point.

111

00:07:24,580  -->  00:07:30,140
And also one other thing is when we vent here around when we were in print method.

112

00:07:30,400  -->  00:07:36,370
So if we had then we you know when we do step down here it was returning the control back to the calling

113

00:07:36,460  -->  00:07:42,540
motard But if there was any other break point in between then it would stop at the big point.

114

00:07:42,670  -->  00:07:47,090
OK so if there is no magic wand you would call the control would go back with a calling method.

115

00:07:47,170  -->  00:07:47,750
OK.

116

00:07:47,980  -->  00:07:50,960
Now let's go back to the matter let's just had this button.

117

00:07:50,980  -->  00:07:52,690
So back to this matter.

118

00:07:52,750  -->  00:07:57,240
Now if you do step or can just took over.

119

00:07:57,450  -->  00:08:02,160
Now let's see if you're done with your investigation you can either stop here dominate.

120

00:08:02,320  -->  00:08:05,180
You can terminate all you consider is you.

121

00:08:05,290  -->  00:08:08,180
So you can resume the control would raise your hand.

122

00:08:08,190  -->  00:08:12,050
It would stop at the next break point.

123

00:08:13,090  -->  00:08:19,030
OK so let's just head this and we are done with the debugging session.

124

00:08:19,060  -->  00:08:21,180
Now let's look at something interesting.

125

00:08:21,340  -->  00:08:24,060
So let's just go up here.

126

00:08:24,070  -->  00:08:25,280
The student won.

127

00:08:25,720  -->  00:08:27,730
Let's get another break point here.

128

00:08:27,820  -->  00:08:31,010
So here we are creating a student instance.

129

00:08:31,030  -->  00:08:31,380
OK.

130

00:08:31,390  -->  00:08:33,270
And this is the first Torent instance.

131

00:08:33,550  -->  00:08:38,910
So we have two break points in our student test at line 13 on line five.

132

00:08:39,280  -->  00:08:42,510
So let's just go ahead and head and de-bug once again.

133

00:08:42,880  -->  00:08:47,500
So the debugger pauses here and let's So this is.

134

00:08:47,590  -->  00:08:49,200
Here we are creating an instance.

135

00:08:49,210  -->  00:08:51,860
So let's just go into this constructor here.

136

00:08:51,910  -->  00:08:54,330
So let's step in do.

137

00:08:55,600  -->  00:09:01,010
And here you see that it's loading this classic cordless classloader.

138

00:09:01,510  -->  00:09:09,470
And even here here it says that in arts you can see the corresponding stack for him.

139

00:09:09,550  -->  00:09:17,140
Let's get one more step in two and you'll see something else launcher Dark Glass string dark glass.

140

00:09:17,140  -->  00:09:18,980
So what exactly is happening here.

141

00:09:19,300  -->  00:09:25,210
So the thing that is happening is we are in walking we are creating the student instance for the very

142

00:09:25,210  -->  00:09:26,150
first time.

143

00:09:26,350  -->  00:09:31,530
And when that happens GBM first tries to load the Student class into the memory.

144

00:09:31,540  -->  00:09:31,830
OK.

145

00:09:31,840  -->  00:09:36,940
And that process is qualis glassblowing and we will see that in the GBM in dentals chapter.

146

00:09:36,970  -->  00:09:44,740
So every time when we create a new instance every time as it classes access for the very first time

147

00:09:45,040  -->  00:09:46,610
it has to be loaded into the memory.

148

00:09:46,630  -->  00:09:51,090
And that's called class loading and that happens for the very first time.

149

00:09:51,430  -->  00:09:52,850
Not for the second time.

150

00:09:52,900  -->  00:09:59,700
So that's what is happening so when you see this all you can do is just click on separate and separate

151

00:09:59,700  -->  00:10:01,600
and separate and separate.

152

00:10:01,620  -->  00:10:08,370
So now we're back in the main matter and first instance has been created so let's just go to the second

153

00:10:08,370  -->  00:10:09,180
instance.

154

00:10:09,180  -->  00:10:16,720
Now let's head step into now as you can see it's no longer calling the class loading class.

155

00:10:16,800  -->  00:10:25,020
The reason as class student is already in memory and JVM is simply using it to create the need to create

156

00:10:25,020  -->  00:10:26,510
a new instance or an effect.

157

00:10:26,700  -->  00:10:30,240
OK so what we saw happens only the very first time.

158

00:10:30,240  -->  00:10:32,060
So that's the class drawing process.

159

00:10:32,070  -->  00:10:37,680
So the first time it floats into the memory and from the second on time onwards it's just it just uses

160

00:10:37,680  -->  00:10:39,120
the class from the memory.

161

00:10:39,210  -->  00:10:46,190
Ok since it's already loaded into memory now we are here in this construct Let's head step over.

162

00:10:46,380  -->  00:10:52,830
Now you'll see it's not going it's not executing the first statement but for some reason it's getting

163

00:10:52,830  -->  00:10:58,360
here to the this statement where the gender variable and the student is getting initialized.

164

00:10:58,470  -->  00:11:00,340
So what exactly is happening.

165

00:11:00,360  -->  00:11:06,570
The thing is we know that within the constructor the first invocation statement would be a call to call

166

00:11:06,570  -->  00:11:08,580
to the superclass constructor which is.

167

00:11:08,700  -->  00:11:11,790
So we know that there is an super invocation statement.

168

00:11:11,850  -->  00:11:18,870
So basically what happened was the object class got invoked under super invocation statement is an invisible

169

00:11:18,870  -->  00:11:20,380
statement We know that.

170

00:11:20,550  -->  00:11:21,890
And so that got in worked.

171

00:11:21,900  -->  00:11:28,620
So the control window object it created an object instance and then it came back with a subclass which

172

00:11:28,620  -->  00:11:29,530
is the student.

173

00:11:29,700  -->  00:11:34,760
And then it started to initialize all these instance variables so that's what is happening here.

174

00:11:34,800  -->  00:11:40,710
And we will examine it in more detail when we create the next instance so let's just head step over

175

00:11:41,220  -->  00:11:43,380
so step or so we are here now.

176

00:11:43,410  -->  00:11:43,980
Back.

177

00:11:43,980  -->  00:11:50,470
So let's just go back Buist to pretend hits in do OK.

178

00:11:50,490  -->  00:11:52,630
So this is the third student instance.

179

00:11:52,920  -->  00:11:55,230
Now let's do another step in do.

180

00:11:55,530  -->  00:11:56,520
And here we are.

181

00:11:56,550  -->  00:12:01,220
So the object class got invoked.

182

00:12:01,410  -->  00:12:03,180
So that's what has happened.

183

00:12:03,180  -->  00:12:05,280
And we do step over.

184

00:12:05,520  -->  00:12:08,010
So we are back in Student class.

185

00:12:08,390  -->  00:12:12,390
Students take over step over OK so we.

186

00:12:12,420  -->  00:12:13,500
So that's what is happening.

187

00:12:13,500  -->  00:12:17,330
So there is an invisible super in waggish statement as we know.

188

00:12:17,520  -->  00:12:21,360
And here is one more thing I want to point out as.

189

00:12:21,600  -->  00:12:23,620
So here this is a statement.

190

00:12:23,700  -->  00:12:28,150
So if we do step over it would execute this statement and move to the next statement.

191

00:12:28,230  -->  00:12:35,180
But if had this been a method invocation then if we had step into it would go into the matter.

192

00:12:35,190  -->  00:12:36,640
We know what we already know that.

193

00:12:37,020  -->  00:12:41,790
But for this kind of statement which is not a method invocation statement it doesn't matter whether

194

00:12:41,790  -->  00:12:47,210
it is step over or step into or even step into Would we have the same me.

195

00:12:47,250  -->  00:12:51,990
It's just that if the statement involves him at that location then step in and do would really step

196

00:12:51,990  -->  00:12:52,870
into that method.

197

00:12:52,980  -->  00:13:00,150
OK so let's just step into the you see step into step into.

198

00:13:00,150  -->  00:13:01,730
So that's what is happening here.

199

00:13:02,070  -->  00:13:05,100
So there is no difference between step over and step into.

200

00:13:05,120  -->  00:13:07,240
Now another thing I want to point as.

201

00:13:07,240  -->  00:13:12,630
Let's say we came here to this particular statement and you just want to go back and do it go back in

202

00:13:12,630  -->  00:13:18,990
time and you know or Buddha or de-bug once again into the beginning from the beginning of the matter

203

00:13:19,390  -->  00:13:22,200
and that is all you need to do is just click on this.

204

00:13:22,200  -->  00:13:27,210
Drop the frame and it would start again.

205

00:13:27,420  -->  00:13:34,860
But the catch is that the ID variable got initialized 2003.

206

00:13:35,550  -->  00:13:37,190
So the values are not reset.

207

00:13:37,290  -->  00:13:42,780
It's just that the control goes back but the values the instance variable values are not initialized

208

00:13:43,260  -->  00:13:46,640
or even the static variable values will not read or read initialized.

209

00:13:46,800  -->  00:13:47,440
OK.

210

00:13:47,550  -->  00:13:56,630
So let's just go do step over stick or stick or just of course the we're now ID would be 2004.

211

00:13:57,270  -->  00:14:04,130
So that's the drop to frame on your JVM hostile supported in order for you to see these Eikon here.

212

00:14:04,740  -->  00:14:07,240
So let's just do a step taken.

213

00:14:07,410  -->  00:14:09,770
So here we are.

214

00:14:10,300  -->  00:14:14,220
STUDENT 4 let's just take resume here.

215

00:14:14,220  -->  00:14:18,930
So here we are in the for loop just took over.

216

00:14:18,990  -->  00:14:24,640
Now another thing that we can do is here we have the name variable or the generated one.

217

00:14:24,780  -->  00:14:28,190
You can also read said the value so the value is Jo-Anne.

218

00:14:28,200  -->  00:14:33,000
Now let's say for example we want to see what happens if we change it to another.

219

00:14:33,090  -->  00:14:34,670
OK so we can do that.

220

00:14:34,740  -->  00:14:38,080
So you can just right click on Sid change value.

221

00:14:38,280  -->  00:14:41,380
So from Joanne let's say you want to change it to null.

222

00:14:41,490  -->  00:14:42,530
It's just a string.

223

00:14:42,720  -->  00:14:43,180
So hit.

224

00:14:43,200  -->  00:14:43,970
OK.

225

00:14:44,190  -->  00:14:48,750
Now you can see that it is not a novel it's going to print.

226

00:14:48,900  -->  00:14:51,210
Let's let's just step into print.

227

00:14:51,700  -->  00:14:54,480
As you can see the print is not at all.

228

00:14:54,480  -->  00:14:56,010
It's printing now here.

229

00:14:56,340  -->  00:15:03,540
So it's just written soon it's just finished a..

230

00:15:04,830  -->  00:15:10,270
Now one final thing I want to show is let's just go here.

231

00:15:10,530  -->  00:15:12,400
So let's just say we want to get it.

232

00:15:12,420  -->  00:15:14,900
I mean if we hit resume it's going to finish right.

233

00:15:14,970  -->  00:15:16,430
Because there is no break point.

234

00:15:16,560  -->  00:15:18,360
But let's say we want to stop here.

235

00:15:18,360  -->  00:15:22,830
There is no break point but we still want to stop here at some point in the future.

236

00:15:22,830  -->  00:15:29,640
So what we can do is just put your you know just going near that statement going to that line and just

237

00:15:29,640  -->  00:15:37,830
hit Control are and you can see the control jumps to that particular statement and it exiguous everything

238

00:15:37,830  -->  00:15:38,530
in between.

239

00:15:38,610  -->  00:15:39,170
OK.

240

00:15:39,330  -->  00:15:45,330
So we can do that even though there is no break statement and on what we will do is to control our.

241

00:15:45,780  -->  00:15:47,140
So that's about it.

242

00:15:47,280  -->  00:15:51,060
And let me just run this one more time resume.

243

00:15:51,540  -->  00:15:52,810
So we are done.

244

00:15:52,980  -->  00:15:57,150
Now here are the big points if you want remore all the brick ones at once.

245

00:15:57,150  -->  00:16:01,390
You can click this icon here remore all break points.

246

00:16:01,440  -->  00:16:02,910
So it says are are you sure.

247

00:16:02,910  -->  00:16:04,260
Yes.

248

00:16:04,260  -->  00:16:10,410
Now if you want to remove this you can also do directory more or terminated branches so there is one

249

00:16:10,410  -->  00:16:12,870
more from some other session.

250

00:16:12,870  -->  00:16:18,120
So let's just close this so you can have multiple debug sessions.

251

00:16:18,450  -->  00:16:18,700
OK.

252

00:16:18,710  -->  00:16:20,890
So that's about it.

253

00:16:20,940  -->  00:16:26,610
I think those are all important things that we need to know about about debugging.

254

00:16:26,610  -->  00:16:28,760
And we have blown that.

255

00:16:28,890  -->  00:16:36,140
So what we learned is all the fundamental stuff now in the supplementary notes I will include a pointer

256

00:16:36,160  -->  00:16:42,850
to a really good read you'll see it is that coward's debugging debugger at a very deep level.

257

00:16:42,960  -->  00:16:49,680
Those rules are specific to debugging are not instructed by a person called Mark Baxter and it's really

258

00:16:49,680  -->  00:16:50,410
good stuff.

259

00:16:50,670  -->  00:16:56,690
OK so if you want to go into more details you have to do it you can look at those videos it's over one

260

00:16:56,700  -->  00:16:57,530
hour long.

261

00:16:57,750  -->  00:17:03,690
But what be covered here is definitely the basic stuff fundamental stuff and it should be more than

262

00:17:03,690  -->  00:17:08,760
enough but you can also go and look check all those videos.

263

00:17:09,240  -->  00:17:14,440
Not that debuggers are also used on Glan side to debug issues in Javascript.

264

00:17:14,490  -->  00:17:15,720
So it's not just Java code.

265

00:17:15,720  -->  00:17:18,690
You can also have a debugger or in the client side.

266

00:17:18,690  -->  00:17:22,420
So Wondolowski a debugger I use extensively is cardless firebug.

267

00:17:22,780  -->  00:17:27,690
And it can be installed in the browser and it works pretty much like Eclipse's a debugger.

268

00:17:27,690  -->  00:17:31,320
In fact I think most debuggers would work in a similar way.

269

00:17:31,470  -->  00:17:32,740
So that's about it.

270

00:17:32,740  -->  00:17:34,520
And I hope you enjoyed it.
