Week 7
Week 8 – Debuggers
Due Dates & Links
Due This Week
- Quiz 8 - Due 11:59am February 23, 2021
- Lab Report 4 (Week 8) - Due 5pm February 25, 2021
- Updates to Lab Report 3 (Week 6) - Due 5pm February 25, 2021
To Watch/Read
- Videos on
jdb
:
Lab Tasks
Editing at the Command Line
Everyone should do this; it’s skill practice that you all need.
Log into ieng6. Run the command vimtutor
. Set a timer for 15 minutes.
Complete the first two lessons (go past lesson 2 if you can in 15 minutes). Really do the exercises!
Then quit the tutor, clone (or pull if you’ve already cloned) your copy of markdown-parse
onto ieng6. Make sure you can use make test
to build it and run your tests.
Still on your own, open the test file by giving it as an argument to vim
, like vim MarkdownParseTest.java
(you might need to cd
into the repository directory first). Add a test using the vim editing commands you learned, then save, quit, and rerun the tests.
You’ve just done programming entirely on ieng6; you didn’t need VScode at all, just a terminal!
As a group, discuss and write in notes:
- What were two things you thought were annoying about using Vim? Be specific.
- What were two things you thought were cool about using Vim? Be specific.
Using a Debugger
Do this part as a group, while logged into someone’s account on ieng6
.
- Make a fresh clone of https://github.com/ucsd-cse15l-w22/markdown-parse
- In the checkout, run
make test
. Notice that one test fails. - Use
jdb
withMarkdownParse
to run just that markdown file from the command line using themain
method ofMarkdownParse
. Take usejdb
commands to get the following information and take screenshots of it:- The stack trace when the exception is happening
- The local variables in
getLinks
when the exception is happening
- Next, use
jdb
to run the JUnit tests. It should be similar to thejava
command in themakefile
. You can refer to the lecture videos for a good way to do this. Again, usejdb
commands to find:- The stack trace when the exception is happening
- The local variables in
getLinks
when the exception is happening
Then, diagnose and fix the bug so that all the tests pass. Make a commit with the fix and push it, then link to the commit in your notes.
Write down in notes answers to these additional questions:
- What is information that you were able to get via
jdb
that you would be unable to get via the stack trace of the exception? - What are some pros and cons of using
jdb
to get information vs. adding print statements to do so? - Discuss the
findCloseParen
method – are there other places in parsing markdown where a method like this may be useful?
More Debugger Uses
Switch to another student to screenshare, still using ieng6
.
Change findCloseParen
so that it has an infinite loop (for example, remove the increment closeParen++
, or change the condition). Re-run make test
and verify that a test is in an infinite loop.
Practice using jdb
with suspend
to pause the program and show the stack trace during the loop. You should be able to identify:
- Which test is triggering the infinite loop
- Which line the program stopped on when the program was
suspend
ed - What the current values of all the variables are in
getCloseParen
at the moment the program suspended
Take a screenshot or copy/paste of your jdb
session and indicate in your notes each of the three items above and how your jdb
session informs you of that.
Week 8 Lab Report
Consider the following three markdown snippets:
Snippet 1
`[a link`](url.com)
[another link](`google.com)`
[`cod[e`](google.com)
[`code]`](ucsd.edu)
Snippet 2
[a [nested link](a.com)](b.com)
[a nested parenthesized url](a.com(()))
[some escaped \[ brackets \]](example.com)
Snippet 3
[this title text is really long and takes up more than
one line
and has some line breaks](
https://www.twitter.com
)
[this title text is really long and takes up more than
one line](
https://ucsd-cse15l-w22.github.io/
)
[this link doesn't have a closing parenthesis](github.com
And there's still some more text after that.
[this link doesn't have a closing parenthesis for a while](https://cse.ucsd.edu/
)
And then there's more text
For each snippet, add a test both to your implementation of markdown-parse, and the implementation you reviewed in week 7. Run the tests and show the results of running the tests on each. This means you should add a total of 6 test methods (3 to your implementation and 3 to the one you reviewed).
This means you will need to clone and run both your implementation and the one you reviewed in week 7, make some small edits, and run them both.
Your report should include:
- A link to your markdown-parse repository and a link to the one you reviewed in week 7
- For each test above:
- Decide on what it should produce by using either VScode preview or the CommonMark demo site
- Showing the code in
MarkdownParseTest.java
for how you turned it into a test - For your implementation, the corresponding output when running the tests; if it passed, say so. If it didn’t pass, show the specific part of the JUnit output that shows the test failure.
- For the implementation you reviewed in Week 7, the corresponding output when running the tests; if it passed, say so. If it didn’t pass, show the specific part of the JUnit output that shows the test failure.
- Answer the following questions with 2-3 sentences each:
- Do you think there is a small (<10 lines) code change that will make your program work for snippet 1 and all related cases that use inline code with backticks? If yes, describe the code change. If not, describe why it would be a more involved change.
- Do you think there is a small (<10 lines) code change that will make your program work for snippet 2 and all related cases that nest parentheses, brackets, and escaped brackets? If yes, describe the code change. If not, describe why it would be a more involved change.
- Do you think there is a small (<10 lines) code change that will make your program work for snippet 3 and all related cases that have newlines in brackets and parentheses? If yes, describe the code change. If not, describe why it would be a more involved change.
If you’re using a direct clone to ieng6
, you might find it useful to give an extra argument to git clone
that specifies which directory to clone into, for example:
$ git clone https://github.com/ucsd-cse15l-w22/markdown-parse markdown-parse-target-directory
Add your lab report as lab-report-4-week-8
within the same Github pages lab reports repository you’ve been using all quarter, and include all of the elements above.