boa调试

Cannot access memory at address 0x0 0x400fc7e0 in ?? ()

0 0x4014f0dc in wcscasecmp_l () from /lib/libc.so.6

usr/local/openssl_arm/lib:/usr/local/libosip2_arm/lib:/usr/local/libexosip2_arm/lib:

  • 调试过程:准备调试环境:开发板的环境(依赖库)、可执行文件、和core文件拷贝到PC的linux下。

829188-20170810171638636-545763530.png

  • 将core和boa执行文件通过tftp服务器下载到PC的linux上。
  • 在gdb中指定solib-absolute-prefix和solib-search-path两个变量以保证gdb能够找到可执行程序的依赖库路径。

  • 在gdb中查看solib-absolute-prefix的路径,
    显示:
    829188-20170810174158449-896799599.png
    即没有设置。当我要设置该路径时,出现了一个警告。
    当我将这两个变量均设置为/lib时,出现如下调试错误:
    829188-20170810191906558-757460499.png

通过查阅资料,我了解到这两个变量的作用。
于是我将其均设置为:
829188-20170810191753855-2008814497.png
再次查看错误:
829188-20170810192036199-2062721180.png

gdb命令:maintenance info sections

reference

https://stackoverflow.com/questions/14896534/why-do-i-get-in-gdb-cannot-access-memory-at-address-0x-while-inspecting-a-c
http://bbs.youkuaiyun.com/wap/topics/390930906
http://blog.youkuaiyun.com/weed_hz/article/details/8939892

转载于:https://www.cnblogs.com/xlwang1995/p/7340703.html

import time import os import sys import ctypes import re import can from can.interfaces.etas import EtasBus from pathlib import Path # 全局变量 ETAS_CHANNELS = [] def load_etas_dlls(): """显式加载 ETAS DLL 并配置路径""" try: # 确定 DLL 路径 if getattr(sys, 'frozen', False): # 打包后 base_path = sys._MEIPASS if hasattr(sys, '_MEIPASS') else os.path.dirname(sys.executable) dll_dir = os.path.join(base_path, "etas_dlls") else: # 开发环境 dll_dir = r"C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework/" # 添加 DLL 路径到系统环境 os.environ["PATH"] = os.pathsep.join([dll_dir, os.environ.get("PATH", "")]) # 显式加载关键 DLL for dll in ["dll-csiBind.dll", "dll-ocdProxy.dll"]: ctypes.WinDLL(os.path.join(dll_dir, dll)) print(f"✅ ETAS DLL 加载成功: {dll_dir}") return True except Exception as e: print(f"❌ DLL 加载失败: {e}") return False def detect_etash_devices(): """检测可用的 ETAS 设备""" try: configs = can.interface.detect_available_configs(interfaces=["etas"]) pattern = re.compile(r'ETAS://(USB|PCI)/ES582\.?1?', re.IGNORECASE) global ETAS_CHANNELS ETAS_CHANNELS = [cfg['channel'] for cfg in configs if pattern.search(cfg.get('channel', ''))] if ETAS_CHANNELS: print("🟢 ETAS 设备已连接:") for i, channel in enumerate(ETAS_CHANNELS, 1): print(f" {i}. {channel}") return True print("⚠️ 未检测到 ETAS 设备") return False except Exception as e: print(f"❌ 设备检测失败: {e}") return False def select_channel(): """选择通信通道""" if not ETAS_CHANNELS: raise ValueError("无可用通道") print("\n请选择通信通道:") for i, channel in enumerate(ETAS_CHANNELS, 1): print(f"{i} - {channel}") while True: try: choice = int(input("通道序号: ")) - 1 if 0 <= choice < len(ETAS_CHANNELS): return ETAS_CHANNELS[choice] print("❌ 无效选择,请重试") except ValueError: print("❌ 请输入数字") def format_asc_line(msg): """将 CAN 报文格式化为 ASC 格式""" try: sec = int(msg.timestamp) usec = int(round((msg.timestamp - sec) * 1e6)) timestamp = f"{sec}.{usec:06d}" can_id = f"{msg.arbitration_id:08X}" if msg.is_extended_id else f"{msg.arbitration_id:03X}" data = ' '.join(f"{byte:02X}" for byte in msg.data[:msg.dlc]) return f"{timestamp} {can_id} {msg.dlc} {data}\n" except Exception as e: print(f"❌ 格式化错误: {e}") return "" def main(): # 配置 BOA 调试日志 os.environ["BOA_LOG_LEVEL"] = "DEBUG" os.environ["BOA_LOG_FILE"] = "BOA_Debug.log" # 加载 ETAS 依赖 if not load_etas_dlls(): print("❌ 无法加载 ETAS 库文件") sys.exit(1) # 检测设备 if not detect_etash_devices(): print("❌ 未检测到 ETAS 设备") sys.exit(1) # 选择通道 try: channel = select_channel() print(f"✅ 已选择通道: {channel}") except ValueError as e: print(f"❌ 通道选择失败: {e}") sys.exit(1) # 配置 CAN 总线 config = { 'interface': 'etas', 'channel': channel, 'bitrate': 500000, 'data_bitrate': 2000000, 'fd': True, 'receive_own_messages': False, 'sync': False, 'buffer_size': 1000 } # 初始化 CAN 总线 try: bus = EtasBus(**config) print(f"🟢 成功连接到 {config['channel']}") except Exception as e: print(f"❌ 初始化失败: {e}") print("请检查:") print("1. 硬件连接") print("2. BOA SDK 安装") print("3. 通道配置") sys.exit(1) # 创建 ASC 日志文件 timestamp = time.strftime("%Y%m%d_%H%M%S") asc_filename = f"can_log_{timestamp}.asc" try: with open(asc_filename, "w") as f: f.write(f"date {time.strftime('%b %d %H:%M:%S %Y')}\n") f.write("base hex timestamps absolute\n") f.write("no internal events logged\n") f.write("// version 1.0\n") except Exception as e: print(f"❌ 日志文件创建失败: {e}") sys.exit(1) print(f"\n🔄 开始记录到 {asc_filename}... (按 Ctrl+C 停止)") # 开始记录 try: with open(asc_filename, "a") as asc_file: while True: try: msg = bus.recv(timeout=1.0) if msg: asc_line = format_asc_line(msg) if asc_line: print(asc_line.strip()) asc_file.write(asc_line) asc_file.flush() except can.CanError as e: print(f"⚠️ CAN 错误: {e}") time.sleep(0.1) except KeyboardInterrupt: print("\n🛑 用户终止") break except Exception as e: print(f"❌ 记录过程中发生错误: {e}") finally: if 'bus' in locals(): bus.shutdown() print("🔌 CAN 连接已关闭") if __name__ == "__main__": main() 开发环境运行成功,打包后❌ 初始化失败: OCI_CreateCANControllerNoSearch failed with error 0x80002002
最新发布
09-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值