I'm not entirely clear on the context where you are trying to do this. Is it for the process in question to examine itself?
With e.g. eu-addr2line you can use -p or -M (see --help). What those are doing is driving libdwfl in a fairly straightforward way that you can also do yourself.
Thanks, Roland