Module: wine Branch: master Commit: 7d7ce1dc205ed48e0201d5193e370d01fde49601 URL: https://gitlab.winehq.org/wine/wine/-/commit/7d7ce1dc205ed48e0201d5193e370d0...
Author: Eric Pouech epouech@codeweavers.com Date: Sat Jun 8 10:29:18 2024 +0200
include/mscvpdb.h: Use flexible array members for codeview_symbol union.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/dbghelp/msc.c | 12 ++++++------ include/wine/mscvpdb.h | 36 ++++++++++++++++-------------------- tools/winedump/msc.c | 18 +++++++++++------- 3 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 04de7f6491f..815bcedb04a 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2585,8 +2585,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, struct symt* se; VARIANT v;
- vlen = leaf_as_variant(&v, &sym->constant_v1.cvalue); - name = (const struct p_string*)((const char*)&sym->constant_v1.cvalue + vlen); + vlen = leaf_as_variant(&v, sym->constant_v1.data); + name = (const struct p_string*)&sym->constant_v1.data[vlen]; se = codeview_get_type(sym->constant_v1.type, FALSE);
TRACE("S-Constant-V1 %u %s %x\n", V_INT(&v), terminate_string(name), sym->constant_v1.type); @@ -2601,8 +2601,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, struct symt* se; VARIANT v;
- vlen = leaf_as_variant(&v, &sym->constant_v2.cvalue); - name = (const struct p_string*)((const char*)&sym->constant_v2.cvalue + vlen); + vlen = leaf_as_variant(&v, sym->constant_v2.data); + name = (const struct p_string*)&sym->constant_v2.data[vlen]; se = codeview_get_type(sym->constant_v2.type, FALSE);
TRACE("S-Constant-V2 %u %s %x\n", V_INT(&v), terminate_string(name), sym->constant_v2.type); @@ -2617,8 +2617,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, struct symt* se; VARIANT v;
- vlen = leaf_as_variant(&v, &sym->constant_v3.cvalue); - name = (const char*)&sym->constant_v3.cvalue + vlen; + vlen = leaf_as_variant(&v, sym->constant_v3.data); + name = (const char*)&sym->constant_v3.data[vlen]; se = codeview_get_type(sym->constant_v3.type, FALSE);
TRACE("S-Constant-V3 %u %s %x\n", V_INT(&v), name, sym->constant_v3.type); diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index da66b2c2416..4d0380ee429 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -1661,10 +1661,9 @@ union codeview_symbol unsigned short int len; unsigned short int id; cv_typ16_t type; - unsigned short cvalue; /* numeric leaf */ -#if 0 - struct p_string p_name; -#endif + unsigned char data[]; + /* <numeric leaf> cvalue; */ + /* struct p_string p_name; */ } constant_v1;
struct @@ -1672,10 +1671,9 @@ union codeview_symbol unsigned short int len; unsigned short int id; cv_typ_t type; - unsigned short cvalue; /* numeric leaf */ -#if 0 - struct p_string p_name; -#endif + unsigned char data[]; + /* <numeric leaf> cvalue; */ + /* struct p_string p_name; */ } constant_v2;
struct @@ -1683,10 +1681,9 @@ union codeview_symbol unsigned short int len; unsigned short int id; cv_typ_t type; - unsigned short cvalue; -#if 0 - char name[1]; -#endif + unsigned char data[]; + /* <numeric leaf> cvalue; */ + /* char name; */ } constant_v3;
struct @@ -1896,7 +1893,7 @@ union codeview_symbol unsigned short int id; unsigned int program; struct cv_addr_range range; - struct cv_addr_gap gaps[0]; + struct cv_addr_gap gaps[]; } defrange_v3;
struct @@ -1906,7 +1903,7 @@ union codeview_symbol unsigned int program; unsigned int offParent; struct cv_addr_range range; - struct cv_addr_gap gaps[0]; + struct cv_addr_gap gaps[]; } defrange_subfield_v3;
struct @@ -1916,7 +1913,7 @@ union codeview_symbol unsigned short reg; unsigned short attr; struct cv_addr_range range; - struct cv_addr_gap gaps[0]; + struct cv_addr_gap gaps[]; } defrange_register_v3;
struct @@ -1925,7 +1922,7 @@ union codeview_symbol unsigned short int id; int offFramePointer; struct cv_addr_range range; - struct cv_addr_gap gaps[0]; + struct cv_addr_gap gaps[]; } defrange_frameptrrel_v3;
struct @@ -2003,10 +2000,9 @@ union codeview_symbol unsigned short int len; unsigned short int id; unsigned int count; - cv_typ_t funcs[0]; /* array of cuntions, count entries */ -#if 0 - unsigned int invocations[0]; /* array of count entries, paires with funcs */ -#endif + unsigned char data[]; + /* cv_typ_t functions[count]; */ + /* unsigned int invocations[count]; */ } function_list_v3;
struct diff --git a/tools/winedump/msc.c b/tools/winedump/msc.c index 5e274b730dd..0a638d4bf9f 100644 --- a/tools/winedump/msc.c +++ b/tools/winedump/msc.c @@ -1703,9 +1703,9 @@ BOOL codeview_dump_symbols(const void* root, unsigned long start, unsigned long int vlen; struct full_value fv;
- vlen = full_numeric_leaf(&fv, &sym->constant_v2.cvalue); + vlen = full_numeric_leaf(&fv, sym->constant_v2.data); printf("Constant V2 '%s' = %s type:%x\n", - p_string(PSTRING(&sym->constant_v2.cvalue, vlen)), + p_string((const struct p_string *)&sym->constant_v2.data[vlen]), full_value_string(&fv), sym->constant_v2.type); } break; @@ -1715,9 +1715,9 @@ BOOL codeview_dump_symbols(const void* root, unsigned long start, unsigned long int vlen; struct full_value fv;
- vlen = full_numeric_leaf(&fv, &sym->constant_v3.cvalue); + vlen = full_numeric_leaf(&fv, sym->constant_v3.data); printf("Constant V3 '%s' = %s type:%x\n", - (const char*)&sym->constant_v3.cvalue + vlen, + (const char*)&sym->constant_v3.data[vlen], full_value_string(&fv), sym->constant_v3.type); } break; @@ -1893,6 +1893,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long start, unsigned long case S_INLINEES: { unsigned i, ninvoc; + const cv_typ_t *functions; const unsigned* invoc; const char* tag;
@@ -1900,12 +1901,15 @@ BOOL codeview_dump_symbols(const void* root, unsigned long start, unsigned long else if (sym->generic.id == S_CALLEES) tag = "Callees"; else tag = "Inlinees"; printf("%s V3 count:%u\n", tag, sym->function_list_v3.count); - invoc = (const unsigned*)&sym->function_list_v3.funcs[sym->function_list_v3.count]; + functions = (const cv_typ_t *)&sym->function_list_v3.data; + invoc = (const unsigned*)&functions[sym->function_list_v3.count]; ninvoc = (const unsigned*)get_last(sym) - invoc; + if (ninvoc < sym->function_list_v3.count) ninvoc = sym->function_list_v3.count;
- for (i = 0; i < sym->function_list_v3.count; ++i) + for (i = 0; i < ninvoc; ++i) printf("%*s| func:%x invoc:%u\n", - indent, "", sym->function_list_v3.funcs[i], i < ninvoc ? invoc[i] : 0); + indent, "", functions[i], invoc[i]); + if (i < sym->function_list_v3.count) printf("Number of entries exceed symbol serialized size\n"); } break;