• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Am I being debugged?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Am I being debugged?


  • Subject: Re: Am I being debugged?
  • From: Kevin Grant <email@hidden>
  • Date: Tue, 17 Feb 2004 19:13:46 -0600

In my Development build, I would like to be able to determine (at runtime)
whether I am running inside gdb, or just running normally. What is the best
way to do this?


Also, could I determine if I started normally, but have been attached to
gdb?


A fairly simple test:

	if (isatty(STDIN_FILENO))
	{
		. . .
	}

This is true whenever you debug in Xcode or with gdb from a terminal, and is never true if you launch from the Finder. While technically the code above would also return true any time you launch your application from a terminal shell, users aren't likely to do this. So, "probably" it means you are being debugged.

Kevin G.
http://homepage.mac.com/kmg/
mail to kevin at ieee dot org
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Am I being debugged? (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: Warnings disable build commands
  • Next by Date: Leaks
  • Previous by thread: Re: Am I being debugged?
  • Next by thread: Why do some build settings have lines through them?
  • Index(es):
    • Date
    • Thread