@@ -794,6 +794,8 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note,
794794 char * ret = NULL ;
795795 int i , args_count , err ;
796796 unsigned long long ref_ctr_offset ;
797+ char * arg ;
798+ int arg_idx = 0 ;
797799
798800 if (strbuf_init (& buf , 32 ) < 0 )
799801 return NULL ;
@@ -818,11 +820,43 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note,
818820 if (args == NULL )
819821 goto error ;
820822
821- for (i = 0 ; i < args_count ; ++ i ) {
822- if (synthesize_sdt_probe_arg (& buf , i , args [i ]) < 0 ) {
823+ for (i = 0 ; i < args_count ; ) {
824+ /*
825+ * FIXUP: Arm64 ELF section '.note.stapsdt' uses string
826+ * format "-4@[sp, NUM]" if a probe is to access data in
827+ * the stack, e.g. below is an example for the SDT
828+ * Arguments:
829+ *
830+ * Arguments: -4@[sp, 12] -4@[sp, 8] -4@[sp, 4]
831+ *
832+ * Since the string introduces an extra space character
833+ * in the middle of square brackets, the argument is
834+ * divided into two items. Fixup for this case, if an
835+ * item contains sub string "[sp,", need to concatenate
836+ * the two items.
837+ */
838+ if (strstr (args [i ], "[sp," ) && (i + 1 ) < args_count ) {
839+ err = asprintf (& arg , "%s %s" , args [i ], args [i + 1 ]);
840+ i += 2 ;
841+ } else {
842+ err = asprintf (& arg , "%s" , args [i ]);
843+ i += 1 ;
844+ }
845+
846+ /* Failed to allocate memory */
847+ if (err < 0 ) {
823848 argv_free (args );
824849 goto error ;
825850 }
851+
852+ if (synthesize_sdt_probe_arg (& buf , arg_idx , arg ) < 0 ) {
853+ free (arg );
854+ argv_free (args );
855+ goto error ;
856+ }
857+
858+ free (arg );
859+ arg_idx ++ ;
826860 }
827861
828862 argv_free (args );
0 commit comments