Skip to content

FEATURE REUQEST: Add support for swift logging macro #16

@doronz88

Description

@doronz88

I tried adding support for the swift logging version of os_log_impl variant, but had troubles doing so. From what I understand the major change is because the log buffer is allocated dynamically instead of on-stack. He is an example as shown in the decompiler code:

 v20 = (NSObject *)Logger.logObject.getter(v19);
  v21 = (unsigned __int8)static os_log_type_t.error.getter();
  if ( os_log_type_enabled(v20, v21) )
  {
    v22 = swift_slowAlloc(12, -1);
    *(_DWORD *)v22 = 134217984;
    *(_QWORD *)(v22 + 4) = 300;
    _os_log_impl(
      (void *)&_mh_execute_header,
      v20,
      v21,
      "Timed out waiting for stackshot to complete after %ld seconds",
      (uint8_t *)v22,
      0xCu);
    swift_slowDealloc(v22, -1, -1);
  }

As well as a microcode:

33.BLT_1WAY                             ; Predecessors: 32
; 1WAY-BLOCK 33 INBOUNDS: 32 OUTBOUNDS: 34 [START=10002E208 END=10002E22C] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x0.8,x19.8,x22.8,x29.8,cs.2,(x3.8,x4.8,x5.8,x6.8,x7.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x0.8,x1.8,x2.8,x8.8,x9.8,x17.8,x24.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x3.8,x4.8,x5.8,x6.8,x7.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
; DNU: x9.8,x17.8,x24.8
33. 1           mov    x0.8, x1.8 ; 10002E208 u=x0.8       d=x1.8
33. 2           ldx    cs.2, (x29.8-#0x58.8), x24.8 ; 10002E20C u=x29.8,cs.2,(ALLMEM) d=x24.8
33. 3           ldx    cs.2, (x29.8-#0x58.8), x8.8 ; 10002E210 u=x29.8,cs.2,(ALLMEM) d=x8.8
33. 4           ldx    cs.2, (x8.8+#0x10.8), t1.8 ; 10002E214 u=x8.8,cs.2,(ALLMEM) d=t1.8
33. 5           add    x8.8, #0x10.8, x8.8 ; 10002E214 u=x8.8       d=x8.8
33. 6           mov    t1.8, x9.8 ; 10002E214 u=t1.8       d=x9.8
33. 7           mov    x22.8, x0.8 ; 10002E218 u=x22.8      d=x0.8
33. 8           mov    x19.8, x2.8 ; 10002E21C u=x19.8      d=x2.8
33. 9           or     (x8.8 & #0xFFFFFFFFFFFF.8), #-0x1C46000000000000.8, x17.8 ; 10002E224 u=x8.6       d=x17.8
33.10           icall  cs.2, t1.8 ; 10002E228 u=t1.8,cs.2,(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 34

34.BLT_1WAY                             ; Predecessors: 33
; 1WAY-BLOCK 34 INBOUNDS: 33 OUTBOUNDS: 35 [START=10002E22C END=10002E234] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x22.8,(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x20.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
; DNU: x20.8
34. 1           mov    x22.8, x20.8 ; 10002E22C u=x22.8      d=x20.8
34. 2           call   $"_$s2os6LoggerV9logObjectSo03OS_a1_C0Cvg" ; 10002E230 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 35

35.BLT_1WAY                             ; Predecessors: 34
; 1WAY-BLOCK 35 INBOUNDS: 34 OUTBOUNDS: 36 [START=10002E234 END=10002E23C] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x0.8,(x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x20.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
; DNU: x20.8
35. 1           mov    x0.8, x20.8 ; 10002E234 u=x0.8       d=x20.8
35. 2           call   $"_$sSo13os_log_type_ta0A0E5errorABvgZ" ; 10002E238 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 36

36.BLT_1WAY                             ; Predecessors: 35
; 1WAY-BLOCK 36 INBOUNDS: 35 OUTBOUNDS: 37 [START=10002E23C END=10002E24C] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x0.8,x20.8,(x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x0.8,x1.8,x21.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
; DNU: x21.8
36. 1           mov    x0.8, x21.8 ; 10002E23C u=x0.8       d=x21.8
36. 2           xdu    (w0.4 & #0xFF.4), x1.8 ; 10002E240 u=w0.1       d=x1.8
36. 3           mov    x20.8, x0.8 ; 10002E244 u=x20.8      d=x0.8
36. 4           call   $_os_log_type_enabled ; 10002E248 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 37

37.BLT_2WAY                             ; Predecessors: 36
; 2WAY-BLOCK 37 INBOUNDS: 36 OUTBOUNDS: 38 41 [START=10002E24C END=10002E250] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: w0.4
37. 1           jz     w0.4, #0.4, @41 ; 10002E24C u=w0.4       ; Successors: 38, 41

38.BLT_1WAY                             ; Predecessors: 37
; 1WAY-BLOCK 38 INBOUNDS: 37 OUTBOUNDS: 39 [START=10002E250 END=10002E25C] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: (x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x0.8,x1.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
38. 1           mov    #0xC.8, x0.8 ; 10002E250 u=           d=x0.8
38. 2           mov    #-1.8, x1.8 ; 10002E254 u=           d=x1.8
38. 3           call   $_swift_slowAlloc ; 10002E258 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 39

39.BLT_1WAY                             ; Predecessors: 38
; 1WAY-BLOCK 39 INBOUNDS: 38 OUTBOUNDS: 40 [START=10002E25C END=10002E298] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x0.8,x20.8,w21.1,cs.2,(x6.8,x7.8,v0.q[0]^8.16,v1.q[0]^8.16,v2.q[0]^8.16,v3.q[0]^8.16,v4.q[0]^8.16,v5.q[0]^8.16,v6.q[0]^8.16,v7.d[1].8,ALLMEM)
; DEF: x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x8.8,x23.8,d0.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x6.8,x7.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,v0.q[0]^8.16,v1.q[0]^8.16,v2.q[0]^8.16,v3.q[0]^8.16,v4.q[0]^8.16,v5.q[0]^8.16,v6.q[0]^8.16,v7.d[1].8,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
39. 1           mov    x0.8, x23.8 ; 10002E25C u=x0.8       d=x23.8
39. 2           mov    #0x8000100.8, d0.8 ; 10002E264 u=           d=d0.8
39. 3           stx    #0x8000100.4, cs.2, x0.8 ; 10002E268 u=x0.8,cs.2  d=(ALLMEM)
39. 4           mov    #0x12C.8, x8.8 ; 10002E26C u=           d=x8.8
39. 5           stx    #0x12C.8, cs.2, (x0.8+#4.8) ; 10002E270 u=x0.8,cs.2  d=(ALLMEM)
39. 6           mov    &($__mh_execute_header).8, x0.8 ; 10002E274 u=           d=x0.8
39. 7           mov    &($aTimedOutWaitin).8, x3.8 ; 10002E27C u=           d=x3.8
39. 8           xdu    (w21.4 & #0xFF.4), x2.8 ; 10002E284 u=w21.1      d=x2.8
39. 9           mov    x20.8, x1.8 ; 10002E288 u=x20.8      d=x1.8
39.10           mov    x23.8, x4.8 ; 10002E28C u=x23.8      d=x4.8
39.11           mov    #0xC.8, x5.8 ; 10002E290 u=           d=x5.8
39.12           call   $__os_log_impl ; 10002E294 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 40

40.BLT_1WAY                             ; Predecessors: 39
; 1WAY-BLOCK 40 INBOUNDS: 39 OUTBOUNDS: 41 [START=10002E298 END=10002E2A8] MINREFS: STK=0/ARG=70, MAXBSP: 0
; USE: x23.8,(x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM)
; DEF: x0.8,x1.8,x2.8,(cf.1,zf.1,nf.1,vf.1,pf.1,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM)
40. 1           mov    x23.8, x0.8 ; 10002E298 u=x23.8      d=x0.8
40. 2           mov    #-1.8, x1.8 ; 10002E29C u=           d=x1.8
40. 3           mov    #-1.8, x2.8 ; 10002E2A0 u=           d=x2.8
40. 4           call   $_swift_slowDealloc ; 10002E2A4 u=(x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,ALLMEM) d=(cf.1,zf.1,nf.1,vf.1,pf.1,x0.8,x1.8,x2.8,x3.8,x4.8,x5.8,x6.8,x7.8,x8.8,x9.8,x10.8,x11.8,x12.8,x13.8,x14.8,x15.8,x16.8,x17.8,x30.8,q0.16,q1.16,q2.16,q3.16,q4.16,q5.16,q6.16,q7.16,q16.16,q17.16,q18.16,q19.16,q20.16,q21.16,q22.16,q23.16,q24.16,q25.16,q26.16,q27.16,q28.16,q29.16,q30.16,q31.16,ALLMEM) ; Successors: 41

41.BLT_1WAY                             ; Predecessors: 37, 40

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions