private Variable createStackVariable(final String name, final int offset, DataType dt,
			MessageLog log) {
		StackFrame stackFrame = function.getStackFrame();
		Variable variable = stackFrame.getVariableContaining(offset);
		try {
			if (variable == null || variable.getStackOffset() != offset) {
				if (variable != null) {
					stackFrame.clearVariable(variable.getStackOffset());
				}
				try {
					variable = stackFrame.createVariable(name, offset, dt, SourceType.IMPORTED);
				}
				catch (DuplicateNameException e) {
					variable = stackFrame.createVariable(name + "@" + Integer.toHexString(offset),
						offset, dt, SourceType.IMPORTED);
				}
			}
			else {
				variable.setDataType(dt, false, true, SourceType.ANALYSIS);
				try {
					variable.setName(name, SourceType.IMPORTED);
				}
				catch (DuplicateNameException e) {
					variable.setName(name + "@" + Integer.toHexString(offset), SourceType.IMPORTED);
				}
			}
		}
		catch (Exception e) {
			log.appendMsg("PDB", "Unable to create stack variable " + name + " at offset " +
				offset + " in " + function.getName());
		}
		return variable;
	}
Get the stack offset after it settles down.

@param monitor
@return stack offset that stack variables will be relative to.
@throws CancelledException
Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb/ApplyStackVariables.java