Program which behaves differently in/out of a debugger [on hold]Create a chain of spam generators in as many languages as possibleBrainf**k DebuggerOutput the first 200 primes using TeXWrite a program that reverses the name of its source fileWrite a program that outputs the number of times it has been runCheating Cyclic QuinePick a random number between 0 and n using a constant source of randomnessKlein TopololyglotsMake a Geiger CounterLongest Seven Segment Word
Does the talk count as invited if my PI invited me?
How to get all possible paths in 0/1 matrix better way?
When did Britain learn about the American Declaration of Independence?
Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?
Told to apply for UK visa before other visas
Why does the U.S military use mercenaries?
Good examples of "two is easy, three is hard" in computational sciences
Have the writers and actors of GOT responded to its poor reception?
Can ThermodynamicData be used with NSolve?
Why are there five extra turns in tournament Magic?
Can a generation ship withstand its own oxygen and daily wear for many thousands of years?
Why wear sunglasses in indoor velodromes?
Taylor series leads to two different functions - why?
What color to choose as "danger" if the main color of my app is red
Was Tyrion always a poor strategist?
Have GoT's showrunners reacted to the poor reception of the final season?
Can the word crowd refer to just 10 people?
What should I wear to go and sign an employment contract?
Parse a C++14 integer literal
How many Dothraki are left as of Game of Thrones S8E5?
Hotel booking: Why is Agoda much cheaper than booking.com?
How do you cope with rejection?
Gaussian kernel density estimation with data from file
Does the US Supreme Court vote using secret ballots?
Program which behaves differently in/out of a debugger [on hold]
Create a chain of spam generators in as many languages as possibleBrainf**k DebuggerOutput the first 200 primes using TeXWrite a program that reverses the name of its source fileWrite a program that outputs the number of times it has been runCheating Cyclic QuinePick a random number between 0 and n using a constant source of randomnessKlein TopololyglotsMake a Geiger CounterLongest Seven Segment Word
$begingroup$
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.
For example, the program may output something when being debugged but not output anything when not being debugged. Or output something different in each case. Or it may crash when being debugged but not crash when not being debugged. Or vice-versa.
Caveats and clarifications:
- Timing differences do not count.
- Interpreted languages are permitted.
- To emphasize determinism: the behaviour must be exactly reproducible both in and out of debugging context.
- The presence of the debugger itself should the only difference between the two cases.
- Telling the debugger to add inputs (stdin or argv ENV or whatever) is cheating, the debugger should run the program "as-is".
- Changing the environment (e.g. running in a virtual machine or different OS, or changing OS settings such as memory limits) between debug and non-debug runs is not permitted.
Shortest code wins. I may award a bounty which reveals something interesting about how debuggers work.
code-golf
$endgroup$
put on hold as unclear what you're asking by MilkyWay90, Stephen, mbomb007, Sriotchilism O'Zaic, Taylor Scott May 13 at 19:44
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 3 more comments
$begingroup$
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.
For example, the program may output something when being debugged but not output anything when not being debugged. Or output something different in each case. Or it may crash when being debugged but not crash when not being debugged. Or vice-versa.
Caveats and clarifications:
- Timing differences do not count.
- Interpreted languages are permitted.
- To emphasize determinism: the behaviour must be exactly reproducible both in and out of debugging context.
- The presence of the debugger itself should the only difference between the two cases.
- Telling the debugger to add inputs (stdin or argv ENV or whatever) is cheating, the debugger should run the program "as-is".
- Changing the environment (e.g. running in a virtual machine or different OS, or changing OS settings such as memory limits) between debug and non-debug runs is not permitted.
Shortest code wins. I may award a bounty which reveals something interesting about how debuggers work.
code-golf
$endgroup$
put on hold as unclear what you're asking by MilkyWay90, Stephen, mbomb007, Sriotchilism O'Zaic, Taylor Scott May 13 at 19:44
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
1
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
5
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
3
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
6
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24
|
show 3 more comments
$begingroup$
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.
For example, the program may output something when being debugged but not output anything when not being debugged. Or output something different in each case. Or it may crash when being debugged but not crash when not being debugged. Or vice-versa.
Caveats and clarifications:
- Timing differences do not count.
- Interpreted languages are permitted.
- To emphasize determinism: the behaviour must be exactly reproducible both in and out of debugging context.
- The presence of the debugger itself should the only difference between the two cases.
- Telling the debugger to add inputs (stdin or argv ENV or whatever) is cheating, the debugger should run the program "as-is".
- Changing the environment (e.g. running in a virtual machine or different OS, or changing OS settings such as memory limits) between debug and non-debug runs is not permitted.
Shortest code wins. I may award a bounty which reveals something interesting about how debuggers work.
code-golf
$endgroup$
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.
For example, the program may output something when being debugged but not output anything when not being debugged. Or output something different in each case. Or it may crash when being debugged but not crash when not being debugged. Or vice-versa.
Caveats and clarifications:
- Timing differences do not count.
- Interpreted languages are permitted.
- To emphasize determinism: the behaviour must be exactly reproducible both in and out of debugging context.
- The presence of the debugger itself should the only difference between the two cases.
- Telling the debugger to add inputs (stdin or argv ENV or whatever) is cheating, the debugger should run the program "as-is".
- Changing the environment (e.g. running in a virtual machine or different OS, or changing OS settings such as memory limits) between debug and non-debug runs is not permitted.
Shortest code wins. I may award a bounty which reveals something interesting about how debuggers work.
code-golf
code-golf
asked May 12 at 12:57
spraffspraff
516311
516311
put on hold as unclear what you're asking by MilkyWay90, Stephen, mbomb007, Sriotchilism O'Zaic, Taylor Scott May 13 at 19:44
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by MilkyWay90, Stephen, mbomb007, Sriotchilism O'Zaic, Taylor Scott May 13 at 19:44
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
1
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
5
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
3
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
6
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24
|
show 3 more comments
4
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
1
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
5
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
3
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
6
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24
4
4
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
1
1
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
5
5
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
3
3
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
6
6
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24
|
show 3 more comments
10 Answers
10
active
oldest
votes
$begingroup$
x86 and x64_64 machine language on Linux and OSX, 1 byte
0x0: CC int3
Try it online!
int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).
C (gcc) (x86 Linux and OSX), 14 11 9 bytes
main=204;
Try it online!
The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.
$endgroup$
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
$begingroup$
ActuallySIGTRAPdoesn't result inSIGABRT, so the part about callingabort()is wrong. There's simply no default signal handler forSIGTRAP, so the kernel terminates the process (and the parent can useWIFSIGNALEDto detect this andWTERMSIGto determine which signal happened).
$endgroup$
– Ruslan
May 13 at 16:02
add a comment |
$begingroup$
JavaScript on Firefox, 69 bytes
WARNING: This script may hang your browser! Do NOT test it with other browsers (e.g. Chrome) as it may crash your tab / browser.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)How: When debugger is enabled with console tab activated. console.log makes memory leak possible, and the program will run out of memory soon. When debugger is disabled, GC would clear memory allocated, and you would see an alert with text 1 finally.
$endgroup$
add a comment |
$begingroup$
T-SQL, 6 bytes
sp_who
Always returns an extra row under the executing user's name when the debugger is active.
$endgroup$
add a comment |
$begingroup$
MSVC (64-bit), 50 35 bytes
main()return IsDebuggerPresent();
Exits with code 0 normally but 1 under the debugger (note that WinDbg does not automatically display the exit code but you can fake it by examining the stack). Edit: Saved 15 bytes thanks to @Ruslan.
$endgroup$
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
add a comment |
$begingroup$
APL (Dyalog Unicode), 0 bytes
In Dyalog APL, debugger vs no debugger is choosen by running one's workspace in either the IDE interpreter or the runtime interpreter.
Loading a completely empty default settings workspace into the IDE interpreter, immediately drops the user into REPL mode as applications must actively shut down the interpreter for it to quit:

