diff --git a/CMakeLists.txt b/CMakeLists.txt index 8408f45..a328d15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ add_library(dwarves_reorganize SHARED ${dwarves_reorganize_LIB_SRCS}) set_target_properties(dwarves_reorganize PROPERTIES VERSION 1.0.0 SOVERSION 1) target_link_libraries(dwarves_reorganize ${DWARF_LIBRARIES} dwarves) -set(codiff_SRCS codiff.c) +set(codiff_SRCS codiff.c dutil.c) add_executable(codiff ${codiff_SRCS}) target_link_libraries(codiff dwarves) diff --git a/codiff.c b/codiff.c index 7d4784d..f42676a 100644 --- a/codiff.c +++ b/codiff.c @@ -22,6 +22,8 @@ static int show_function_diffs; static int verbose; static int show_terse_type_changes; +static struct strlist *structs_printed; + #define TCHANGEF__SIZE (1 << 0) #define TCHANGEF__NR_MEMBERS (1 << 1) #define TCHANGEF__TYPE (1 << 2) @@ -497,8 +499,13 @@ static int show_structure_diffs_iterator(struct tag *tag, struct cu *cu, return 0; class = tag__class(tag); - if (class->priv != NULL) - show_diffs_structure(class, cu); + if (class->priv != NULL) { + const char *name = class__name(class, cu); + if (!strlist__has_entry(structs_printed, name)) { + show_diffs_structure(class, cu); + strlist__add(structs_printed, name); + } + } return 0; } @@ -660,9 +667,10 @@ failure: dwarves__init(0); + structs_printed = strlist__new(false); old_cus = cus__new(NULL, NULL); new_cus = cus__new(NULL, NULL); - if (old_cus == NULL || new_cus == NULL) { + if (old_cus == NULL || new_cus == NULL || structs_printed == NULL) { fputs("codiff: insufficient memory\n", stderr); return EXIT_FAILURE; }