[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Debugging
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 56
Thread images: 6
File: Vimlogo.svg.png (90 KB, 1022x1024) Image search: [Google]
Vimlogo.svg.png
90 KB, 1022x1024
Programmers of /g/ who write their code using in a terminal editor like VIM instead of a dedicated IDE like Codeblocks,

do you use gdb and a terminal window to debug your code?

I'm writing a small project using vim instead of an IDE and I'm stuck.

How can I effectively debug using my terminal?
>>
>>53164888
I don't understand the question. You've already said "use gdb" which is the answer.

Look at backtrace, disassemble functions, cast pointers, read memory, find bug.
>>
>>53165028

I mean how can I do it faster or more effectively than using plain gdb in console.

It seems like I need 4 times as long to do the same thing with plain gdb in console than I need within an IDE and a few clicks.

Are there /g/ approved vim plugins for debugging?
>>
>>53165058
use and IDE that supports gdb like netbeans for c/c++
>>
File: 1410970252271.jpg (10 KB, 236x294) Image search: [Google]
1410970252271.jpg
10 KB, 236x294
>>53164888
>VIM
>>
File: gdb.jpg (5 KB, 200x125) Image search: [Google]
gdb.jpg
5 KB, 200x125
>>53165058
no, trust me. the only way you can effectively debug something without a good ide is with your terminal.

you will be less productive for long time, but you know what you get when you choose a text editor instead an ide (expecially for c++).
>>
>>53165109

Sure I could do that.

But the point is that I want to use terminal applications for this project. Just for trying stuff out and for fun.
>>
>>53165058
Ah I get you. I've heard of Clewn but I've never used it.
>>
>>53165152

Allright thanks,

it's mainly for serverside programing.

I also tried to ssh into the server and then start an IDE with X forwarding, but it's a big too laggy for me.
>>
>>53165153
then no. that's why IDEs exist. to make it easier and faster than the cli
>>
>>53164888
>debugging
My debug process is that I don't write shit code
At which point if I do write shit code, I make a note to fix it
My first priority on my programs is those notes
Congratulations! No bugs!
>>
File: 1456267542381.jpg (34 KB, 447x444) Image search: [Google]
1456267542381.jpg
34 KB, 447x444
>>53165286

Sure thing, that's fun with all those pointers and memory allocation...
>>
-tui

or pipe into a terminal with a low-level C redirecting program that checks the ^Z^Z at the beginning of lines that act as gdb location indicators and open that in a remote vim session like a real G
>>
>>53165286
enjoying your 50 line programs?
>>
>>53164888
Last time I checked, even vi creator disliked Vim.

Also, many Vim users were so horrified of Vim's spaghetti code, they forked it.

Too bad any other popular alternative is terrible.
>>
>>53165922
Vim doesn't have spaghetti code, just too much relating to backwards compatibility.
>>
>>53164888
Use printf if you can. Add output in strategic locations and verify that it does what you think it should. This works most of the time.
>>
>>53165768

It can be done on real projects too, of course you need to follow modern programming practices, like tdd, continous integration, merciless refactoring and so on, have a decent software process (ie not waterfall) but yes it can be done.

/g/ never talks about those techniques tho. I suspect this is due to the vast majority here being merely hobbyists.
>>
>>53166703
protip: use the word "enthusiasts" instead of "hobbyists" if you really want to come off as an academic dickhead.
>>
>>53166753

Ah just trying to get a rise outta ya m8, thats all!
No offence intended.

Also not an academic, those techniques are out there in the wild, I've used them, they work.
>>
>>53164888
>How can I effectively debug using my terminal?
By learning how to use gdb.

Literally just Google for gdb tutorials. You'll probably end up at Beej's guide, or something similar. Find a gdb cheatsheet and start using it.

Did you know you can reverse the flow of execution in gdb if you accidentally step too far past an interesting instruction?
https://sourceware.org/gdb/onlinedocs/gdb/Reverse-Execution.html#Reverse-Execution

You can do literally anything in gdb if you know how. You could write a script that uses gdb to attach to a running process at runtime, change the value of variable (say, to change the logging level), detach, and then enjoy debug level logging for the rest of the lifetime of the process.
>>
>>53166779
>tdd
>they work
lmao. Like that one tdd messiah that tried implementing sudoku solver with tdd and spent like 7 blogposts on it, never finishing it.

Nice buzzwords, m8.
>>
>>53164888
>do you use gdb and a terminal window to debug your code?
No. The last time I attached gdb to a core dump of a program I work on, I discovered that top has a "t" unit for terabytes of RSS.

>How can I effectively debug using my terminal?
No idea, I use printf debugging. My coworkers at this huge, name-brand tech company do the same.

I miss ViEmu with Vim's keybindings and Visual Studio's debugger.
>>
>>53166838

So one person failed proves it doesnt work?
Gee I guess linux is shit then cos of all the people who post here everyday who have problems installing it. Yeah, that must be it.
>>
>>53164888

literally goggling gdb frontend....

https://www.gnu.org/software/ddd/
>>
>>53166922
If a guy who preaches it can't do it, it is probably not that good. And sudoku solvers are not that fucking difficult to write; I wrote one in high school. His attempted solution also ended up being fucking horrible over-engineered shite.

I'm not going to argue with you, but you can read all about this at http://ravimohan.blogspot.si/2007/04/learning-from-sudoku-solvers.html

Do note though that I'm not arguing against unit tests.
>>
>>53165058
>>53165164
clewn is fine, just set up bindings and it works the same as an ide. honestly though, you don't need it. just using gdb is better, once you get comfortable with the commands and workflow you'll be way faster
>>
>>53167019
>If a guy who preaches it can't do it, it is probably not that good.

No, your logic if flawed, any idiot can "preach" that doesnt mean anything. There are many many people who can and are doing it. Check out the scrum/xp lists.

>Do note though that I'm not arguing against unit tests.

Good to hear. A question for you then, have you ever found that when you write your unit tests for code you already have that you have to change the design of your code to be able to test it?
>>
Why do you intentionally gimp yourself?

Use a fucking ide.

QtCreator
Code blocks
Eclipse for c++

Those are the ones I've used.

Stop using a terminal to code, be normal and up your productivity by using an ide. Unless you are changing only one or two lines, use an ide.

I saw one of you vim fags in class using his stupid unintuitive macros to do simple things like searching and replacing.
>>
>>53167091
Well if you don't like the word preaching, use teaching instead, since that's what he's doing with his books (apparently, I admit I never bothered to read them).

>when you write your unit tests for code you already have that you have to change the design of your code to be able to test it?
Very very very rarely. Design inspired by functional programming makes functions pretty easily testable.

But I most definitely don't start solving a problem by first writing a failing test and then design my solution around that. I figure out a solution, implement it, and during implementation use unit tests to check that some of the more complicated functions I write work as I want them to.
>>
>>53167104
>using his stupid unintuitive macros to do simple things like searching and replacing.
are there other ways of doing that then /foo and
:s/foo/bar/
>>
>>53167398
>I never bothered to read them

Well, if you're ever curious, I'd suggest one of the more notable teachers of that stuff, kent beck, ron jeffries, robert martin, martin fowler, or someone who signed the original agile manifesto.

>I figure out a solution, implement it, and during implementation use unit tests

Sure, and thats a lot better than most. I'm just suggesting that the agile techniques which were brought to prominence at the end of the last century by guys who had previously done what you were doing for decades is worthy of consideration.
>>
>>53167488
>Well, if you're ever curious, I'd suggest one of the more notable teachers of that stuff
>ron jeffries
If you checked the link you would know that that is exactly who I'm talking about.
>>
>>53167519

Ha! Ok you got me, I just went and read the link. Its interesting. I think if you read the comments on the article the ones by keithb are I think pertinent. tdd is not a silver bullet by any means but it has to be seen in the context of what came before which is waterfall. On non-trivial problems, ie not sudoku where the abstractions are known from the get-go, its a better technique that Big Upfront Design, which suffers from the illusion that you can know everything before you've even started, you cant.
>>
>>53167693
Stop. With. The. Buzzwords. Jesus Christ.
And you are now the one making false assumption by pretending its just ````Big Upfront Design'''' or TDD with no other option in between.
>>
>>53167410
even better
:s//bar/
. // calls up the last search in history
>>
>>53167410
>>53167867
This has the problem of (at least) ignoring scopes. Even as a long-time vim user, renaming shit is much nicer in ide.
>>
>>53167903
what do you mean by ignoring scopes
>>
>>53167829
>stop the buzzwords.
>then uses buzzwords.
>>
>>53167940
I mean it renames too much shit; for example:
int a = 3;
{
int a = 2;
b = a + 2;
}
return a;

Your solution would rename every `a' here, but maybe you only wanted to rename the outer `a' or the inner one.
>>
>>53167965
I only used the buzzwords he used though.
>>
>>53165286
Agree. If you need to debug your code you have no idea what you're doing
>>
>>53168579
>>53165286
Lol....
So I guess you guys are fizzbuzzers, have never written anything big/complicated, and never have worked somewhere where you had to find a bug in code someone ELSE wrote?
Yeah, fizzbuzzers.
>>
Emacs has excellent gdb integration.
>>
File: 1440167717015.jpg (14 KB, 255x255) Image search: [Google]
1440167717015.jpg
14 KB, 255x255
>>53169772
it's just troll shit. they do this all the time. if you ask questions they keep spouting memes without directly responding.
>>
>>53164888
>do you use gdb and a terminal window to debug your code?
Not really. I mostly use the debugging facilities that I build into my own programs.

I'm not an experienced gdb user even in the slightest.
>>
>>53164888
DDD isn't bad
>>
>>53164888
cgdb
>>
>>53171678
Valve uses cgdb btw.
>>
File: gdb-many-windows.gif (178 KB, 1200x900) Image search: [Google]
gdb-many-windows.gif
178 KB, 1200x900
>>53165058
Emacs integrates really nicely with gdb, and includes a traditional multi-window debugging setup for gdb.

Terminal debugging is also great.
>>
>>53164888
Install tmux and vimux, it allows you to split the terminal window and run commands within vim. I managed to tweak my vim to do anything an ide can, except dot completion for objects, but it takes time.
Otherwise I'd recommend you to use emacs with evil or install spacemacs if you don't want to edit your .emacs for weeks.
>>
>>53167903

there are plugins for refactoring...
s:/foo/bar/
is plain text replacement
>>
Just use syntastic.
https://github.com/scrooloose/syntastic
>>
>>53164888
VIM is great but at one point, a dedicated IDE will save you lots of time. Plus it's almost essential if you're in a pool of programmers.
>>
>>53172900
I never claimed there isn't any way to do the replacement, I just said it's not as simple as
:s/a/b/
.

I am usually completely fine with just visually selecting the approximate scope I want to change and using /c to manually confirm replacement.
>>
>>53172998
Syntastic can be used for checking your code is syntactically correct, not for debugging.
Thread replies: 56
Thread images: 6

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.