我对Python不太熟悉,我只是发现了GDB python脚本功能; 我的问题的动机是增强MELT监视器内的值的GDB打印,该监视器稍后将连接到GCC MELT.但这是一个更简单的变体.
我的系统是Linux/Debian/Sid/x86-64.GCC编译器是4.8.2; GDB调试器是7.6.2; 它的python是3.3
我想用"区别联合"类型调试C程序:
// file tiny.c in the public domain by Basile Starynkevitch
// compile with gcc -g3 -Wall -std=c99 tiny.c -o tiny
// debug with gdb tiny
// under gdb: python tiny-gdb.py
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef union my_un myval_t;
enum tag_en {
tag_none,
tag_int,
tag_string,
tag_sequence
};
struct boxint_st;
struct boxstring_st;
struct boxsequence_st;
union my_un {
void* ptr;
enum tag_en *ptag;
struct boxint_st *pint;
struct …Run Code Online (Sandbox Code Playgroud)