Debug_Break dependable on compiler switch?

  • 1
  • 2
  • Page 1 of 2
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Debug_Break dependable on compiler switch?

 · 
Posted: 03.12.2014 - 19:48  ·  #1
@Rolf,

if it's not too much work, is it possible to implement compiler switch something like this:
{$IGNORE_DEBUG_BREAK}
so when it's defined, DEBUG_BREAK (or my custom alias based shorter "Dbg" version) commands in code will simply be ignored by debugger? That way we could leave them in code if we wish without tons of ugly ifdefs.
With additional
{$ENABLE_DEBUG_BREAK}
we could use this feature on just part of the source (like few new procedures in our latest unit)...
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 03.12.2014 - 20:53  ·  #2
Hello Avra,

sorry, absolutely impossible because the "Debug_Break" instruction is a real
hardware executable CPU instruction.
The XMega ignores it when it is not in Debug mode, PDI inactive.
In this case this instruction is handled by the CPU as a NOP.

So there is no problem if you leave these instructions in your code.
Simply a few unnecessary NOPs are added.

But in Debug mode these instructions are always active, sorry.

rolf
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 04.12.2014 - 14:22  ·  #3
Hello Rolf, thanks for considering it.

I have really meant that {$IGNORE_DEBUG_BREAK} switch should instruct compiler to not compile "Debug_Break" instruction at all. {$ENABLE_DEBUG_BREAK} would be default define and it would tell AvrCo compiler to really compile "Debug_Break" instruction into code. That way I could have portions of code that are already debugged and running well for some time having it's many"Debug_Break" instructions not compiled at all, but when I introduce some new features I would like to make these old "Debug_Break" instructions live again and probably introduce some new. {$IFDEF} is too clumsy for this purpose.
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 04.12.2014 - 15:02  ·  #4
Hello,

why not use conditional compilation

{$DEFINE DEBUG}

{$IFDEF DEBUG} Debug_Break; {$ENDIF}
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 04.12.2014 - 16:53  ·  #5
Hello Avra,

I will try to implement it.
But to avoid SIM/Debug problems the underlying ASM break instruction must be
temporaly replaced by an NOP

rolf
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 04.12.2014 - 21:05  ·  #6
@Thomas.AC:
I already use it like that but code is so unreadable when there are so many {$IFDEFs}.

@Rolf:
NOP is quite acceptable, thanks!
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 09.12.2014 - 11:12  ·  #7
define your own Debug procedure and use optimization Switch {$OPTI ALLOW_INLINE}


Code

program test;

{ $W+}

{$DEFINE DEBUG}

Device = xmega128A1U, VCC = 3.3;

Define_Fuses
    Override_Fuses;
    NoteBook   = A;
    COMport    = USB;
    FuseBits5  = [BODLEVEL1, BODLEVEL2, BODACT0]; // BOD=2.8V if USB variant
    ProgFuses = true;
    ProgEEprom = true;


Import ;

Define
    OSCtype = extXTAL=8000000, PLLmul=4, prescA=1, prescB=1, prescC=1, faildet;


    StackSize      = 256, iData;
    FrameSize      = 256, iData;
    
implementation
{$IDATA}
{-------------------------------------------------------------------------------
Main Program
-------------------------------------------------------------------------------}
procedure myDebugBreak;
begin
  {$IFDEF DEBUG}
  Debug_Break;
  {$ENDIF}
end;

{$OPTI ALLOW_INLINE}
begin
   myDebugBreak;
end test.

Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: Debug_Break dependable on compiler switch?

 · 
Posted: 09.12.2014 - 11:42  ·  #8
I can see three problems with this.

1. when wanted the break will occur far away from where it is wanted. OK you can step through until you hit the return, but even so it is not very convenient.

2. There could be timing issues, particularly when used with the optimiser, since if DEBUG is not defined the optimiser will remove the function completely together with calls to it. I admit that this is unlikely to be a real problem, though.

3. This is very much an all or nothing approach. I believe that what Avra wants to do is have lots of Debug_Break statements but only have a few of them active at a time. This approach does not allow that.

Having said all that and playing devil's advocate here, I am not sure that Avra's request will gain what he imagines. My own approach would be (and has been) to comment out temporarily unwanted Debug_Breaks with a double slash

Code

  //Debug_Break;


This maintains readability and allows specific debug_breaks to be enabled/disabled at will, and I think with no more work than Avra's suggestion.
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   128   142 · Page-Gen-Time: 0.029402s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI