c0de517e,
@c0de517e@mastodon.gamedev.place avatar

Is there a way to set a breakpoint on the first instruction of a program, in visualstudio? No I don't mean on main - I mean on the very first thing, i.e. global constructor code. Also, I tried to set a breakpoint on mainCRTStartup and... it doesn't trigger? I suspect there is some write protection so that the debugger can't patch the int instruction? Is this a new thing?

breakin,
@breakin@mastodon.gamedev.place avatar

@c0de517e I was able to step out of my main and find mainCRTStartup and friends. Breakpoints there worked, at least in debug build. Static constructors are run from mainCRTStartup I guess but there are some hidden layers.

breakin,
@breakin@mastodon.gamedev.place avatar

@c0de517e I want to remember that vs at some point had an option to launch a program with debugger attached and breaking it right away, but it might be a dream.

breakin,
@breakin@mastodon.gamedev.place avatar

@c0de517e Visual C++ 2022 community 17.7.1 here under Windows 10 btw.

c0de517e,
@c0de517e@mastodon.gamedev.place avatar

@breakin win11/vs22 enterprise, every time I try to put a break on mainCRTStartup it gets disabled and does not trigger - but I side-stepped the issue by creating a static instance in a translation unit marked with pragma init_seg(compiler)

breakin,
@breakin@mastodon.gamedev.place avatar

@c0de517e Not sure if work computer but hard balance for IT between keeping us safe and not keeping us from doing our job I guess!

rvkennedy,
@rvkennedy@mastodon.social avatar

@c0de517e breakpoint, I don't know. But just pressing F10 will get you there.

c0de517e,
@c0de517e@mastodon.gamedev.place avatar

@rvkennedy not really, it gets to the userland winmain, not the library and definitely not the first code instruction (all of that is way after all global init)

rvkennedy,
@rvkennedy@mastodon.social avatar

@c0de517e Yes you're quite right. Interestingly, breakpoints can be set e.g. in main.cpp on any line that produces runtime code, such as a declaration that launches a constructor. But how to stop at the first code.. Looking up my callstack (and this will be compiler- and runtime-dependent) I see a fn called _initterm() which loops through initializer functions calling them in turn. This seems to be where the globals are created. You can break in _initterm, I don't know if that's the first.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • everett
  • InstantRegret
  • rosin
  • Youngstown
  • slotface
  • love
  • khanakhh
  • kavyap
  • tacticalgear
  • GTA5RPClips
  • thenastyranch
  • modclub
  • megavids
  • mdbf
  • normalnudes
  • Durango
  • ethstaker
  • osvaldo12
  • cubers
  • ngwrru68w68
  • tester
  • anitta
  • cisconetworking
  • Leos
  • provamag3
  • JUstTest
  • All magazines