90 points

let’s not act like Java’s error log is useful

permalink
report
reply
131 points
*
Deleted by creator
permalink
report
parent
reply
52 points
*

Super-advanced java devs like me do it like try{} catch (Exception e) { System.out.println("something went wrong"); e.printStackTrace(); }

permalink
report
parent
reply
7 points

you can follow any exception down to the exact line of code

Which is usually not a piece of code written by us and is caused by another piece of code not written by us either

permalink
report
parent
reply
5 points
*
Deleted by creator
permalink
report
parent
reply
10 points
*

Does your IDE not highlight the lines written by you in a different colour? Of course that doesn’t help when it’s an error in production!

permalink
report
parent
reply
4 points

but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs.

But, it’s not really where the problem occurred. How often do you get a stack trace and the bug fix is at the line referenced by the stack trace? Almost never. It’s more that it takes you down to the exact line of code where the effects of the problem are bad enough to affect the running of the program. But, the actual problem happened earlier, sometimes much earlier.

For example, NullPointerException isn’t actually the problem, it’s a symptom of the problem. Something didn’t get initialized properly, and nobody noticed for a while, until we tried to use it, and got a null pointer. Sometimes it’s easy to go from the effect (null pointer) to the cause (uninitialized thing). But, other times that “thing” was passed in, so you have to work backwards to try to figure out where that thing comes from, and why it’s in that broken state.

Sure, it’s better than nothing, but it’s still frustrating.

permalink
report
parent
reply
13 points
*
Deleted by creator
permalink
report
parent
reply
16 points

I think it’s pretty useful, be interested to hear your hangups with it though because it’s definitely not perfect.

If something goes wrong and I have a stack trace, that plus the type of exception will almost always be enough for me to figure out what’s wrong at least as a starting point. I’ve worked mostly with JVM languages in my career though so maybe I just don’t know how bad it actually is.

permalink
report
parent
reply
1 point

It’s not bad. It’s better than what most languages give you

permalink
report
parent
reply
10 points

skill issue

permalink
report
parent
reply
7 points

The same applies to using the core dump.

In fact, the Python one is the lest useful of the trio.

permalink
report
parent
reply
10 points

When the day comes that you need gdb you will indeed be amazed at how fucking powerful it is. If your server crashes grab that core dump!

permalink
report
parent
reply
1 point

Implying you can’t consistently go to the same line every time and it always has what you need.

permalink
report
parent
reply
7 points

It’s extraordinarily useful

permalink
report
parent
reply
18 points

The developer must either provide the logging and attach a debugger or go get fucked when a runtime error happens

permalink
report
reply
7 points

are you c++?

permalink
report
parent
reply
10 points
*

That’s not true though. You can get the backtrace and other useful information from the coredump mentioned by the error message by loading it with gdb. Not as good as attaching it to a living process, since you can’t see step-by-step what happens leading up to the error, but still quite useful.

permalink
report
parent
reply
3 points

Well yes, that’s a pretty good way of debugging a third party app but if you are developing something you can have more ease with gdb attached

permalink
report
parent
reply
6 points

You can also debug post-mortem with the minidump or the core dump file with WDT on Windows. Great fun and a good way to brush up on your assembly skills

permalink
report
parent
reply
2 points

Great fun and a good way to brush up on your assembly skills

Just load it on the debugger and leave your asm skill gather patina.

permalink
report
parent
reply
84 points

My favorite compile error happened while I was taking a Haskell class.

ghc: panic! (the ‘impossible’ happened)

The issue is plainly stated, and it provides clear next steps to the developer.

permalink
report
reply
50 points

I had a similar error, though not from the compiler
Error message just read this should never happen

permalink
report
parent
reply
11 points

Ah, good old PlarformIO

permalink
report
parent
reply
17 points

I know this is supposed to be humorous, but there’s a reason why these languages can, and are doing what they’re doing.

Core dumps are also worth learning about, they’re really helpful if you understand them.

permalink
report
reply
59 points

gdb: Am I a joke to you?

permalink
report
reply
36 points
*

Yes. It’s a surprisingly bad debugger the more you think about it. I use it largely in assembly and it loves to spit out random errors about memory it tried to access based on the current register state. The shortcuts are kind of dumb.

It certainly works but I wouldn’t call it a pleasure to use.

Ex: try disp x/1i $eip often just doesn’t work.

permalink
report
parent
reply
6 points

I use gdb with great success for x64, rv64, and c:

info registers rip or just setup tui:

# ~/.config/gdb/gdbinit:
tui new-layout default regs 1 {-horizontal src 1 asm 1} 2 status 0 cmd 1
tui layout default
tui enable
permalink
report
parent
reply
1 point

I honestly vastly prefer using IDA and Windows specific tools (x64dbg) over gdb. IDA can interface with gdb so it can act as a frontend which can be handy for visualization.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 5.3K

    Monthly active users

  • 1.5K

    Posts

  • 33K

    Comments