dlav-sc wrote:

I connect to a riscv (rv64gv) machine, nothing special. 

Lldb can just allocate memory on remote target only if the target supports 
executing JIT-compiled code (`if (process_is_alive && process_sp->CanJIT())` on 
the line `68`), otherwise lldb falls through and starts finding suitable memory 
region for a mapping.

The problem is that riscv targets currently don't support JIT-compiled code 
execution, but can only execute simple lldb expressions interpreting its IR, 
like for example 
```
expr <variable>
``` 
or 
```
expr *(type_z*)pz
``` 
If in the case above `pz == nullptr` and lldb have mapped zero address, then 
instead of the error we will get a valid result:
```
output: (type_z) $0 = {
  y = (dummy = 0)
}
```
I take this example from `TestAnonymous.py`. 

Logs you have asked for:

Without patch:
```
lldb             <  23> send packet: $qMemoryRegionInfo:0#44                    
                                                                                
                                                                                
                                   
lldb             <  28> read packet: $start:0;size:2aaaaaa000;#0b               
                                                                                
                                                                                
                                   
lldb             IRMemoryMap::Malloc (23, 0x8, 0x3, eAllocationPolicyHostOnly) 
-> 0x0                                                                          
                                                                                
                                    
lldb             <  26> send packet: $qMemoryRegionInfo:1000#d5                 
                                                                                
                                                                                
                                   
lldb             <  31> read packet: $start:1000;size:2aaaaa9000;#74            
                                                                                
                                                                                
                                   
lldb             IRMemoryMap::Malloc (524295, 0x8, 0x3, 
eAllocationPolicyHostOnly) -> 0x1000
```
With patch:
```
lldb             <  23> send packet: $qMemoryRegionInfo:0#44                    
                                                                                
                                                                                
                                   
lldb             <  28> read packet: $start:0;size:2aaaaaa000;#0b               
                                                                                
                                                                                
                                   
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaaaa000#1c           
                                                                                
                                                                                
                                   
lldb             <  81> read packet: 
$start:2aaaaaa000;size:1000;permissions:rx;flags:;name:2f726f6f742f612e6f7574;#fc
                                                                                
                                                                             
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaaab000#1d           
                                                                                
                                                                                
                                   
lldb             <  80> read packet: 
$start:2aaaaab000;size:1000;permissions:r;flags:;name:2f726f6f742f612e6f7574;#85
                                                                                
                                                                              
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaaac000#1e           
                                                                                
                                                                                
                                   
lldb             <  81> read packet: 
$start:2aaaaac000;size:1000;permissions:rw;flags:;name:2f726f6f742f612e6f7574;#fd
                                                                                
                                                                             
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaaad000#1f           
                                                                                
                                                                                
                                   
lldb             <  72> read packet: 
$start:2aaaaad000;size:21000;permissions:rw;flags:;name:5b686561705d;#5a        
                                                                                
                                                                              
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaace000#22           
                                                                                
                                                                                
                                   
lldb             <  37> read packet: $start:2aaaace000;size:154d0a2000;#32      
                                                                                
                                                                                
                                   
lldb             IRMemoryMap::Malloc (23, 0x8, 0x3, eAllocationPolicyHostOnly) 
-> 0x2aaaace000                                                                 
                                                                                
                                    
lldb             <  32> send packet: $qMemoryRegionInfo:2aaaacf000#23           
                                                                                
                                                                                
                                   
lldb             <  37> read packet: $start:2aaaacf000;size:154d0a1000;#32      
                                                                                
                                                                                
                                   
lldb             IRMemoryMap::Malloc (524295, 0x8, 0x3, 
eAllocationPolicyHostOnly) -> 0x2aaaacf000
```

Actually, I have solved the problem with this patch: 
https://github.com/llvm/llvm-project/pull/99336. It adds the ability to make 
function calls inside lldb expressions, including jitted code execution support 
for riscv targets.

I thought maybe this patch may be usefull for other architectures that can't 
execute JIT code.

https://github.com/llvm/llvm-project/pull/99045
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to