How to get the full source location of a frame via python

Simon Sobisch via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
With the Python API we can do nearly everything necessary related to 
frames and
	st = frame.find_sal().symtab
	if st:
		filename = st.filename

provides the filename as noted in the debug info.

If we now need to get the full filename as used in GDB (with source path 
and similar applied) the only version I've found so far involves GDB 
text parsing:

	# Get the full path for the source file
	old_frame = gdb.selected_frame()
	frame.select()
	info_source = gdb.execute("info source", False, True)
	pattern = re.compile(r"Located in (.*)\n")
	match = re.search(pattern, info_source)
	if match:
		self.current_full_path = match.group(1)
	else:
		self.current_full_path = filename_frame	
	old_frame.select()

Which seems not very robust as it parses text which may have a different 
format in other GDB versions and likely a different text when localized; 
additional it needs a regex which is not that fast.

Questions:
Is there a direct way to get the full source location for a frame?
If not: any suggestions to improve the code (especially the reliability?)

Also: if there isn't a way via GDBs python API please consider this as a 
feature request, maybe as
	gdb.Frame.resolve_filename()

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.