Skip to content

Commit

Permalink
Fix: pass primitive pid to memory limit request
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sauce committed Nov 18, 2024
1 parent 1fcc2a1 commit 250da62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions ios/dtx_codec/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,36 @@ func (d *Channel) ReceiveMethodCall(selector string) Message {
// MethodCall is the standard DTX style remote method invocation pattern. The ObjectiveC Selector goes as a NSKeyedArchiver.archived NSString into the
// DTXMessage payload, and the arguments are separately NSKeyArchiver.archived and put into the Auxiliary DTXPrimitiveDictionary. It returns the response message and an error.
func (d *Channel) MethodCall(selector string, args ...interface{}) (Message, error) {
payload, _ := nskeyedarchiver.ArchiveBin(selector)
auxiliary := NewPrimitiveDictionary()
for _, arg := range args {
auxiliary.AddNsKeyedArchivedObject(arg)
}

return d.methodCallWithReply(selector, auxiliary)
}

// MethodCallPrimitive is a DTX style remote method invocation pattern. The ObjectiveC Selector goes as a NSKeyedArchiver.archived NSString into the
// DTXMessage payload, and the primitive arguments put into the Auxiliary DTXPrimitiveDictionary. It returns the response message and an error.
func (d *Channel) MethodCallPrimitive(selector string, args ...int) (Message, error) {
auxiliary := NewPrimitiveDictionary()
for _, arg := range args {
auxiliary.AddInt32(arg)
}

return d.methodCallWithReply(selector, auxiliary)
}

func (d *Channel) methodCallWithReply(selector string, auxiliary PrimitiveDictionary) (Message, error) {
payload, _ := nskeyedarchiver.ArchiveBin(selector)
msg, err := d.SendAndAwaitReply(true, Methodinvocation, payload, auxiliary)
if err != nil {
log.WithFields(log.Fields{"channel_id": d.channelName, "error": err, "methodselector": selector}).Info("failed starting invoking method")
return msg, err
}
if msg.HasError() {
return msg, fmt.Errorf("Failed invoking method '%s' with error: %s", selector, msg.Payload[0])
return msg, fmt.Errorf("failed invoking method '%s' with error: %s", selector, msg.Payload[0])
}

return msg, nil
}

Expand Down
2 changes: 1 addition & 1 deletion ios/instruments/processcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewProcessControl(device ios.DeviceEntry) (*ProcessControl, error) {

// DisableMemoryLimit disables the memory limit of a process.
func (p ProcessControl) DisableMemoryLimit(pid uint64) (bool, error) {
msg, err := p.processControlChannel.MethodCall("requestDisableMemoryLimitsForPid:", pid)
msg, err := p.processControlChannel.MethodCallPrimitive("requestDisableMemoryLimitsForPid:", int(pid))
if err != nil {
return false, err
}
Expand Down

0 comments on commit 250da62

Please sign in to comment.