question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local debugger implementation discussion

See original GitHub issue

What we’ve got

  • LeetCode problem’s templateMeta property from GraphQL API:
    "templateMeta": {
        "name": "addTwoNumbers",
        "params": [
            {
                "name": "l1",
                "type": "ListNode",
                "dealloc": false
            },
            {
                "name": "l2",
                "type": "ListNode",
                "dealloc": false
            }
        ],
        "return": {
            "type": "ListNode",
            "dealloc": true
        }
    }
  • Pre- and Post- Solution code template in cpp. I’ve written a bunch of robust code in this gist. To successfully build a solution, we should provide:
    1. solution code file solution.h.
    2. metadata of the problem meta.h:
#ifndef __CLASS
#define __CLASS(name, ...)
#endif

#ifndef __METHOD
#define __METHOD(name, ...)
#endif

__CLASS(Solution);

__METHOD(inorderTraversal, vector<int>, TreeNode*);

#undef __CLASS
#undef __METHOD

#define __TREE_NODE

//#define __SYSTEM_DESIGN

The meta code could be generated by templateMeta from the extension side.

This is not the cpptool extension, but its api package, from which we can provide custom configuration of our currently writing code.

e.g., we can force-include pre-solution.h in the solution.h to provide proper intellisense.

What we may need

  • A proper folder structure of leetcode problem files.

I suggest we keep everything about leetcode extension in ~/.leetcode, or somewhere specified by user in settings, rather than an arbitrary workspace. All the files inside the root should be managed by extension, and user intervention should be reduced as little as possible.

  • How to organize the dependency with each other language tools? Users only need a small set of languages to write leetcode solutions.

  • How to trigger the debugger through a WebView, and feed the testcase data from a WebView textbox?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
wangtao0101commented, Jul 7, 2019

I am working on a local debugger proposal. I have finished a demo for javascript language for the problem 1.

For the local debugger, we have something to do:

1. get problem meta data

I have finished it by leetcode-problem-types for free available problems.

2. start debug

Using vscode.debug.startDebugging to start debug session

3. handle input and output

As we know the types of all parameters according to problem meta data, so we can write all
transform functions for every kind of parameters. (string, number, ListNode, TreeNode, TreeNode[]…)

4. missing definition

We should add missing definitions for some languages to the problem file when debug, and delete them when submit. For example: javascript needs ‘module.exports’ and C need struct of TreeNode.

5. judge result

The same as step 3 for most problems but some specials which have no output. We should write judge function for thest problems if we support them.

Hoping get some advice for the proposal, i will finish the first version of javascript in few weeks.

0reactions
wangtao0101commented, Mar 29, 2020

@jdneo I have come up with an idea about how to strip the debug feature from vscode-leetcode. After i finish cpp debuger soon, i will do this. I agree with that the way will benefit both users and the two extensions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local debugger implementation discussion #241 - GitHub
The debug session starts from a temporary file with the main function is generated from the problem's template code. User can modify input...
Read more >
Debugging in Local (by Flywheel): A Beginner's Guide
In Local, there's a multi-pronged approach available for debugging. Here, we'll be discussing the default debug options included with Local, as ...
Read more >
A Debugger for Standard ML 1
Abstract. We have built a portable, instrumentation-based, replay debugger for the Standard ML of. New Jersey compiler. Traditional \source-level" debuggers ...
Read more >
Implementing record and refinement for debugging timing ...
In this section, we discuss our approach and its implementation as a basis for the Peek-At-Talk extension for debugging non-deterministic ...
Read more >
Debugging methods - DiVA Portal
In (normal) local debugging the same functions exists as when using remote debugging with remote and client stubs, except that with local ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found