Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Smali values to logcat

In the example code below, how can I add a command to print the values of v0, v1 etc to logcat?

const v1, 0x7f05002e

iget-object v2, p0, Lcom/company/myapp/MainActivity;->d:Lcom/company/myapp/f;

invoke-virtual {v2}, Lcom/company/myapp/f;->getPanelModel()Lcom/company/myapp/h;

move-result-object v2

invoke-virtual {v2}, Lcom/company/myapp/h;->b()I

move-result v2

invoke-virtual {v0, v1, v2}, Lcom/company/e/k;->a(II)V

iget-object v0, p0, Lcom/company/myapp/MainActivity;->c:Lcom/company/e/k;
like image 458
Raz Razman Avatar asked Jun 20 '16 00:06

Raz Razman


1 Answers

Add at the end:

const-string v8, "log-tag"

invoke-static {v1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v9

invoke-static {v8, v9}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

From your sample v1 is integer so the function String;->valueOf(I) is used to convert it to String before using log. Also Log;->d outputs at debug log level; possibly another level is needed.

like image 168
Ilia Barahovsky Avatar answered Oct 17 '22 03:10

Ilia Barahovsky