It looks like mondrian.rolap.agg.AggregationManager has some code related to it but its not straight forward.
parseTree = this.olap4jConnection.getMondrianConnection().parseStatement(mdx);
DrillThrough plan1 = (DrillThrough)parseTree;
Query query = plan1.getQuery();
query.setResultStyle(ResultStyle.LIST);
this.setQuery(query);
CellSet cellSet = this.executeOlapQueryInternal(
query,
(MondrianOlap4jCellSetMetaData) null
);
List coords = Collections.nCopies(cellSet.getAxes().size(), Integer.valueOf(0));
MondrianOlap4jCell cell = (MondrianOlap4jCell) cellSet.getCell(coords);
ResultSet resultSet = cell.drillThroughInternal(
plan1.getMaxRowCount(),
plan1.getFirstRowOrdinal(),
plan1.getReturnList(),
true,
(Logger)null,
rowCountSlot
);
If you follow the last line,
cell.drillThroughInternal(...)
you will end up here
String sql = this.getDrillThroughSQL(fields, extendedContext);
But I am not so sure if mondrian generates only one SQL for an mdx. I think through XMLA (which most tools use as interface), you can request a drill through on a single axis, in which the complete query is not rewritten.
Hope this answers.