However, the runtime interpreter does not have a REPL mode, and so if an application comes to an end (for example because it is completely empty) and does not explicitly shut down the interpreter, it implicitly has attempted to reach REPL mode ("the APL session"), and complains:

$endgroup$
add a comment |
$begingroup$
Python, 29 bytes
import sys
sys.modules['pdb']
Without debugger (python3 /tmp/foo.py):
Traceback (most recent call last):
File "/tmp/foo.py", line 2, in <module>
sys.modules['pdb']
KeyError: 'pdb'
With debugger (python3 -m pdb /tmp/foo.py):
(empty output)
because pdb is loaded into an app-visible module in the second case.
$endgroup$
add a comment |
$begingroup$
Java, 131 102 bytes
v->(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()+"").indexOf(":jdwp")
When running without a debugger this function returns -1. When running with a debugger, this prints a positive integer.
Try it online!
This technically detects if you could attach a debugger; not if one is currently connected... Not sure if that's valid
-23 bytes thanks to Olivier Grégoire for mentioning that I can cut down on what I search for in the runtime parameters and for lambda-izing my answer
-5 bytes thanks to Benjamin Urquhart for noting that calling toString is dumb when I can let Java implicitly convert
$endgroup$
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on:jdwp, instead of-agentlib:jdwp. The:is to distinguishrunjdwpfrom-agentlib:jdwp. 108 bytes
$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing thetoStringenhancement here. Good catch!
$endgroup$
– Poke
May 13 at 15:08
add a comment |
$begingroup$
JavaScript, 17 bytes
debugger
alert(1)debugger stops execution if the debugger console is open, else it does nothing
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
Robotalk, 22 bytes
debug l: chronon l ifg
If the debugger is active, the debug instruction pauses execution until the end of the current game tick. In this case, the variable "chronon" is always 1 or greater when read, and the program executes an infinite loop. If the debugger isn't active, debug is a one-cycle no-op. "Chronon" is now 0 when read, the "ifg" branch isn't taken, and execution reaches the end of the code, which is an error condition.
$endgroup$
add a comment |
$begingroup$
MATLAB, 6 bytes
dbquit
When stopped in the debugger, this will quit debugging mode.
When not under debug, it will print an error message that it cannot be used when not stopped in the debugger.
It should be noted this only works for evaluation in the command window (one of the three ways of running MATLAB code). It won't work in a function or script as once you try to run the script or function, you stop being in debug mode during execution.
The closest you can get to something that will run in a function/script as well would be:
MATLAB, 22 bytes
feature('IsDebugMode')
This is an undocumented command in MATLAB. If you are stopped in the debugger in a script or function, and then call another function (or command evaluation) that contains the above line, it will return true.
Outside the debugger it will return false.
If you were however to just run a script/function containing the above, even if you add a breakpoint at the start of the script/function and step through, it will return false, because again, once you start executing you stop being in the debugger temporarily.
$endgroup$
add a comment |
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
x86 and x64_64 machine language on Linux and OSX, 1 byte
0x0: CC int3
Try it online!
int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).
C (gcc) (x86 Linux and OSX), 14 11 9 bytes
main=204;
Try it online!
The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.
$endgroup$
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
$begingroup$
ActuallySIGTRAPdoesn't result inSIGABRT, so the part about callingabort()is wrong. There's simply no default signal handler forSIGTRAP, so the kernel terminates the process (and the parent can useWIFSIGNALEDto detect this andWTERMSIGto determine which signal happened).
$endgroup$
– Ruslan
May 13 at 16:02
add a comment |
$begingroup$
x86 and x64_64 machine language on Linux and OSX, 1 byte
0x0: CC int3
Try it online!
int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).
C (gcc) (x86 Linux and OSX), 14 11 9 bytes
main=204;
Try it online!
The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.
$endgroup$
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
$begingroup$
ActuallySIGTRAPdoesn't result inSIGABRT, so the part about callingabort()is wrong. There's simply no default signal handler forSIGTRAP, so the kernel terminates the process (and the parent can useWIFSIGNALEDto detect this andWTERMSIGto determine which signal happened).
$endgroup$
– Ruslan
May 13 at 16:02
add a comment |
$begingroup$
x86 and x64_64 machine language on Linux and OSX, 1 byte
0x0: CC int3
Try it online!
int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).
C (gcc) (x86 Linux and OSX), 14 11 9 bytes
main=204;
Try it online!
The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.
$endgroup$
x86 and x64_64 machine language on Linux and OSX, 1 byte
0x0: CC int3
Try it online!
int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).
C (gcc) (x86 Linux and OSX), 14 11 9 bytes
main=204;
Try it online!
The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.
edited May 13 at 18:07
answered May 12 at 16:26
ceilingcatceilingcat
4,10211121
4,10211121
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
$begingroup$
ActuallySIGTRAPdoesn't result inSIGABRT, so the part about callingabort()is wrong. There's simply no default signal handler forSIGTRAP, so the kernel terminates the process (and the parent can useWIFSIGNALEDto detect this andWTERMSIGto determine which signal happened).
$endgroup$
– Ruslan
May 13 at 16:02
add a comment |
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
$begingroup$
ActuallySIGTRAPdoesn't result inSIGABRT, so the part about callingabort()is wrong. There's simply no default signal handler forSIGTRAP, so the kernel terminates the process (and the parent can useWIFSIGNALEDto detect this andWTERMSIGto determine which signal happened).
$endgroup$
– Ruslan
May 13 at 16:02
1
1
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
$begingroup$
clear assignment in the C code, haven't seen that before.
$endgroup$
– Tom
May 13 at 9:18
3
3
$begingroup$
Actually
SIGTRAP doesn't result in SIGABRT, so the part about calling abort() is wrong. There's simply no default signal handler for SIGTRAP, so the kernel terminates the process (and the parent can use WIFSIGNALED to detect this and WTERMSIG to determine which signal happened).$endgroup$
– Ruslan
May 13 at 16:02
$begingroup$
Actually
SIGTRAP doesn't result in SIGABRT, so the part about calling abort() is wrong. There's simply no default signal handler for SIGTRAP, so the kernel terminates the process (and the parent can use WIFSIGNALED to detect this and WTERMSIG to determine which signal happened).$endgroup$
– Ruslan
May 13 at 16:02
add a comment |
$begingroup$
JavaScript on Firefox, 69 bytes
WARNING: This script may hang your browser! Do NOT test it with other browsers (e.g. Chrome) as it may crash your tab / browser.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)How: When debugger is enabled with console tab activated. console.log makes memory leak possible, and the program will run out of memory soon. When debugger is disabled, GC would clear memory allocated, and you would see an alert with text 1 finally.
$endgroup$
add a comment |
$begingroup$
JavaScript on Firefox, 69 bytes
WARNING: This script may hang your browser! Do NOT test it with other browsers (e.g. Chrome) as it may crash your tab / browser.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)How: When debugger is enabled with console tab activated. console.log makes memory leak possible, and the program will run out of memory soon. When debugger is disabled, GC would clear memory allocated, and you would see an alert with text 1 finally.
$endgroup$
add a comment |
$begingroup$
JavaScript on Firefox, 69 bytes
WARNING: This script may hang your browser! Do NOT test it with other browsers (e.g. Chrome) as it may crash your tab / browser.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)How: When debugger is enabled with console tab activated. console.log makes memory leak possible, and the program will run out of memory soon. When debugger is disabled, GC would clear memory allocated, and you would see an alert with text 1 finally.
$endgroup$
JavaScript on Firefox, 69 bytes
WARNING: This script may hang your browser! Do NOT test it with other browsers (e.g. Chrome) as it may crash your tab / browser.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)How: When debugger is enabled with console tab activated. console.log makes memory leak possible, and the program will run out of memory soon. When debugger is disabled, GC would clear memory allocated, and you would see an alert with text 1 finally.
for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)for(console.log(a=,i=99);--i;a=a.a=k:new Int8Array(1e9));alert(1)edited May 13 at 8:56
answered May 13 at 6:33
tshtsh
9,66011654
9,66011654
add a comment |
add a comment |
$begingroup$
T-SQL, 6 bytes
sp_who
Always returns an extra row under the executing user's name when the debugger is active.
$endgroup$
add a comment |
$begingroup$
T-SQL, 6 bytes
sp_who
Always returns an extra row under the executing user's name when the debugger is active.
$endgroup$
add a comment |
$begingroup$
T-SQL, 6 bytes
sp_who
Always returns an extra row under the executing user's name when the debugger is active.
$endgroup$
T-SQL, 6 bytes
sp_who
Always returns an extra row under the executing user's name when the debugger is active.
answered May 13 at 4:36
youcantryreachingmeyoucantryreachingme
1813
1813
add a comment |
add a comment |
$begingroup$
MSVC (64-bit), 50 35 bytes
main()return IsDebuggerPresent();
Exits with code 0 normally but 1 under the debugger (note that WinDbg does not automatically display the exit code but you can fake it by examining the stack). Edit: Saved 15 bytes thanks to @Ruslan.
$endgroup$
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
add a comment |
$begingroup$
MSVC (64-bit), 50 35 bytes
main()return IsDebuggerPresent();
Exits with code 0 normally but 1 under the debugger (note that WinDbg does not automatically display the exit code but you can fake it by examining the stack). Edit: Saved 15 bytes thanks to @Ruslan.
$endgroup$
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
add a comment |
$begingroup$
MSVC (64-bit), 50 35 bytes
main()return IsDebuggerPresent();
Exits with code 0 normally but 1 under the debugger (note that WinDbg does not automatically display the exit code but you can fake it by examining the stack). Edit: Saved 15 bytes thanks to @Ruslan.
$endgroup$
MSVC (64-bit), 50 35 bytes
main()return IsDebuggerPresent();
Exits with code 0 normally but 1 under the debugger (note that WinDbg does not automatically display the exit code but you can fake it by examining the stack). Edit: Saved 15 bytes thanks to @Ruslan.
edited May 13 at 20:16
answered May 12 at 14:29
NeilNeil
84k845182
84k845182
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
add a comment |
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
1
1
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
Does MSVC require prototypes? You might then want to try with MinGW in C89 mode, to save some bytes.
$endgroup$
– Ruslan
May 13 at 16:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
$begingroup$
@Ruslan Bah, shows how long it's been since I've used C...
$endgroup$
– Neil
May 13 at 20:16
add a comment |
$begingroup$
APL (Dyalog Unicode), 0 bytes
In Dyalog APL, debugger vs no debugger is choosen by running one's workspace in either the IDE interpreter or the runtime interpreter.
Loading a completely empty default settings workspace into the IDE interpreter, immediately drops the user into REPL mode as applications must actively shut down the interpreter for it to quit:

