How to get xrefs to field in IDApython

I’m trying to fetch the results of “jump to xref globally” for a combination of a tinfo_t and an offset. (I know they depend on caching, it is part of an advance xref plugin).

I tried to find xrefs using the following code but no results returned (tid was successfully returned):

def get_udm_index(tif: tinfo_t, udm: udm_t) -> int | None:
    """Get the index of a `udm` in a `tif`"""
    index = tif.find_udm(udm, ida_typeinf.STRMEM_OFFSET)
    if index == -1:
        return None
    return index

def tid_from_udm(tif: tinfo_t, udm: udm_t) -> int | None:
    """Get the type ID of a `udm` in a `tif`"""
    index = get_udm_index(tif, udm)
    if index is None:
        return None
    return tif.get_udm_tid(index)

def member_xrefs_to(typ: tinfo_t, member: udm_t) -> list[int]:
    """Get all xrefs to the given member of a type"""
    tid = tid_from_udm(typ, member)
    if tid is None:
        return []

    return [xref.frm for xref in idautils.XrefsTo(tid, 0)]

Hello @yoavst,
I’ve asked around if this is possible, but unfortunately, it doesn’t look like it.
Here’s the answer I received:

Global xrefs are a feature of the decompiler, so using the IDA level API (XrefsTo) will not return them. Currently, global xrefs are not exposed in the decompiler API.

Hope this clears things up a bit.

hey, can you try the new option added in 9.2?