Author Topic: Some suggestions for C::B improvements  (Read 5326 times)

Offline kevinxy

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Some suggestions for C::B improvements
« Reply #15 on: November 15, 2015, 11:07:14 am »
Hello! I need more help.

I kind-of fixed it, but the fix should be regarded more as a proof-of concept.

I disabled a lot of things for which I couldn't figure out what they are for (I guessed: nothing).

It works with structures, vecors, doubly and triply nested.

I don't know how to run your unit tests, I'm on Windows+ TDM gcc 4.81 + wx 2.8.1, CB 13.12 (I used the CB wx2.8.x project file to compile CB with CB).

CB always does some post build-steps to compile CB , and that takes forever and it made debugging awkward.

So, if someone could test it a bit, live and with unit test, that would also be of great help!

The fixed file is here:
http://www.programming4beginners.com/outgoing/parsewatchvalue.cpp

And, btw, the format is ambiguous. Has anyone tried contacting GDB developers?
« Last Edit: November 15, 2015, 11:19:46 am by kevinxy »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11647
    • Travis build status
Re: Some suggestions for C::B improvements
« Reply #16 on: November 15, 2015, 11:26:46 am »
And, btw, the format is ambiguous. Has anyone tried contacting GDB developers?
This format is not mean for parsing by machines. It is mean for humans. So I doubt they'll do anything.
We're just using the wrong API/protocol. We have to be using the gdb/mi protocol. I've started a plugin, but I have no time at the moment to continue working on it.

About running the tests: you need unittest++ and then find the test project in the debuggergdb folder. Build it and it will run the tests automagically.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11647
    • Travis build status
Re: Some suggestions for C::B improvements
« Reply #17 on: November 15, 2015, 11:41:12 am »
Applied the patch and these are the failures:
Code: [Select]
/home/obfuscated/projects/codeblocks/git/src/plugins/debuggergdb/debuggergdb_test_parser.cpp:259: error: Failure in RepeatingChars0: Expected t= {c=0x400d90 'A' <repeats 16 times>, "aa\"a"} but was t= {c=0x400d90 'A' <repeats 16 times>,[1]="aa\"a"}
/home/obfuscated/projects/codeblocks/git/src/plugins/debuggergdb/debuggergdb_test_parser.cpp:266: error: Failure in RepeatingChars1: Expected t= {c=0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, "aabba"} but was t= {c=0x400d90 'A' <repeats 16 times>,[1]=' ' <repeats 29 times>,[2]="aabba"}
/home/obfuscated/projects/codeblocks/git/src/plugins/debuggergdb/debuggergdb_test_parser.cpp:273: error: Failure in RepeatingChars2: Expected t= {c=0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, "aaa",a=5} but was t= {c=0x400d90 'A' <repeats 16 times>,[1]=' ' <repeats 29 times>,[2]="aaa",a=5}
/home/obfuscated/projects/codeblocks/git/src/plugins/debuggergdb/debuggergdb_test_parser.cpp:380: error: Failure in RepeatingChars11: Expected t= {[0]=0x4080d8 "1st",[1]=0x4080dc '.' <repeats 14 times>, "#", '&' <repeats 16 times>,[2]=0x4080fc "3th"} but was t= {[0]=0x4080d8 "1st",[1]=0x4080dc '.' <repeats 14 times>,[2]="#", '&' <repeats 16 times>,[3]=0x4080fc "3th"}
/home/obfuscated/projects/codeblocks/git/src/plugins/debuggergdb/debuggergdb_test_parser.cpp:388: error: Failure in RepeatingChars11_children_count: Expected 3 but was 4
FAILURE: 5 out of 116 tests failed (5 failures).

Next time please post a proper patch. See this for details http://wiki.codeblocks.org/index.php/Creating_a_patch_to_submit_%28Patch_Tracker%29
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kevinxy

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Some suggestions for C::B improvements
« Reply #18 on: November 15, 2015, 12:16:18 pm »
I just managed to run it with unittest++, and I got the same errors.

The errors are probably due to me disabling the entire 'repeating chars' segment in the code.

I can enable it back, to see whether it works.

But I'm wondering why is this 'repeating char' feature there at all? It would be easier for me to do debugging if I knew what the code is supposed to be doing.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11647
    • Travis build status
Re: Some suggestions for C::B improvements
« Reply #19 on: November 15, 2015, 12:36:44 pm »
The tests contain real output produced by gdb.
So this is how the output looks like in the real world.
I've not made this up.

My workflow, when changing code related to parsing is:
1. someone reports a problem
2. I inspect it and find what causes it
3. I add a test case
4. start modifying the code until all tests pass

This workflow guarantees that all supported cases still work after my modification.
Also I don't accept patches without new tests and if there are failing old tests.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kevinxy

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Some suggestions for C::B improvements
« Reply #20 on: November 15, 2015, 04:13:20 pm »
Fair enough.

I reenabled 'repeated chars'.

I added 4 or 5 additional unit tests.

Can someone test it just to confirm that I have set up everything correctly?

Also, a live test on some other version of GDB would be great.

Here is the patch.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11647
    • Travis build status
Re: Some suggestions for C::B improvements
« Reply #21 on: November 15, 2015, 05:17:54 pm »
Ok, passes all tests.

But I'm a bit concerned that you've special cased this just for std::vector.
If I remember correctly the old logic was a bit more generic.
I'll have to test if the parser still works for my custom containers.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kevinxy

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Some suggestions for C::B improvements
« Reply #22 on: November 15, 2015, 05:39:27 pm »
Well, why not?

note: the only important change and a 'special case' is the change of delimiters so that the string ", cap" is not cosidered to be a comma anymore.

The rest of the changes are either cosmetic, or removal of some complex cases and questionalbe flow control which seemed to me as completely unnecessary.

In fact, I was quite conservative, if I had more confidence, I would have removed about half the code. But before I do that I need at least to set up my development environment correctly, this ad-hoc setup that I glued together is quite frustrating.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11647
    • Travis build status
Re: Some suggestions for C::B improvements
« Reply #23 on: November 15, 2015, 06:11:34 pm »
Probably, I've not written tests for my custom containers. So if they use something different from ", capacity", they'll brake with the new changes.
But I'll be able to do the tests on Monday.

If you can remove half the code and still make the tests pass then I'm with it.
But every line of code is added because there is need for it, so I highly doubt you'll be able to do it.

BTW: I've attached a bit cleaner version of your code, more cleaning is needed to make it in a good shape for commit.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kevinxy

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Some suggestions for C::B improvements
« Reply #24 on: November 15, 2015, 09:50:13 pm »
Thanks for cleaning it up!

By the way, it will not completely break up if there is no ", capacity" string, it will just add some extra unwanted children. Actually, it will only do that when there is a non item-separating comma not followed by " cap".