+/*
+ * Check if the symbol field passed by the user is in fact an address or an
+ * offset from a symbol. Those two instrumentation types are not supported yet.
+ * It's expected to be a common mistake because of the existing --probe option
+ * that does support these formats.
+ *
+ * Here are examples of these unsupported formats for the --userspace-probe
+ * option:
+ * elf:/path/to/binary:0x400430
+ * elf:/path/to/binary:4194364
+ * elf:/path/to/binary:my_symbol+0x323
+ * elf:/path/to/binary:my_symbol+43
+ */
+static int warn_userspace_probe_syntax(const char *symbol)
+{
+ int ret;
+
+ /* Check if the symbol field is an hex address. */
+ ret = sscanf(symbol, "0x%*x");
+ if (ret > 0) {
+ /* If there is a match, print a warning and return an error. */
+ ERR("Userspace probe on address not supported yet.");
+ ret = CMD_UNSUPPORTED;
+ goto error;
+ }
+
+ /* Check if the symbol field is an decimal address. */
+ ret = sscanf(symbol, "%*u");
+ if (ret > 0) {
+ /* If there is a match, print a warning and return an error. */
+ ERR("Userspace probe on address not supported yet.");
+ ret = CMD_UNSUPPORTED;
+ goto error;
+ }
+
+ /* Check if the symbol field is symbol+hex_offset. */
+ ret = sscanf(symbol, "%*[^+]+0x%*x");
+ if (ret > 0) {
+ /* If there is a match, print a warning and return an error. */
+ ERR("Userspace probe on symbol+offset not supported yet.");
+ ret = CMD_UNSUPPORTED;
+ goto error;
+ }
+
+ /* Check if the symbol field is symbol+decimal_offset. */
+ ret = sscanf(symbol, "%*[^+]+%*u");
+ if (ret > 0) {
+ /* If there is a match, print a warning and return an error. */
+ ERR("Userspace probe on symbol+offset not supported yet.");
+ ret = CMD_UNSUPPORTED;
+ goto error;
+ }
+
+ ret = 0;
+
+error:
+ return ret;
+}
+