Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Pages: 1 2 
Send Topic Print
Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a) (Read 469 times)
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #20 - Apr 6th, 2021 at 5:49pm
 
Hi,
here the full list of micro build
Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 774
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #21 - Apr 7th, 2021 at 2:33pm
 
Thanks for the detail.

From some further testing using your project today, it seems the most reliable solution is:
1) Set vMicro > Debugger > Optimization: No Project
2) Set a breakpoint at the top of loop()   (If this is not put in, further breakpoints do not bind)
3) Build and Upload
4) Use Debug > Attach to process

The Debug > Start attaches before the COM port is available, so using Attach to Process is more reliable with this particular library.
Back to top
 
 
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #22 - Apr 8th, 2021 at 6:09am
 
Hi, sorry but it doesn't work. Exactly the same as before, debugging is not started.
Shocked
Back to top
 
 
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #23 - Apr 8th, 2021 at 7:14am
 
UPDATE:
setting COM11 instead of COM10 the debug is runnig.
But (there is alway a but in our life!)
The debug
1- do not start with START button but only with attach to process
2 - is not possible to set a break point in SETUP
3- if you do not place a break point in loop() before to compile, during debug session is not possible to add any breakpoint

in not easy to use this debug with teensy4.1  Undecided
Back to top
 
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline



Posts: 774
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #24 - Apr 8th, 2021 at 9:39am
 
Thanks for the update.

To get into the setup() code, you can add a delay after the debug init, or wait for something to be sent via the normal serial comms to continue execution.

Back to top
 
 
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #25 - Apr 8th, 2021 at 2:17pm
 
Hi!
this is my code:
void setup() {
     Serial.begin(115200);       // First Serial Port in Dual
     debug.begin(SerialUSB1); // Second Serial Port in
     delay(5000);

using a 5Sec. (too low?) delay the situation do not change.

1- is not possible to setup a breakpoint in to setup
2- some time the debug do not start with COM11 I need always to upload the code if I want restart the debug using the attach process menu.

Embarrassed
Back to top
 
 
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #26 - Apr 8th, 2021 at 2:32pm
 
UPDATE
using a delay(35000); the debuf work well.
yes, is not a elegant solution but work
now I can:
1- insert a breakpoint in to setup
2- the code flowing is stopped correctly on  breakpoint
3- the F10/F11 work well step-over/step-into

could this discussion be used to think of a more robust solution in VM? Could this discussion be used to think of an VM update that would provide greater stability, without having to wait 25 seconds for debugging to start? For me there is a issue about the selection COM10 - COM11 how I can understand wht COM I need to use for debug? Actually I need to try com10 or com11 , but is not a "great" solution.
Smiley
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11006
United Kingdom
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #27 - Apr 8th, 2021 at 2:37pm
 
Hi Marco,

Each hardware debug solution comes with different restrictions. That is just how they work. We can only give tips as to possible workarounds in some cases. Non of this relates to things Visual Micro can control, it is how the hardware debug authors have designed things for each type of hardware.

In the case of a GDB stub there are always additional restrictions but you can think it through yourself and sometimes find solutions. The two issues you report are related to the teensy board and how the GDB stub works for the Teensy board.

We produced the serial debugger because it avoids many of the restrictions but you still need to consider what is happening to find solutions.

The issues are especially difficult with Teensy because it has a different upload facility to all other boards. It performs the upload each time you build, then the mcu starts. This all happens a long time before debug starts. The attach to process instead of debug start gets around some of the issues of the mcu starting early but makes debug setup tricky.

Putting all this together, the design of the GDB stub solution for Teensy makes it quite difficult to jump into the setup() code. I think there can be a solution but it isn't clean. It might involve the mcu waiting in the setup() until it receieves a serial message from thje pc telling it to continue. You would send the serial from the pc after debug is started and waiting. All in all hardware debuggers as opposed to stubs handle this better as do other boards. For the Teensy the best solution is probably the serial debugger.




Back to top
 

Tim Leek
home
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11006
United Kingdom
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #28 - Apr 8th, 2021 at 2:39pm
 
Our posts crossed. Good to hear you have it working. Hopefully my last comments show you why this happens and that it is not something that Visual Micro or any other IDE could control.

There is a define #VM_DEBUG_GDB  that can be used to include/exclude code when debugging

Code (C++):
#ifdef VM_DEBUG_GDB
  //some debug only code here
#endif 

Back to top
« Last Edit: Apr 8th, 2021 at 2:44pm by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #29 - Apr 8th, 2021 at 2:59pm
 
Hi Tim!
thanks for your assistance. the code that you provide me is right used in this mode?

Code (C++):

#ifdef VM_DEBUG_GDB
      debug.begin(SerialUSB1); // Second Serial Port in
      delay(5000);
#endif
so, this code is selected only when the debug is connected?

Grin
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11006
United Kingdom
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #30 - Apr 8th, 2021 at 3:20pm
 
Looks ok to me, let me know if doesn't work.
Back to top
 

Tim Leek
home
WWW  
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #31 - Apr 8th, 2021 at 3:30pm
 
Hi Tim!
the code doesn't work, same problem!

Wink
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11006
United Kingdom
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #32 - Apr 8th, 2021 at 4:57pm
 
Maybe some confusion in what I have said. The condition using an #if is simply to allow you to add code that only works/compiles when gdb debug is enabled. All other settings such as pause time for teensy gdb stub are unrelated to my suggestion.

Here is a clear example. Visual Micro is set to GDB Stub but I have not initialized or used GDB in the program code.

The code example prints "test" to serial ONLY when GDb is enabled. In this case enabling GDB but not using GDB allows us to demonstrate how the #ifdef works.

Serial is only active when GDB is selected in Visual Micro ...

Code (C++):
void setup() {
#ifdef VM_DEBUG_GDB
	Serial.begin(115200);
#endif
}

// the loop function runs over and over again until power down or reset
void loop() {
#ifdef VM_DEBUG_GDB
	Serial.println("test");
#endif

}
 

Back to top
« Last Edit: Apr 8th, 2021 at 4:58pm by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
Marco (Italy)
Member
***
Offline



Posts: 126
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #33 - Apr 8th, 2021 at 7:10pm
 
[SOLVED]

Hi Tim
this code work fine !

void setup{
Serial.begin(115200);
debug.begin(SerialUSB1);
while(!SerialUSB1){}      
delay(500); // min 200mSec. 500mSec. for safety
}

Tomorrow I will open a new thread for a new issue ... but for Arduino Zero using the ICE Atmel debug.

See you tomorrow!
Marco Grin
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11006
United Kingdom
Re: Teensy4.1 GDB error -> The program '' has exited with code 42 (0x2a)
Reply #34 - Apr 8th, 2021 at 7:17pm
 
Well done, yes you have to wait for some serial ports before they can be used. You can do this early, not sure you need the delay.

Code:
void setup{

while(!SerialUSB1)
{}

Serial.begin(115200);
debug.begin(SerialUSB1);

} 

Back to top
« Last Edit: Apr 8th, 2021 at 7:19pm by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
Pages: 1 2 
Send Topic Print