I'm trying to read raw multitouch data from my touchpad, though I'm not getting the results I expect.
I started by identifying what my device ID was, using lsinput:
/dev/input/event0
bustype : BUS_HOST
vendor : 0x0
product : 0x5
version : 0
name : "Lid Switch"
phys : "PNP0C0D/button/input0"
bits ev : EV_SYN EV_SW
/dev/input/event1
bustype : BUS_HOST
vendor : 0x0
product : 0x1
version : 0
name : "Power Button"
phys : "PNP0C0C/button/input0"
bits ev : EV_SYN EV_KEY
/dev/input/event2
bustype : BUS_HOST
vendor : 0x0
product : 0x1
version : 0
name : "Power Button"
phys : "LNXPWRBN/button/input0"
bits ev : EV_SYN EV_KEY
/dev/input/event3
bustype : BUS_I8042
vendor : 0x1
product : 0x1
version : 43907
name : "AT Translated Set 2 keyboard"
phys : "isa0060/serio0/input0"
bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP
/dev/input/event4
bustype : BUS_HOST
vendor : 0x0
product : 0x6
version : 0
name : "Video Bus"
phys : "LNXVIDEO/video/input0"
bits ev : EV_SYN EV_KEY
/dev/input/event5
bustype : BUS_HOST
vendor : 0x0
product : 0x6
version : 0
name : "Video Bus"
phys : "LNXVIDEO/video/input0"
bits ev : EV_SYN EV_KEY
/dev/input/event6
bustype : BUS_I8042
vendor : 0x2
product : 0x7
version : 433
name : "SynPS/2 Synaptics TouchPad"
phys : "isa0060/serio1/input0"
bits ev : EV_SYN EV_KEY EV_ABS
/dev/input/event7
bustype : BUS_HOST
vendor : 0x0
product : 0x0
version : 0
name : "Ideapad extra buttons"
phys : "ideapad/input0"
bits ev : EV_SYN EV_KEY EV_MSC
/dev/input/event8
bustype : BUS_USB
vendor : 0x4f2
product : 0xb57e
version : 34624
name : "EasyCamera: EasyCamera"
phys : "usb-0000:00:14.0-6/button"
bits ev : EV_SYN EV_KEY
/dev/input/event9
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH Mic"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event10
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH Headphone"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event11
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH HDMI/DP,pcm=3"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event12
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH HDMI/DP,pcm=7"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event13
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH HDMI/DP,pcm=8"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event14
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH HDMI/DP,pcm=9"
phys : "ALSA"
bits ev : EV_SYN EV_SW
/dev/input/event15
bustype : (null)
vendor : 0x0
product : 0x0
version : 0
name : "HDA Intel PCH HDMI/DP,pcm=10"
phys : "ALSA"
bits ev : EV_SYN EV_SW
Since I could see none of the devices listed here, I decided to choose /dev/input/event6 (SynPS/2 Synaptics TouchPad) which seemed the closest to what I was looking for.
Now, I've written a dead-simple code to try and get the max number of MT points from it:
int main(void)
{
struct libevdev *dev;
int fd;
int rc;
fd = open("/dev/input/event6", O_RDONLY|O_NONBLOCK);
if (fd < 0)
fprintf(stderr, "error: %d %s\n", errno, strerror(errno));
rc = libevdev_new_from_fd(fd, &dev);
if (rc < 0)
fprintf(stderr, "error: %d %s\n", -rc, strerror(-rc));
int n = libevdev_get_num_slots(dev);
printf("%d\n", n);
return 0;
}
I can compile it using gcc -levdev myfile.c and run it properly, but I only get 2.
Does that mean that my touchpad only handles two points ? This is weird, since it can handle (at least) 4 on Windows.
Do you have any ideas about this?
Small update : using libinput-debug-events, I get the following output
When using 1 finger:
event6 POINTER_MOTION +0.79s 0.00/ -6.22
event6 POINTER_MOTION +0.80s 0.00/-11.26
event6 POINTER_MOTION +0.81s 0.00/ -9.93
event6 POINTER_MOTION +0.82s 1.69/ -9.05
When using 2 fingers:
event6 POINTER_AXIS +0.60s vert -9.27* horiz 1.19* (finger)
event6 POINTER_AXIS +0.62s vert -13.25* horiz 2.03* (finger)
event6 POINTER_AXIS +0.65s vert -15.89* horiz 2.03* (finger)
When using 3 fingers:
event6 GESTURE_PINCH_UPDATE +0.68s 4 1.42/-1.54 ( 5.49/-5.97 unaccelerated) 0.99 # 0.15
event6 GESTURE_PINCH_UPDATE +0.71s 4 0.00/-0.31 ( 0.00/-0.89 unaccelerated) 0.99 # 0.07
event6 GESTURE_PINCH_UPDATE +0.73s 4 1.03/-3.44 ( 3.20/-10.74 unaccelerated) 0.98 # 0.74
When using 4 fingers:
event6 GESTURE_SWIPE_UPDATE +0.80s 4 0.00/-0.89 ( 0.00/-6.86 unaccelerated)
event6 GESTURE_SWIPE_UPDATE +0.82s 4 0.00/-1.18 ( 0.00/-7.16 unaccelerated)
event6 GESTURE_SWIPE_UPDATE +0.84s 4 0.68/-3.48 ( 3.20/-16.40 unaccelerated)
So it does seem that there's something on my system that is capable of detecting and reading at least up to four fingers... But for some reason, I can't get them with libevdev...
Related
WiFi connected
IP address:
192.168.1.xxx
Attempting MQTT connection...connected
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d25bc: ee650213 00f01d0a 41004136
Core 1 register dump:
PC : 0x400d25c1 PS : 0x00060930 A0 : 0x00000000 A1 : 0x3ffb4010
A2 : 0x75e82caf A3 : 0x75e82caf A4 : 0x3ffc2f84 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800d24dc A9 : 0x3ffb3ff0
A10 : 0x00000001 A11 : 0x00000001 A12 : 0x00000010 A13 : 0x3ffc2f84
A14 : 0x3ffb927c A15 : 0x80000001 SAR : 0x0000000a EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x40084415 LEND : 0x4008441d LCOUNT : 0x00000026
Backtrace:0x400d25be:0x3ffb4010
ELF file SHA256: 0000000000000000
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13864
load:0x40080400,len:3608
entry 0x400805f0
Connecting to xxx
Guys, i got bugged when connecting to mqtt server. I'm using ESP32.
Here is my code for connecting.
void connectMQTT(void *pvParameters) {
vTaskDelay(6000 / portTICK_PERIOD_MS);
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
String clientId = "FreeRTOS";
clientId += String(random(0xffff), HEX);
if (client.connect(clientId.c_str())) {
Serial.println("connected");
client.subscribe("denled");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 2 seconds");
delay(2000 / portTICK_PERIOD_MS);
}
}
}
Here is my task. The default running core on my arduino ide is 1
xTaskCreatePinnedToCore(
connectMQTT
, "MQTTConnection" // Task name
, 2048 // Stack size (bytes)
, NULL
, 3 // Priority
, NULL
, ARDUINO_RUNNING_CORE);
Thanks for reading. This is the first time i post, so if there any feedback is always good for me
I'm having trouble accessing debug information for local static variables with gdb. I created a very simple example that shows the behaviour:
int global = 0;
static int g_static = 1;
int main(void)
{
static int l_static = 2;
return global + g_static + l_static;
}
I compiled with arm-none-eabi-gcc (I'm compiling for an MCU target) using -O0 and -gdwarf-2 and I can see the debug information for all 3 variables in the output of objdump -g:
<1><29>: Abbrev Number: 2 (DW_TAG_variable)
<2a> DW_AT_name : (indirect string, offset: 0x9): global
<2e> DW_AT_decl_file : 1
<2f> DW_AT_decl_line : 1
<30> DW_AT_decl_column : 5
<31> DW_AT_type : <0x3c>
<35> DW_AT_external : 1
<36> DW_AT_location : 5 byte block: 3 0 0 0 0 (DW_OP_addr: 0)
<1><3c>: Abbrev Number: 3 (DW_TAG_base_type)
<3d> DW_AT_byte_size : 4
<3e> DW_AT_encoding : 5 (signed)
<3f> DW_AT_name : int
<1><43>: Abbrev Number: 4 (DW_TAG_variable)
<44> DW_AT_name : (indirect string, offset: 0xac): g_static
<48> DW_AT_decl_file : 1
<49> DW_AT_decl_line : 2
<4a> DW_AT_decl_column : 12
<4b> DW_AT_type : <0x3c>
<4f> DW_AT_location : 5 byte block: 3 0 0 0 0 (DW_OP_addr: 0)
<1><55>: Abbrev Number: 5 (DW_TAG_subprogram)
<56> DW_AT_external : 1
<57> DW_AT_name : (indirect string, offset: 0x17): main
<5b> DW_AT_decl_file : 1
<5c> DW_AT_decl_line : 4
<5d> DW_AT_decl_column : 5
<5e> DW_AT_prototyped : 1
<5f> DW_AT_type : <0x3c>
<63> DW_AT_low_pc : 0x0
<67> DW_AT_high_pc : 0x28
<6b> DW_AT_frame_base : 0x0 (location list)
<6f> DW_AT_GNU_all_call_sites: 1
<2><70>: Abbrev Number: 4 (DW_TAG_variable)
<71> DW_AT_name : (indirect string, offset: 0x0): l_static
<75> DW_AT_decl_file : 1
<76> DW_AT_decl_line : 6
<77> DW_AT_decl_column : 14
<78> DW_AT_type : <0x3c>
<7c> DW_AT_location : 5 byte block: 3 0 0 0 0 (DW_OP_addr: 0)
In the symbol table l_static is given a suffix to make it unique and prevent ambiguity. nm output:
00000000 b $d
00000000 d $d
00000000 d $d
0000001c t $d
00000000 t $t
00000000 d g_static
00000000 B global
00000000 d l_static.0
00000001 T main
Yet when I try to access it using gdb, I can only access debug info for global and g_static but not for l_static or even 'l_static.0'. It looks like gdb knows about the existence of l_static.0but can't find the related debug info.:
(gdb) ptype global
type = int
(gdb) ptype g_static
type = int
(gdb) ptype l_static
No symbol "l_static" in current context.
(gdb) ptype 'l_static.0'
type = <data variable, no debug info>
I have tried with gdb 7.6.1 and 11.2 with the same result. As far as I understand it the information is there, as shown by the output of objdump -g. But for some reason gdb can't find it.
My gut feeling is that this might be related to the way gcc appends the .0 to the local static's symbol name. Maybe this leads to a mismatch between the symbol name and the name related to the debug info?
Hoping for anyone who can shed some light on this. Thanks in advance!
You need to stop inside the main function to see that variable:
I found out how to do it without running the binary and setting a breakpoint.
(gdb) ptype main::l_static
type = int
Apparently gdb knows in which function the local static is defined and lets you access it in this c++ namespace-style way, even if the relevant stack frame has not been selected. This is documented in section 10.3 of the gdb manual.
I am parsing dwarf files, and I want to get the value of a variable or a pointer.
For example,
#include<stdio.h>
int main(){
int *a=malloc(4*sizeof(int));
a[0]=1;
int *b=&a;
int c=a[0];
return 0;
}
I got the dwarf debug information like this:
<2><304>: Abbrev Number: 17 (DW_TAG_variable)
<305> DW_AT_name : a
<307> DW_AT_decl_file : 1
<308> DW_AT_decl_line : 4
<309> DW_AT_decl_column : 10
<30a> DW_AT_type : <0x341>
<30e> DW_AT_location : 2 byte block: 91 58 (DW_OP_fbreg: -40)
<2><311>: Abbrev Number: 18 (DW_TAG_subprogram)
<312> DW_AT_external : 1
<312> DW_AT_name : (indirect string, offset: 0x3f): malloc
<316> DW_AT_decl_file : 8
<317> DW_AT_decl_line : 0
<318> DW_AT_prototyped : 1
<318> DW_AT_type : <0x47>
<31c> DW_AT_declaration : 1
<31c> DW_AT_sibling : <0x326>
<3><320>: Abbrev Number: 19 (DW_TAG_formal_parameter)
<321> DW_AT_type : <0x39>
<3><325>: Abbrev Number: 0
<2><326>: Abbrev Number: 17 (DW_TAG_variable)
<327> DW_AT_name : b
<329> DW_AT_decl_file : 1
<32a> DW_AT_decl_line : 7
<32b> DW_AT_decl_column : 10
<32c> DW_AT_type : <0x341>
<330> DW_AT_location : 2 byte block: 91 60 (DW_OP_fbreg: -32) [without DW_AT_frame_base]
<2><333>: Abbrev Number: 17 (DW_TAG_variable)
<334> DW_AT_name : c
<336> DW_AT_decl_file : 1
<337> DW_AT_decl_line : 8
<338> DW_AT_decl_column : 9
<339> DW_AT_type : <0x65>
<33d> DW_AT_location : 2 byte block: 91 54 (DW_OP_fbreg: -44) [without DW_AT_frame_base]
I get the name,type,frame base offset of a,b and c, but could I know the value of int *b and int c ?
I begin to learn compiler.
I know that .symtab in ELF stores information about global variables and functions, but I don't find any valid information about local variables. For those local variables that are allocated on the stack, how could a debugger know their name? Are there any helpful information in ELF?
For example, here is a stupid C code:
void printLocal(){
char c1_loc='a';
int i_loc=1;
char c2_loc='b';
double d_loc=2;
char c3_loc='c';
float f_loc=3;
char c4_loc='d';
short s_loc=4;
printf("&c1_loc = %p\n",&c1_loc);
printf("&i_loc = %p\n",&i_loc);
printf("&c2_loc = %p\n",&c2_loc);
printf("&d_loc = %p\n",&d_loc);
printf("&c3_loc = %p\n",&c3_loc);
printf("&f_loc = %p\n",&f_loc);
printf("&c4_loc = %p\n",&c4_loc);
printf("&s_loc = %p\n",&s_loc);
}
And I get the .debug_info in ELF :
<1><490>: Abbrev Number: 19 (DW_TAG_subprogram)
<491> DW_AT_external : 1
<491> DW_AT_name : (indirect string, offset: 0x2b): printLocal
<495> DW_AT_decl_file : 1
<496> DW_AT_decl_line : 42
<497> DW_AT_decl_column : 6
<498> DW_AT_low_pc : 0x12ff
<4a0> DW_AT_high_pc : 0x129
<4a8> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<4aa> DW_AT_GNU_all_tail_call_sites: 1
<4aa> DW_AT_sibling : <0x527>
<2><4ae>: Abbrev Number: 20 (DW_TAG_variable)
<4af> DW_AT_name : (indirect string, offset: 0x13d): c1_loc
<4b3> DW_AT_decl_file : 1
<4b4> DW_AT_decl_line : 43
<4b5> DW_AT_decl_column : 10
<4b6> DW_AT_type : <0x91>
<4ba> DW_AT_location : 2 byte block: 91 52 (DW_OP_fbreg: -46)
<2><4bd>: Abbrev Number: 20 (DW_TAG_variable)
<4be> DW_AT_name : (indirect string, offset: 0xc): i_loc
<4c2> DW_AT_decl_file : 1
<4c3> DW_AT_decl_line : 44
<4c4> DW_AT_decl_column : 9
<4c5> DW_AT_type : <0x65>
<4c9> DW_AT_location : 2 byte block: 91 58 (DW_OP_fbreg: -40)
<2><4cc>: Abbrev Number: 20 (DW_TAG_variable)
<4cd> DW_AT_name : (indirect string, offset: 0x126): c2_loc
<4d1> DW_AT_decl_file : 1
<4d2> DW_AT_decl_line : 45
<4d3> DW_AT_decl_column : 10
<4d4> DW_AT_type : <0x91>
<4d8> DW_AT_location : 2 byte block: 91 53 (DW_OP_fbreg: -45)
<2><4db>: Abbrev Number: 20 (DW_TAG_variable)
<4dc> DW_AT_name : (indirect string, offset: 0xce): d_loc
<4e0> DW_AT_decl_file : 1
<4e1> DW_AT_decl_line : 46
<4e2> DW_AT_decl_column : 12
<4e3> DW_AT_type : <0x334>
<4e7> DW_AT_location : 2 byte block: 91 60 (DW_OP_fbreg: -32)
<2><4ea>: Abbrev Number: 20 (DW_TAG_variable)
<4eb> DW_AT_name : (indirect string, offset: 0x333): c3_loc
<4ef> DW_AT_decl_file : 1
<4f0> DW_AT_decl_line : 47
<4f1> DW_AT_decl_column : 10
<4f2> DW_AT_type : <0x91>
<4f6> DW_AT_location : 2 byte block: 91 54 (DW_OP_fbreg: -44)
<2><4f9>: Abbrev Number: 20 (DW_TAG_variable)
<4fa> DW_AT_name : (indirect string, offset: 0x32d): f_loc
<4fe> DW_AT_decl_file : 1
<4ff> DW_AT_decl_line : 48
<500> DW_AT_decl_column : 11
<501> DW_AT_type : <0x364>
<505> DW_AT_location : 2 byte block: 91 5c (DW_OP_fbreg: -36)
<2><508>: Abbrev Number: 20 (DW_TAG_variable)
<509> DW_AT_name : (indirect string, offset: 0x159): c4_loc
<50d> DW_AT_decl_file : 1
<50e> DW_AT_decl_line : 49
<50f> DW_AT_decl_column : 10
<510> DW_AT_type : <0x91>
<514> DW_AT_location : 2 byte block: 91 55 (DW_OP_fbreg: -43)
<2><517>: Abbrev Number: 20 (DW_TAG_variable)
<518> DW_AT_name : (indirect string, offset: 0x1e): s_loc
<51c> DW_AT_decl_file : 1
<51d> DW_AT_decl_line : 50
<51e> DW_AT_decl_column : 11
<51f> DW_AT_type : <0x5e>
<523> DW_AT_location : 2 byte block: 91 56 (DW_OP_fbreg: -42)
when I use GDB to debug the program, I get:
(gdb) info locals
c1_loc = 97 'a'
i_loc = 1
c2_loc = 98 'b'
d_loc = 2
c3_loc = 99 'c'
f_loc = 3
c4_loc = 100 'd'
s_loc = 4
I don't know how GDB get the name of the local variables, hope someone could help me.
Background
Found a strange kernel Oops, Googled a lot, found nothing.
Background:
The kernel version is 3.0.8
There are two process let's say p1, p2
p2 have lots of threads(about 30)
p1 continuously calls system(pidof("name of p1"))
The kernel may Oops after running for a few days. the primary reason I found is that unwind_frame got a strange frame->fp(0xFFFFFFFF) from get_wchan
When executing this line
frame->fp = *(unsigned long *)(fp - 12);
The CPU will try to access 0xFFFFFFF3, and cause a paging error.
My question is:
How on earth the fp register saved before context switch becomes 0xFFFFFFFF ?
here is the CPU infomation
# cat /proc/cpuinfo
Processor : ARMv7 Processor rev 0 (v7l)
processor : 0
BogoMIPS : 1849.75
processor : 1
BogoMIPS : 1856.30
Features : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part : 0xc09
CPU revision : 0
Here is the Oops and pt registers:
[734212.113136] Unable to handle kernel paging request at virtual address fffffff3
[734212.113154] pgd = 826f0000
[734212.113175] [fffffff3] *pgd=8cdfe821, *pte=00000000, *ppte=00000000
[734212.113199] Internal error: Oops: 17 [#1] SMP
--------------cut--------------
[734212.113464] CPU: 1 Tainted: P (3.0.8 #2)
[734212.113523] PC is at unwind_frame+0x48/0x68
[734212.113538] LR is at get_wchan+0x8c/0x298
[734212.113557] pc : [<8003d120>] lr : [<8003a660>] psr: a0000013
[734212.113561] sp : 845d1cc8 ip : 00000003 fp : 845d1cd4
[734212.113583] r10: 00000001 r9 : 00000000 r8 : 80493c34
[734212.113597] r7 : 00000000 r6 : 00000000 r5 : 83354960 r4 : 845d1cd8
[734212.113613] r3 : 845d1cd8 r2 : ffffffff r1 : 80490000 r0 : 8049003f
[734212.113632] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[734212.113651] Control: 10c53c7d Table: 826f004a DAC: 00000015
Here is the callstack:
[734212.117027] Backtrace:
[734212.117052] [<8003d0d8>] (unwind_frame+0x0/0x68) from [<8003a660>] (get_wchan+0x8c/0x298)
[734212.117079] [<8003a5d4>] (get_wchan+0x0/0x298) from [<8011f700>] (do_task_stat+0x548/0x5ec)
[734212.117099] r4:00000000
[734212.117118] [<8011f1b8>] (do_task_stat+0x0/0x5ec) from [<8011f7c0>] (proc_tgid_stat+0x1c/0x24)
[734212.117158] [<8011f7a4>] (proc_tgid_stat+0x0/0x24) from [<8011b7f0>] (proc_single_show+0x54/0x98)
[734212.117196] [<8011b79c>] (proc_single_show+0x0/0x98) from [<800e9024>] (seq_read+0x1b4/0x4e4)
[734212.117215] r8:845d1f08 r7:845d1f70 r6:00000001 r5:8ca89d20 r4:866ea540
[734212.117237] r3:00000000
[734212.117264] [<800e8e70>] (seq_read+0x0/0x4e4) from [<800c8c54>] (vfs_read+0xb4/0x19c)
[734212.117289] [<800c8ba0>] (vfs_read+0x0/0x19c) from [<800c8e18>] (sys_read+0x44/0x74)
[734212.117307] r8:00000000 r7:00000003 r6:000003ff r5:7ea00818 r4:8ca89d20
[734212.117340] [<800c8dd4>] (sys_read+0x0/0x74) from [<800393c0>] (ret_fast_syscall+0x0/0x30)
[734212.117358] r9:845d0000 r8:80039568 r6:7ea00c90 r5:0000000e r4:7ea00818
[734212.117388] Code: e3c10d7f e3c0103f e151000c 9afffff6 (e512100c)
[734212.113136] Unable to handle kernel paging request at virtual address fffffff3
[734212.113154] pgd = 826f0000
[734212.113175] [fffffff3] *pgd=8cdfe821, *pte=00000000, *ppte=00000000
[734212.113199] Internal error: Oops: 17 [#1] SMP
This bug was fixed by Konstantin Khlebnikov, details can be found in git commit log.