Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Management
Jan 2, 2010

sup, bitch?
I realize that in school they taught you to use print statements to trace your code. that’s amateur level poo poo. if you’re being paid to write code, it’s time to start using tools like a professional. learn how to use a debugger. I’ve debugged all kinds of code, from low level boot loaders whose only io was blinking a single LED to great big multithreaded monsters that spew gigs of logs. and I was able to use a debugger on all of them to make my life better and so can you.

when you start a project, the first thing you do after writing the boilerplate main function is get the debugger working. for most of you writing normal programs, it’s as easy as running the debugger that comes with your tool chain, zero effort. remember to add the debug symbols flags to your build. if you’re working with an embedded target or simulator or FPGA or gpu or whatever, it will take more work. whether it’s a debug server or jtag or ICE or some other nonsense, get that poo poo up and running before writing any more code. set up core dumps. get stack traces from crashes.

if you are asked to join a project, ask them how they debug. if they say printf tell them to get hosed. or fix that. whichever. but if they don’t want to fix it, definitely the former. if the language doesn’t support a debugger, it is a bad language and you should not use it. if your board doesn’t have a debug port, send it back to the idiots that made it and tell them it’s broken.

it’s time to put on our big boy pants and start acting like professionals.

Adbot
ADBOT LOVES YOU

The Management
Jan 2, 2010

sup, bitch?

gonadic io posted:

tell me how to use remote gdb/lldb with clion and rust please op. my target has such little memory that the the debug symbol file can't even fit on the device so i have printlns with a 20 min bitbake build it loving suuuuuuucks

why would you put the symbols on the device? symbols are for your debugger, they should stay on the host. load the unstripped image in the debugger when you connect.

The Management
Jan 2, 2010

sup, bitch?

DuckConference posted:

every time I connect symbolication takes 5-10 minutes

and a bunch of symbols are still missing anyway. and hopefully you're on the right thread because the process has 70+

are you pulling symbols from the execution image or from the debug binary? most compilers are pretty good at generating efficient lookup tables for symbols in debug data. they tend to get huge though. also you’re probably symbolizing a lot of libraries, possibly fetching their debug data from a remote machine if your environment is complex enough. have you tried caching them locally?

The Management
Jan 2, 2010

sup, bitch?

gonadic io posted:

tell me how to use remote gdb/lldb with clion and rust please op. my target has such little memory that the the debug symbol file can't even fit on the device so i have printlns with a 20 min bitbake build it loving suuuuuuucks

also implementing gdb protocol over uart is pretty easy if you just want to write your own stub.

the rust part I can’t help you with. despite what people keep saying, it’s unsuitable for systems programming.

The Management
Jan 2, 2010

sup, bitch?

horse_ebookmarklet posted:

Or maybe debugging rtos stuff is impossible.

it’s very possible. you will usually need to teach your debugger about the thread model, and if you have a really good one it will know about your interrupt context.

if your watchdog tripped, you should halt and look at the state of all the threads. check the scheduler context for them, who is blocked on what, who is doing what, figure out why the deadline is blown instead of guessing.

why does your build take 30 minutes? is your build system written in python?

The Management
Jan 2, 2010

sup, bitch?

CRIP EATIN BREAD posted:

i learned to use gdb in school, op

good start.

The Management
Jan 2, 2010

sup, bitch?

Private Speech posted:

In my previous job I couldn't attach a debugger because a) the SoC didn't have enough free pins for an UART unless I disabled some important functionality, and b), parts of the board could potentially literally catastrophically fail if the execution stopped in an importune moment.

I didn't have access to printfs either though, had to do with debug registers.

sounds like the hardware designers really hosed up here. they picked a bad chip with a bad configuration. I suggest you return the board to whoever made it and tell them to fix their lovely design. debugging is not an option, it’s a requirement for software to work correctly.

Ciaphas posted:

tell me how to live step-debug on 15 year old win CE 6 r3 devices, op

install visual studio 6 or whatever it was at the time, get MTP going over a usb connection, live step debug. visual studio had an amazing debugger.

The Management
Jan 2, 2010

sup, bitch?
I could have made a career out of telling hardware and ops people that their poo poo is broken because you can’t debug it. it amazes me that idiots still make boards that have no hard debug interfaces, or that significantly reduce functionality to enable debug.

at Apple, the low level software team signs off on schematics before they are approved. you can bet nothing gets signed off if it’s not debuggable. tell your boss and your PMs and your hardware folks that you will not be accepting undebuggable boards and you expect to sign off on designs and chip selections before they make the boards. so say we all.

The Management
Jan 2, 2010

sup, bitch?

Ciaphas posted:

realpost: tldr, but suffice to say MTP is seemingly impossible to get working, Hardware took the UART out of the "newest" revision, whatever module provides ActiveSync doesn't work reliably for debugging via IP, and even if by some miracle it DOES all work, the machine is too gutless to run a debug executable at anything other than unreasonable treacle-like speeds. we're on vs2005 for that so when it does work it at least works well, but yeesh what a fuckin farce to get there and god help me if what i need to test is buried behind slow-running actions

it's pretty crap but at least it's being greenfielded away to unix boxes in the next year (to Golang [ :| ] )

right, activesync not mtp. it’s been a long time since I’ve winced. my experience with it has been pretty good debugging-wise, but I suppose it depends on the BSP.

golang? enjoy your giant binaries.

The Management
Jan 2, 2010

sup, bitch?

hifi posted:

i feel like i had a breakthrough the other day, instead of looping through a code structure that segfaults, you can just let it fail and then reverse until it's back in the code you wrote.

using a debugger is like solving a maze by starting from the end. break when an error happens, figure out how you got there instead of figuring out all of the possible ways to get there

The Management
Jan 2, 2010

sup, bitch?

suffix posted:

the race condition doesn't happen anymore when you attach a debugger

debuggers are fairly innocuous for things like that. you generally add some breakpoints at the start and then run. printfs, on the other hand, can have massive implications on timing as well as changing code generation to hide some bugs.

The Management
Jan 2, 2010

sup, bitch?
printf(“%s:%u\n”, __FUNCTION__, __LINE__);

repeated a thousand times in your file

The Management
Jan 2, 2010

sup, bitch?
debugger UI is very important and vastly underrated. having a window where you watch memory changing, one that shows you a backtrace, one that shows mixed code and assembly, one that shows local variables, and one that shows the cpu registers is a world away from a command line gdb where you have to reinspect everything you care about after every step.

The Management
Jan 2, 2010

sup, bitch?
I wrote this thread because my current project doesn’t have a debugger because dumb reasons and I’m using printf() and I want to die

The Management
Jan 2, 2010

sup, bitch?

Poopernickel posted:

I'm writing a kernel module right now, and printk is way easier than trying to gdb that poo poo

Linux kernel debugging is a POS, so printk is your only option.

The Management
Jan 2, 2010

sup, bitch?

akadajet posted:

trying to imagine debugging an os kernel and laughing at the thought

just stop all cores with jtag and debug, what’s the problem?

The Management
Jan 2, 2010

sup, bitch?

pram posted:

osx has lldb and dtrace which is p good

lldb is terrible.

The Management
Jan 2, 2010

sup, bitch?
lldb is bad. even with a huge amount of debug info the compiler now emits it still does a terrible job of getting local variable values. and it’s way too verbose for a command line interface, mostly because it was designed as a backend tool for Xcode, not for direct human interaction.

Adbot
ADBOT LOVES YOU

The Management
Jan 2, 2010

sup, bitch?

akadajet posted:

is lldb the thing that makes it so that xcode never shows you actual values of symbols you hover your mouse over?

yes.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply