Update:
with regard to multi-process debugging, some time ago I wrote a fun little feature that lets you open a debug server by sending a SIGUSR1 to a selected process/thread. A temporary substitute to multi-threaded debugging, also useful for debugging forked processes. I haven't pushed it to any remote repository yet, but I'm planning to.
I'm really keen on seeing your your changes related to thread naming and debugging, Bill, that would be a huge step forward. Maybe you could push the changes to the repo?
I'm also thinking about a huge clean-up of the debugger branch, even branching out of the freshest master and merging/rewriting previous changes in a more elegant way.
Any chance for me to get access to the official Pike repository? It would me much more comfortable to have my own branch/branches instead of working with a forked github repo mirror.
niedz., 7 kwi 2019 o 12:44 Mateusz Krawczuk krawczukmat@gmail.com napisał(a):
I've verified my hypothesis and made breakpoints in classes work with commit [1]. The way I did it solves the problem, but I believe it should have been done on a lower level.
I've also looked up the program cache and verified that there in fact already is such a structure. I'll work on avoiding the necessity to double it.
[1] https://github.com/mkrawczuk/Pike/commit/bbdf2c23fb536ef42f0d83d14af84a06849...
wt., 2 kwi 2019 o 14:55 Mateusz Krawczuk krawczukmat@gmail.com napisał(a):
That's good news, looking forward to see the update!
My branch is a little specific - I've completely disabled the Hilfe debugger, replacing it by the debug adapter. For this reason you need a DAP-compliant IDE to test on my branch. The examples I provided earlier should suffice, but if you have any problems running it - do not hesitate to ask.
Previously I expressed myself incorrectly. I did not mean class methods (usually called static methods). What was on my mind were the methods, i.e. functions defined inside a class (nested program, in Pike terminology), that can be called on objects instantiating the given class. You currently can't break on them. For example, given
class C { int a; void create() { a = 1; werror("%d\n", a); }
void f() { ++a; werror("%d\n", a); } }
int main(int arc, array(string) argv) { C c = C(); c->f(); werror("c->a: %d\n", c->a); }
It will not stop on breakpoints set inside C's create() and f(). Setting breakpoints inside main() should go fine though.
I did a little research and I might have a potential fix for it. Looks like nested programs are getting their own separate entry. So all the data related to nested programs, like line offsets, are stored in a different object for each defined class. What is done now in debug_breakpoint class's low_enable_breakpoint, is calling low_get_offset_for_line only for one program object that is directly related to the file. What should be done instead, is checking all the programs originating from a given file, so the nested programs are also checked for the needed line offset.
So what I need is to get a list of program objects from a provided file string so I can loop through it. It needs to be available in builtin.cmod. Nothing comes to my mind on how to do it, any help is strongly appreciated.
śr., 13 mar 2019 o 15:01 H. William Welliver III william@welliver.org napisał(a):
That’s cool. I suspect that Parser.LR may require a bit of work to make it nicer to build a parser of this complexity, but I think it would be worth the effort, as it would allow a lot of interesting information to be extracted from pike classes… dependency graphs, data to allow refactoring, various types of analysis, etc.
I’ll also take a look at your branch; I sort of gave up trying to keep my branch in sync with some of the changes Grubba has been making to support live backtrace frames and such. I also have some changes to the thread object that permits setting of names on threads (very useful when debugging) and being able to break execution on a thread regardless of whatever it’s running, etc.
Bill
On Mar 13, 2019, at 8:48 AM, Mateusz Krawczuk krawczukmat@gmail.com wrote:
CCing dozzie (aka Jarowit). He is proficient with parsers and is eager to put some effort to carry this step on.
pon., 11 mar 2019 o 17:43 Mateusz Krawczuk krawczukmat@gmail.com napisał(a):
What exactly is this hypothetical parser needed for? Can you give more detail on what is needed?
I've been working on the debug adapter for a while now and made it possible to work with DAP-compliant IDEs, like VScode. You can check it out at the 'debugger' branch of my Pike fork [1]. Breakpoints, stack trace and variable browsing seems to work pretty well. I've also made it possible to attach to a running Pike process and set breakpoints at runtime. To make it possible I've introduced a program cache, which is string-program mapping. It exists in the master object and is updated every time a program is loaded. It is needed because the way we handle breakpoint initialization deferring is insufficient for this scenario. I wonder how does it affect memory optimization.
One major thing that is missing is setting breakpoints on class methods. Any clues how to implement it?
[1] https://github.com/mkrawczuk/Pike/tree/debugger
czw., 7 lut 2019 o 19:14 H. William Welliver III william@welliver.org napisał(a):
Update:
I took a little time this morning and merged grubba's local variable names branch with the debugger branch, and it looks pretty good.
Seems to me that the next piece of infrastructure that's needed probably involves some sort of Pike parser. I've looked at the java parser a bit and I'm not really happy with it. Perhaps it would make sense to extend Parser.LR to work with Parser.C.Tokens and generate a pike grammar for use with it?
I looked a little bit at Parser.LR and it looks like some features we'd want might not be complete (like %token) or that would make maintaining similarity with the existing grammar (like |). Does anyone have much experience using Parser.LR or might have some real examples?
Bill
February 6, 2019 8:20 PM, "H. William Welliver III" < william@welliver.org <%22H.%20William%20Welliver%20III%22%20%3Cwilliam@welliver.org%3E>> wrote:
I think there’s a sense that the parts of the debug infrastructure that run within the process under debug should be as lightweight as possible, and not be active unless the process is being debugged. In keeping with this line of thought, I think the in-process portion of the agent shouldn’t be fully featured, as that would imply that it would be parsing code for metadata like block locations and the like (for stepping over, etc). The —debugger option is intended to be the mechanism which activates the in-process debugging agent. If your concern is that connecting to a hilfe session is not an ideal debugging tool, that is true, but it was never my intention for that to be the final state. Rather I had some code that served a similar purpose and it didn’t make sense to go off building a lot of infrastructure if the premise wasn’t workable. Something along these lines is what I had in mind: Debugging Tool <— DAP —> Debug Agent <— DAP-lite —> Pike process under debug Now, the debugging tool and Debug Agent could theoretically be a single process, such as a command line debug utility along the lines of gdb, and it could possibly know how to start a pike process for debugging or could also just allow connecting to a running pike process which has the debugger enabled. This is basically how the Java debug agent works, and it allows local and remote debugging, which is pretty handy. Bill