### Structure Initialization Example Source: https://visualgdb.com/documentation/intellisense/navbar Example of a C structure initialization used to demonstrate the Data Context feature. ```c GPIO_InitTypeDef GPIO_InitStructure = { GPIO_PIN_12, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_SPEED_FREQ_HIGH, 0 }; ``` ```c GPIO_InitTypeDef GPIO_InitStructure = { GPIO_PIN_12, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL, GPIO_SPEED_FREQ_HIGH, 0 }; ``` -------------------------------- ### Example Mbed Command Failure Log Source: https://visualgdb.com/documentation/troubleshooting/mbed A sample output log showing a failed dependency installation during an Mbed update process. ```text Run "C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe "C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\lib\site-packages\mbed\mbed.py" update mbed-os-6.9.0" in directory "c:\projects\temp\MbedProject2\mbed-os" on local computer -------------------------- Requirement already satisfied: colorama==0.3.9 in c:\users\virtual.sysprogs\appdata\local\visualgdb\python3\lib\site-packages (from -r c:\projects\temp\MbedProject2\mbed-os\requirements.txt (line 1)) (0.3.9) <...> ERROR: Could not find a version that satisfies the requirement pywin32==224 (from versions: 225, 226, 227, 228, 300, 301, 302) ERROR: No matching distribution found for pywin32==224 WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available. You should consider upgrading via the 'C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe -m pip install --upgrade pip' command. -------------------------- Command exited with code 1 ``` -------------------------------- ### Run Windows Installer with diagnostic logging Source: https://visualgdb.com/documentation/troubleshooting/install Use this command to generate a detailed log file for troubleshooting installation failures. ```bash msiexec /l* VisualGDB.log /i VisualGDB-.msi ``` -------------------------------- ### Example printf() loop Source: https://visualgdb.com/documentation/semihosting A basic loop demonstrating the use of printf() on an STM32 device. ```c for (int i = 1;;i++) { printf("Iteration %d, value = %f\n", i, i * 0.1F); } ``` ```c for (int i = 1;;i++) { printf("Iteration %d, value = %f\n", i, i * 0.1F); } ``` -------------------------------- ### Setting Compiler and Linker Variables Source: https://visualgdb.com/documentation/environment Example of setting specific toolchain variables. ```text CC=arm-gcc|LD=arm-ld ``` -------------------------------- ### Install SSH server on RedHat-based systems Source: https://visualgdb.com/documentation/linux/ssh Use this command on RedHat-based distributions to install the OpenSSH server. ```bash sudo yum install openssh-server ``` -------------------------------- ### Define Test Group Setup and Teardown Source: https://visualgdb.com/documentation/tests/TinyEmbeddedTest Implement setup and teardown methods within a TEST_GROUP to manage test lifecycle events. ```cpp TEST_GROUP(DemoTestGroup) { void setup() { //... } void teardown() { //... } void TestSetup(TestInstance *) { //... } void TestTeardown(TestInstance *) { //... } }; ``` -------------------------------- ### MSBuild Platform Definition Import Source: https://visualgdb.com/documentation/troubleshooting/install/manual Example of the MSBuild platform definition referencing the VISUALGDB_DIR environment variable. ```xml ``` ```xml ``` -------------------------------- ### Refactoring Prompt for LED Control Source: https://visualgdb.com/documentation/ai Example of a concise prompt used to extract LED-related logic into a new function. ```text +Thermostat_SetOutputValue(g_Thermostat, bool) wrapping CYW43_WL_GPIO_LED_PIN ``` -------------------------------- ### Install SSH server on Debian-based systems Source: https://visualgdb.com/documentation/linux/ssh Use this command on Ubuntu or other Debian-based distributions to install the OpenSSH server. ```bash sudo apt install openssh-server ``` -------------------------------- ### Define Toolchain and Build Flags in .mak Files Source: https://visualgdb.com/documentation/makefiles Example of device-specific flags and toolchain paths generated by VisualGDB in a .mak file. ```makefile CC := $(TOOLCHAIN_ROOT)/bin/arm-none-eabi-gcc.exe CXX := $(TOOLCHAIN_ROOT)/bin/arm-none-eabi-g++.exe <...> PREPROCESSOR_MACROS += ARM_MATH_CM4 flash_layout STM32F407VG STM32F407xx USE_HAL_DRIVER INCLUDE_DIRS += . $(BSP_ROOT)/STM32F4xxxx/STM32F4xx_HAL_Driver/Inc <...> ``` -------------------------------- ### Inspect Compiler Command Line Source: https://visualgdb.com/documentation/troubleshooting/headers Example of a compiler command line showing include directories specified with the -I flag. ```bash arm-none-eabi-g++.exe -DARM_MATH_CM4 -IC:/Users/<...>/STM32F4xxxx/CMSIS_HAL/RTOS2/Include -g3 -O0 <...> ``` -------------------------------- ### Example .vcxproj ItemGroup Source: https://visualgdb.com/documentation/makefiles The source ItemGroup containing C++ source files that VisualGDB parses. ```xml ``` -------------------------------- ### Example C program for profiling Source: https://visualgdb.com/documentation/profiler/separate_callers A simple C program demonstrating a function called from two different locations with varying execution times. ```cpp void delay(int iter) { for (int i = 0; i < iter; i++) asm("nop"); } void fast() { delay(1); } void slow() { delay(10000000); } int main(int argc, char *argv[]) { fast(); slow(); return 0; } ``` -------------------------------- ### Patching requirements.txt for Mbed Source: https://visualgdb.com/documentation/troubleshooting/mbed Examples of updating a specific package version in the requirements.txt file to match available distributions. ```text pywin32==224;platform_system=='Windows' ``` ```text pywin32==225;platform_system=='Windows' ``` -------------------------------- ### Extending PATH Variable Source: https://visualgdb.com/documentation/environment Example of appending a directory to the existing PATH variable on Windows. ```text PATH=%PATH%;c:\MinGW\bin|CC=gcc ``` -------------------------------- ### Define a custom target with an error check Source: https://visualgdb.com/documentation/projects/msbuild/propertysheets This example demonstrates how to define a target that triggers an error if a specific variable is not set, and how to register it in the build sequence. ```xml $(BuildDependsOn);MyCustomTarget ``` -------------------------------- ### Linker Verbose Output Log Source: https://visualgdb.com/documentation/linkerinputs Example of the detailed output generated when building with the -Wl,-verbose flag, showing successful and failed attempts to locate libraries. ```text attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o succeeded /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o succeeded /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o succeeded /usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o attempt to open VisualGDB/Debug/LibraryDemo.o succeeded VisualGDB/Debug/LibraryDemo.o attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so succeeded -lstdc++ (/usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so) attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libm.so failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libm.a failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so succeeded -lm (/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so) attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so succeeded -lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so) attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.so failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a succeeded attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libc.so failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libc.a failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so succeeded opened script file /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so opened script file /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so attempt to open /lib/i386-linux-gnu/libc.so.6 succeeded /lib/i386-linux-gnu/libc.so.6 attempt to open /usr/lib/i386-linux-gnu/libc_nonshared.a succeeded (/usr/lib/i386-linux-gnu/libc_nonshared.a)elf-init.oS attempt to open /lib/i386-linux-gnu/ld-linux.so.2 succeeded /lib/i386-linux-gnu/ld-linux.so.2 attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so succeeded -lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so) attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.so failed attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a succeeded attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/crtend.o succeeded /usr/lib/gcc/i686-linux-gnu/4.8/crtend.o attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crtn.o succeeded /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crtn.o libm.so.6 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so found libm.so at /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so ld-linux.so.2 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so found ld-linux.so.2 at /lib/i386-linux-gnu/ld-linux.so.2 libgcc_s.so.1 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so found libgcc_s.so at /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so ``` -------------------------------- ### Define a CMakePresets.json configuration Source: https://visualgdb.com/documentation/cmake/presets Example structure for a CMakePresets.json file defining a hidden configuration preset with environment variables and cache variables. ```json { "configurePresets": [ { "name": "RaspberryPi", "environment": { "TOOLCHAIN_ROOT": "C:/SysGCC/raspberry", }, "cacheVariables": { "CMAKE_C_COMPILER": "$env{TOOLCHAIN_ROOT}/bin/arm-linux-gnueabihf-gcc.exe", }, "binaryDir": "${sourceDir}/build/${presetName}", "generator": "Ninja", "hidden": true } ] } ``` -------------------------------- ### Complex Refactoring Prompt with Symbol References Source: https://visualgdb.com/documentation/ai Example of a prompt using '@' to reference specific files and symbols for complex function generation. ```text +http_format_and_send() with varargs in @http_utils.c . take contentType + enum http_format_flags (ffNoCache). measure with sprintf, then @pvPortMalloc + send + @vPortFree ``` -------------------------------- ### Kernel panic log output Source: https://visualgdb.com/documentation/arm/stm32/stm32mp2 Example of the kernel panic occurring in the etnaviv module when the EULA is not accepted during the build process. ```text [ 8.531340] etnaviv etnaviv: bound 48280000.gpu (ops gpu_ops [etnaviv]) E/TC:1 0 Panic at /usr/src/debug/optee-os-stm32mp/4.0.0-stm32mp-r1/core/drivers/clk/clk-stm32mp25.c:1976 E/TC:1 0 TEE load address @ 0x82000000 E/TC:1 0 Call stack: ``` -------------------------------- ### Define inherited CMake presets Source: https://visualgdb.com/documentation/cmake/presets Example of deriving specific Debug and Release presets from a base RaspberryPi preset to share common toolchain settings. ```json { "name": "RaspberryPi-Debug", "inherits": "RaspberryPi", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "RaspberryPi-Release", "inherits": "RaspberryPi", "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } } ``` -------------------------------- ### Implement custom _sbrk() for heap management Source: https://visualgdb.com/documentation/embedded/stackheap Use this implementation as a starting point for managing dynamic memory allocation in newlib-based embedded projects. ```c register char *stack_ptr asm("sp"); void *_sbrk(ptrdiff_t incr) { extern char end asm("end"); /* Defined by the linker. */ static char *heap_end; char *prev_heap_end; if (heap_end == NULL) heap_end = &end; prev_heap_end = heap_end; if (heap_end + incr > stack_ptr) { errno = ENOMEM; return (void *)-1; } heap_end += incr; return (void *)prev_heap_end; } ``` ```c register char *stack_ptr asm("sp"); void *_sbrk(ptrdiff_t incr) { extern char end asm("end"); /* Defined by the linker. */ static char *heap_end; char *prev_heap_end; if (heap_end == NULL) heap_end = &end; prev_heap_end = heap_end; if (heap_end + incr > stack_ptr) { errno = ENOMEM; return (void *)-1; } heap_end += incr; return (void *)prev_heap_end; } ``` -------------------------------- ### Identify 'The Specified Account Already Exists' error Source: https://visualgdb.com/documentation/troubleshooting/install This error message indicates a corruption in Windows Installer files, often related to Visual Studio uninstallation or reinstallation. ```text The Specified Account Already Exists ``` -------------------------------- ### Launch Visual Studio with Logging Source: https://visualgdb.com/documentation/mefcache Use the /log argument to generate an ActivityLog.xml file for troubleshooting extension loading errors. ```bash devenv.exe /log ``` -------------------------------- ### Manually Build LinuxAppLauncher Source: https://visualgdb.com/documentation/wsl2 Use this command within the WSL bash shell to manually compile the launcher if the automatic build fails. ```bash gcc -std=gnu99 -o LinuxAppLauncher -lutil ``` -------------------------------- ### Implement Startup Wait Loop Source: https://visualgdb.com/documentation/startupdebug Add this function to your main source file and call it from main() to pause execution until the debugger attaches. ```C static int SysprogsDebuggerIsAttached; void __attribute__((noinline)) WaitForSysprogsDebugger() { while (!SysprogsDebuggerIsAttached) { } } ``` -------------------------------- ### Detecting memory leaks in tests Source: https://visualgdb.com/documentation/tests/TinyEmbeddedTest Use CHECK_FOR_MEMORY_LEAKS() at the start of a test to fail if memory remains allocated. ```cpp TEST(DemoTestGroup, MemoryLeakTest) { CHECK_FOR_MEMORY_LEAKS(); void *p = malloc(123); } ``` -------------------------------- ### Expression Substitution in Generators Source: https://visualgdb.com/documentation/refactorscript/language Use the $ syntax to reference generator parameters within output lines starting with > or >>. ```RefactorScript generator DemoGenerator(Function func) { >//Hello, $func.ShortName } ``` -------------------------------- ### Execute CMake using presets Source: https://visualgdb.com/documentation/cmake/presets Commands to configure and build a project using a specific CMake preset from the command line. ```bash cmake.exe --preset=RaspberryPi cmake.exe --build build/RaspberryPi ``` -------------------------------- ### Generate output lines Source: https://visualgdb.com/documentation/refactorscript/language Lines starting with '>' are translated directly to output, while '>>' prevents a newline character from being inserted. ```RefactorScript generator DemoGenerator(Function func) { >//Hello, World } ``` ```RefactorScript generator DemoGenerator(Function func) { >//Hello, World } ``` ```RefactorScript generator DemoGenerator(Function func) { >>//Hello, > World! >//Hello, Script! } ``` ```RefactorScript generator DemoGenerator(Function func) { >>//Hello, > World! >//Hello, Script! } ``` ```text //Hello, World! //Hello, Script! ``` ```text //Hello, World! //Hello, Script! ``` -------------------------------- ### Implement Test with Custom Attribute Source: https://visualgdb.com/documentation/tests/TinyEmbeddedTest Example showing a forward declaration of an attribute class and its usage in a test definition. ```cpp class MyTestAttribute; TEST_WITH_ATTRIBUTES(DemoTestGroup, SuccessfulTest, MyTestAttribute) { printf("Hello from test #1\n"); } ``` -------------------------------- ### Execute GCC with response file Source: https://visualgdb.com/documentation/projects/msbuild Run the compiler using arguments stored in a generated response file. ```bash @ ``` -------------------------------- ### Example of Nested Comment Groups Source: https://visualgdb.com/documentation/codeexplorer/outline Demonstrates how comment-based rules can be used to create hierarchical structures in the Outline view. ```cpp // Test Group: Group 1 // Test: Test 1 void Test1(); // Test: Test 2 void Test2(); // Test Group: Group 2 ``` -------------------------------- ### Extending PATH Variable for Linux/MacOS Source: https://visualgdb.com/documentation/environment Example of appending a directory to the existing PATH variable using the colon separator. ```text PATH=%PATH%:/opt/arm-gcc/bin|CC=arm-gcc ``` -------------------------------- ### Define a Function Pointer in a Struct Source: https://visualgdb.com/documentation/refactorscript/datamodel Example of a C++ struct containing a function pointer field, which is represented by the FunctionPrototype object. ```cpp struct Foo { int (*bar)(int x, int y, int z); }; ``` ```cpp struct Foo { int (*bar)(int x, int y, int z); }; ``` -------------------------------- ### Create symbolic link for project path Source: https://visualgdb.com/documentation/cmake/CMAKE_OBJECT_PATH_MAX Command to create a symbolic link to shorten the project directory path. ```cmd mklink /d c:\prj\Name c:\long\path\under\source\control ``` -------------------------------- ### Run VisualGDB Tracing via Command Line Source: https://visualgdb.com/documentation/tracing Executes an application and generates trace reports using a project file and configuration. ```bash VisualGDB.exe /trace /traceconfig: /tracereport: /xmltracereport: ``` ```bash VisualGDB.exe /trace /traceconfig: /tracereport: /xmltracereport: ``` -------------------------------- ### Define a field name generator Source: https://visualgdb.com/documentation/refactorscript/language Example of a generator function that processes variable names and outputs a formatted field list. ```RefactorScript function MakeFieldName(Variable arg) { return arg.ShortName.UppercaseFirst().AddPrefix("m_"); } generator OutputFieldList(Array vars) { foreach(arg in vars) { set fieldName = MakeFieldName(arg); if (!arg.IsFirst) >>, >>$fieldName } } [Main] generator GenerateNullChecks(Function func) { OutputFieldList(func.Arguments); } ``` -------------------------------- ### Configure test.props for Unit Testing Source: https://visualgdb.com/documentation/tests Define preprocessor definitions and include directories for the test framework in a custom MSBuild property sheet. ```xml SYSPROGS_TEST_PLATFORM_EMBEDDED;TINY_EMBEDDED_TEST_CONTEXT_RESTORE_MODE=0;TINY_EMBEDDED_TEST_HOOK_STDIO=0;%(ClCompile.PreprocessorDefinitions) %(ClCompile.AdditionalIncludeDirectories);$(TESTFW_BASE)/com.sysprogs.unittest.tinyembtest ``` -------------------------------- ### Define Python package compatibility in package.xml Source: https://visualgdb.com/documentation/python The package.xml file defines the version and framework compatibility for a VisualGDB-managed Python installation. ```xml python 3.8.10 Python mbed=*;NRFConnect=0-2.4;PicoSDK=*;ESPIDF=*;ESPADF=*;ESP8266RTOS=* ``` ```xml python 3.8.10 Python mbed=*;NRFConnect=0-2.4;PicoSDK=*;ESPIDF=*;ESPADF=*;ESP8266RTOS=* ``` -------------------------------- ### General Environment Syntax Source: https://visualgdb.com/documentation/environment The basic format for defining multiple environment variables. ```text VAR1=VALUE1|VAR2=VALUE2 ``` -------------------------------- ### Conditionally Import a Property Sheet Source: https://visualgdb.com/documentation/projects/msbuild/propertysheets An example of using ImportGroup to apply property sheets based on specific configuration and platform conditions. ```xml ``` -------------------------------- ### View Keil package diagnostic logs Source: https://visualgdb.com/documentation/toolchains/keil Sample output from the VisualGDB Diagnostics Console showing the scanning process for Keil packages in specified directories. ```text Looking for Keil packages for e:\Keil_v5\ARM\ARMCLANG... Scanning e:\Keil_v5\ARM\pack... Found 0 packages in e:\Keil_v5\ARM\pack. Scanning C:\Users\vmuser\AppData\Local\Arm\Packs... Found 10 packages in C:\Users\vmuser\AppData\Local\Arm\Packs. ``` -------------------------------- ### UART Baud Rate Configuration Comparison Source: https://visualgdb.com/documentation/renesas/troubleshooting Displays the difference between VisualGDB's simplified baud rate setting and the more complex structure generated by native Renesas tools. ```c baud_setting_t g_uart0_baud_setting = { 115200 }; ``` ```c baud_setting_t g_uart0_baud_setting = { .abcse = 0, .abcs = 0, .bgdm = 1, .cks = 0, .brr = 12, .mddr = (uint8_t) 256, .brme = false }; ``` -------------------------------- ### Typical VisualGDB Makefile Structure Source: https://visualgdb.com/documentation/makefiles The primary Makefile includes configuration flags and defines build rules for source files. ```makefile #VisualGDB: AutoSourceFiles TARGETNAME := ProjectName.elf TARGETTYPE := APP CONFIG ?= DEBUG <...> include $(CONFIGURATION_FLAGS_FILE) include $(ADDITIONAL_MAKE_FILES) SOURCEFILES := <...> #VisualGDB: FileSpecificTemplates $(BINARYDIR)/%.o : %.cpp $(all_make_files) |$(BINARYDIR) $(CXX) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep) <...> #VisualGDB: GeneratedRules $(BINARYDIR)/startup_stm32f407xx.o : $(BSP_ROOT)/STM32F4xxxx/StartupFiles/startup_stm32f407xx.c $(all_make_files) |$(BINARYDIR) $(CC) $(CFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep) <...> ``` -------------------------------- ### Identify Ninja build error Source: https://visualgdb.com/documentation/cmake/CMAKE_OBJECT_PATH_MAX Example of the error message displayed when a build fails due to an excessively long object file path. ```text ninja: error: mkdir(CMakeFiles/): No such file or directory ```