Use the native get_query_template() function

http://codex.wordpress.org/Function_Reference/get_query_template