However, the runtime interpreter does not have a REPL mode, and so if an application comes to an end (for example because it is completely empty) and does not explicitly shut down the interpreter, it implicitly has attempted to reach REPL mode ("the APL session"), and complains:

$endgroup$
add a comment |
$begingroup$
APL (Dyalog Unicode), 0 bytes
In Dyalog APL, debugger vs no debugger is choosen by running one's workspace in either the IDE interpreter or the runtime interpreter.
Loading a completely empty default settings workspace into the IDE interpreter, immediately drops the user into REPL mode as applications must actively shut down the interpreter for it to quit:

However, the runtime interpreter does not have a REPL mode, and so if an application comes to an end (for example because it is completely empty) and does not explicitly shut down the interpreter, it implicitly has attempted to reach REPL mode ("the APL session"), and complains:

$endgroup$
add a comment |
$begingroup$
APL (Dyalog Unicode), 0 bytes
In Dyalog APL, debugger vs no debugger is choosen by running one's workspace in either the IDE interpreter or the runtime interpreter.
Loading a completely empty default settings workspace into the IDE interpreter, immediately drops the user into REPL mode as applications must actively shut down the interpreter for it to quit:

However, the runtime interpreter does not have a REPL mode, and so if an application comes to an end (for example because it is completely empty) and does not explicitly shut down the interpreter, it implicitly has attempted to reach REPL mode ("the APL session"), and complains:

$endgroup$
APL (Dyalog Unicode), 0 bytes
In Dyalog APL, debugger vs no debugger is choosen by running one's workspace in either the IDE interpreter or the runtime interpreter.
Loading a completely empty default settings workspace into the IDE interpreter, immediately drops the user into REPL mode as applications must actively shut down the interpreter for it to quit:

However, the runtime interpreter does not have a REPL mode, and so if an application comes to an end (for example because it is completely empty) and does not explicitly shut down the interpreter, it implicitly has attempted to reach REPL mode ("the APL session"), and complains:

edited May 13 at 7:29
answered May 13 at 6:39
AdámAdám
27.7k276207
27.7k276207
add a comment |
add a comment |
$begingroup$
Python, 29 bytes
import sys
sys.modules['pdb']
Without debugger (python3 /tmp/foo.py):
Traceback (most recent call last):
File "/tmp/foo.py", line 2, in <module>
sys.modules['pdb']
KeyError: 'pdb'
With debugger (python3 -m pdb /tmp/foo.py):
(empty output)
because pdb is loaded into an app-visible module in the second case.
$endgroup$
add a comment |
$begingroup$
Python, 29 bytes
import sys
sys.modules['pdb']
Without debugger (python3 /tmp/foo.py):
Traceback (most recent call last):
File "/tmp/foo.py", line 2, in <module>
sys.modules['pdb']
KeyError: 'pdb'
With debugger (python3 -m pdb /tmp/foo.py):
(empty output)
because pdb is loaded into an app-visible module in the second case.
$endgroup$
add a comment |
$begingroup$
Python, 29 bytes
import sys
sys.modules['pdb']
Without debugger (python3 /tmp/foo.py):
Traceback (most recent call last):
File "/tmp/foo.py", line 2, in <module>
sys.modules['pdb']
KeyError: 'pdb'
With debugger (python3 -m pdb /tmp/foo.py):
(empty output)
because pdb is loaded into an app-visible module in the second case.
$endgroup$
Python, 29 bytes
import sys
sys.modules['pdb']
Without debugger (python3 /tmp/foo.py):
Traceback (most recent call last):
File "/tmp/foo.py", line 2, in <module>
sys.modules['pdb']
KeyError: 'pdb'
With debugger (python3 -m pdb /tmp/foo.py):
(empty output)
because pdb is loaded into an app-visible module in the second case.
answered May 13 at 1:14
viraptorviraptor
69148
69148
add a comment |
add a comment |
$begingroup$
Java, 131 102 bytes
v->(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()+"").indexOf(":jdwp")
When running without a debugger this function returns -1. When running with a debugger, this prints a positive integer.
Try it online!
This technically detects if you could attach a debugger; not if one is currently connected... Not sure if that's valid
-23 bytes thanks to Olivier Grégoire for mentioning that I can cut down on what I search for in the runtime parameters and for lambda-izing my answer
-5 bytes thanks to Benjamin Urquhart for noting that calling toString is dumb when I can let Java implicitly convert
$endgroup$
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on:jdwp, instead of-agentlib:jdwp. The:is to distinguishrunjdwpfrom-agentlib:jdwp. 108 bytes
$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing thetoStringenhancement here. Good catch!
$endgroup$
– Poke
May 13 at 15:08
add a comment |
$begingroup$
Java, 131 102 bytes
v->(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()+"").indexOf(":jdwp")
When running without a debugger this function returns -1. When running with a debugger, this prints a positive integer.
Try it online!
This technically detects if you could attach a debugger; not if one is currently connected... Not sure if that's valid
-23 bytes thanks to Olivier Grégoire for mentioning that I can cut down on what I search for in the runtime parameters and for lambda-izing my answer
-5 bytes thanks to Benjamin Urquhart for noting that calling toString is dumb when I can let Java implicitly convert
$endgroup$
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on:jdwp, instead of-agentlib:jdwp. The:is to distinguishrunjdwpfrom-agentlib:jdwp. 108 bytes
$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing thetoStringenhancement here. Good catch!
$endgroup$
– Poke
May 13 at 15:08
add a comment |
$begingroup$
Java, 131 102 bytes
v->(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()+"").indexOf(":jdwp")
When running without a debugger this function returns -1. When running with a debugger, this prints a positive integer.
Try it online!
This technically detects if you could attach a debugger; not if one is currently connected... Not sure if that's valid
-23 bytes thanks to Olivier Grégoire for mentioning that I can cut down on what I search for in the runtime parameters and for lambda-izing my answer
-5 bytes thanks to Benjamin Urquhart for noting that calling toString is dumb when I can let Java implicitly convert
$endgroup$
Java, 131 102 bytes
v->(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()+"").indexOf(":jdwp")
When running without a debugger this function returns -1. When running with a debugger, this prints a positive integer.
Try it online!
This technically detects if you could attach a debugger; not if one is currently connected... Not sure if that's valid
-23 bytes thanks to Olivier Grégoire for mentioning that I can cut down on what I search for in the runtime parameters and for lambda-izing my answer
-5 bytes thanks to Benjamin Urquhart for noting that calling toString is dumb when I can let Java implicitly convert
edited May 13 at 15:12
answered May 13 at 6:03
PokePoke
2,608828
2,608828
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on:jdwp, instead of-agentlib:jdwp. The:is to distinguishrunjdwpfrom-agentlib:jdwp. 108 bytes
$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing thetoStringenhancement here. Good catch!
$endgroup$
– Poke
May 13 at 15:08
add a comment |
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on:jdwp, instead of-agentlib:jdwp. The:is to distinguishrunjdwpfrom-agentlib:jdwp. 108 bytes
$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing thetoStringenhancement here. Good catch!
$endgroup$
– Poke
May 13 at 15:08
3
3
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on
:jdwp, instead of -agentlib:jdwp. The : is to distinguish runjdwp from -agentlib:jdwp. 108 bytes$endgroup$
– Olivier Grégoire
May 13 at 12:09
$begingroup$
You can shorten it using a lambda. Also, it's very likely that you can test only on
:jdwp, instead of -agentlib:jdwp. The : is to distinguish runjdwp from -agentlib:jdwp. 108 bytes$endgroup$
– Olivier Grégoire
May 13 at 12:09
2
2
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
$begingroup$
103 bytes
$endgroup$
– Benjamin Urquhart
May 13 at 13:00
2
2
$begingroup$
@BenjaminUrquhart I feel dumb for missing the
toString enhancement here. Good catch!$endgroup$
– Poke
May 13 at 15:08
$begingroup$
@BenjaminUrquhart I feel dumb for missing the
toString enhancement here. Good catch!$endgroup$
– Poke
May 13 at 15:08
add a comment |
$begingroup$
JavaScript, 17 bytes
debugger
alert(1)debugger stops execution if the debugger console is open, else it does nothing
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
JavaScript, 17 bytes
debugger
alert(1)debugger stops execution if the debugger console is open, else it does nothing
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
JavaScript, 17 bytes
debugger
alert(1)debugger stops execution if the debugger console is open, else it does nothing
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
JavaScript, 17 bytes
debugger
alert(1)debugger stops execution if the debugger console is open, else it does nothing
debugger
alert(1)debugger
alert(1)New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
Fels
48836
48836
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered May 13 at 12:25
jonatjanojonatjano
1312
1312
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jonatjano is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
$begingroup$
Robotalk, 22 bytes
debug l: chronon l ifg
If the debugger is active, the debug instruction pauses execution until the end of the current game tick. In this case, the variable "chronon" is always 1 or greater when read, and the program executes an infinite loop. If the debugger isn't active, debug is a one-cycle no-op. "Chronon" is now 0 when read, the "ifg" branch isn't taken, and execution reaches the end of the code, which is an error condition.
$endgroup$
add a comment |
$begingroup$
Robotalk, 22 bytes
debug l: chronon l ifg
If the debugger is active, the debug instruction pauses execution until the end of the current game tick. In this case, the variable "chronon" is always 1 or greater when read, and the program executes an infinite loop. If the debugger isn't active, debug is a one-cycle no-op. "Chronon" is now 0 when read, the "ifg" branch isn't taken, and execution reaches the end of the code, which is an error condition.
$endgroup$
add a comment |
$begingroup$
Robotalk, 22 bytes
debug l: chronon l ifg
If the debugger is active, the debug instruction pauses execution until the end of the current game tick. In this case, the variable "chronon" is always 1 or greater when read, and the program executes an infinite loop. If the debugger isn't active, debug is a one-cycle no-op. "Chronon" is now 0 when read, the "ifg" branch isn't taken, and execution reaches the end of the code, which is an error condition.
$endgroup$
Robotalk, 22 bytes
debug l: chronon l ifg
If the debugger is active, the debug instruction pauses execution until the end of the current game tick. In this case, the variable "chronon" is always 1 or greater when read, and the program executes an infinite loop. If the debugger isn't active, debug is a one-cycle no-op. "Chronon" is now 0 when read, the "ifg" branch isn't taken, and execution reaches the end of the code, which is an error condition.
answered May 12 at 20:27
MarkMark
1,9791013
1,9791013
add a comment |
add a comment |
$begingroup$
MATLAB, 6 bytes
dbquit
When stopped in the debugger, this will quit debugging mode.
When not under debug, it will print an error message that it cannot be used when not stopped in the debugger.
It should be noted this only works for evaluation in the command window (one of the three ways of running MATLAB code). It won't work in a function or script as once you try to run the script or function, you stop being in debug mode during execution.
The closest you can get to something that will run in a function/script as well would be:
MATLAB, 22 bytes
feature('IsDebugMode')
This is an undocumented command in MATLAB. If you are stopped in the debugger in a script or function, and then call another function (or command evaluation) that contains the above line, it will return true.
Outside the debugger it will return false.
If you were however to just run a script/function containing the above, even if you add a breakpoint at the start of the script/function and step through, it will return false, because again, once you start executing you stop being in the debugger temporarily.
$endgroup$
add a comment |
$begingroup$
MATLAB, 6 bytes
dbquit
When stopped in the debugger, this will quit debugging mode.
When not under debug, it will print an error message that it cannot be used when not stopped in the debugger.
It should be noted this only works for evaluation in the command window (one of the three ways of running MATLAB code). It won't work in a function or script as once you try to run the script or function, you stop being in debug mode during execution.
The closest you can get to something that will run in a function/script as well would be:
MATLAB, 22 bytes
feature('IsDebugMode')
This is an undocumented command in MATLAB. If you are stopped in the debugger in a script or function, and then call another function (or command evaluation) that contains the above line, it will return true.
Outside the debugger it will return false.
If you were however to just run a script/function containing the above, even if you add a breakpoint at the start of the script/function and step through, it will return false, because again, once you start executing you stop being in the debugger temporarily.
$endgroup$
add a comment |
$begingroup$
MATLAB, 6 bytes
dbquit
When stopped in the debugger, this will quit debugging mode.
When not under debug, it will print an error message that it cannot be used when not stopped in the debugger.
It should be noted this only works for evaluation in the command window (one of the three ways of running MATLAB code). It won't work in a function or script as once you try to run the script or function, you stop being in debug mode during execution.
The closest you can get to something that will run in a function/script as well would be:
MATLAB, 22 bytes
feature('IsDebugMode')
This is an undocumented command in MATLAB. If you are stopped in the debugger in a script or function, and then call another function (or command evaluation) that contains the above line, it will return true.
Outside the debugger it will return false.
If you were however to just run a script/function containing the above, even if you add a breakpoint at the start of the script/function and step through, it will return false, because again, once you start executing you stop being in the debugger temporarily.
$endgroup$
MATLAB, 6 bytes
dbquit
When stopped in the debugger, this will quit debugging mode.
When not under debug, it will print an error message that it cannot be used when not stopped in the debugger.
It should be noted this only works for evaluation in the command window (one of the three ways of running MATLAB code). It won't work in a function or script as once you try to run the script or function, you stop being in debug mode during execution.
The closest you can get to something that will run in a function/script as well would be:
MATLAB, 22 bytes
feature('IsDebugMode')
This is an undocumented command in MATLAB. If you are stopped in the debugger in a script or function, and then call another function (or command evaluation) that contains the above line, it will return true.
Outside the debugger it will return false.
If you were however to just run a script/function containing the above, even if you add a breakpoint at the start of the script/function and step through, it will return false, because again, once you start executing you stop being in the debugger temporarily.
answered May 13 at 8:33
Tom CarpenterTom Carpenter
3,930720
3,930720
add a comment |
add a comment |
4
$begingroup$
Some debuggers output different text on startup to the normal compiler, thus any program seems to meet these conditions. Does that count?
$endgroup$
– Sriotchilism O'Zaic
May 12 at 14:48
1
$begingroup$
Doesn't all output come from the debugger? It's not clear to me what debugger output is vs. program output if we are making a distinction.
$endgroup$
– Sriotchilism O'Zaic
May 12 at 15:42
5
$begingroup$
Define debugger?
$endgroup$
– Artemis Fowl
May 12 at 19:05
3
$begingroup$
What do you mean by debugger? Which one?
$endgroup$
– MilkyWay90
May 12 at 23:43
6
$begingroup$
How do you define a debugger? If a language interpreter supports a "debug" mode (which, say, introduces nonstandard commands), does that count?
$endgroup$
– Esolanging Fruit
May 13 at 0:24