You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Lauterbach宏是否支持延迟求值?

Best Practices for a Configurable Lauterbach Test Framework Top Section

Great call centralizing your test config at the top—this makes your script way more maintainable for other users who don’t want to dig through lines of logic to tweak settings. Let’s break down how to implement this effectively, including handling those tricky local C variables.

1. Create a Clear, Commented Config Block

Start your script with a dedicated, visually distinct section marked off by comments. Use Lauterbach’s DEFINE directives or global variables to group all test-specific settings, so users can edit values without touching the core test logic.

Example config section:

-- ==============================================
-- TEST CONFIGURATION (EDIT THESE VALUES AS NEEDED)
-- ==============================================
-- Breakpoint target functions
DEFINE BP_TARGET_FUNC_1 "app_process_data"
DEFINE BP_TARGET_FUNC_2 "app_calculate_checksum"

-- Variables to modify (global + local)
DEFINE GLOBAL_VAR_TO_TWEAK "g_system_state"
DEFINE LOCAL_VAR_TO_TWEAK "local_buffer_size"
DEFINE LOCAL_VAR_PARENT_FUNC "app_process_data" -- Function where the local var lives

-- Test parameters
DEFINE TEST_TIMEOUT_MS 5000
DEFINE EXPECTED_RETURN_VALUE 0
-- ==============================================

2. Use Config Values for Breakpoints

Reference your config defines directly when setting breakpoints. This way, changing the target function only requires editing the top section, no hunting through the script for Break.Set calls.

-- Set breakpoints using config values
Break.Set {function = BP_TARGET_FUNC_1}
Break.Set {function = BP_TARGET_FUNC_2, command = "Go"} -- Auto-continue after hit

3. Accessing Local C Variables

Since local variables are tied to their function’s stack frame, you need to target the correct context in your Lauterbach script. Here are two clean ways to handle this using your config values:

Option 1: Directly Reference with VAR.Local

When stopped at a breakpoint in the parent function, you can access the local variable by specifying its function scope:

-- Modify the local variable when stopped in BP_TARGET_FUNC_1
VAR.Local(LOCAL_VAR_PARENT_FUNC, LOCAL_VAR_TO_TWEAK) = 0x100

Option 2: Explicitly Select the Stack Frame

If you need to access the variable outside the immediate breakpoint context, select the frame first:

-- Target the stack frame for the parent function
Frame.Select {function = LOCAL_VAR_PARENT_FUNC}
-- Now modify the local variable
VAR.Set(LOCAL_VAR_TO_TWEAK, 0x200)

Pro Tip: Wrap Local Var Access in a Helper

To simplify things for other users, add a helper function in the config section that abstracts the frame selection:

-- Helper to modify a local variable (no need for users to remember frame logic)
FUNCTION ModifyLocalVar(func_name, var_name, new_value)
    Frame.Select {function = func_name}
    VAR.Set(var_name, new_value)
    Print("Modified local variable %s in %s to 0x%X", var_name, func_name, new_value)
ENDFUNCTION

-- Usage (users only need to pass config values)
ModifyLocalVar(LOCAL_VAR_PARENT_FUNC, LOCAL_VAR_TO_TWEAK, 0x100)

4. Keep Config and Logic Separate

Ensure the rest of your script only references the config defines/variables, not hardcoded values. This locks all user-facing changes to the top section, making the script intuitive to adjust.

By structuring your script this way, other users can quickly adapt the test to new targets or parameters without having to parse through complex test logic.

内容的提问来源于stack exchange,提问作者Thoran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:46:14