Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart token debug gdb on pcscd #62

Closed
vipint99 opened this issue May 18, 2019 · 2 comments
Closed

Smart token debug gdb on pcscd #62

vipint99 opened this issue May 18, 2019 · 2 comments

Comments

@vipint99
Copy link

Hi Ludovic,
I am trying to make a iKey1000 (safenet->now Gemalto) usb token to respond to API. I have its own IFD library loaded ( as module) and all looks fine on PCSCD foreground debug messages.
When I try to open this device it fails (create context is ok) , It is using pcsc-lite library but not supporting standard CCID.
Now I want to debug this once it is detected by udev_hotplug. how to set gdb to put breakpoints to check what this driver is doing ( even in assembly code). Please help me setup debug with pcscd since it is not crashing and backtrace is not available.
I am using PCSC ver 1.8.8 source and then compiled on Centos7 32bit , since device drivers are of 32 bit version.
Please help !!

$ tree /usr/local/lib/pcsc/drivers/rnboifd.bundle/
/usr/local/lib/pcsc/drivers/rnboifd.bundle/
|-- Contents
| |-- Info.plist
| |-- Linux
| | |-- librnboifd.so -> /usr/local/lib/pcsc/drivers/rnboifd.bundle/Contents/Linux/librnboifd.so.1.1.0.8
| | -- librnboifd.so.1.1.0.8 | |-- PkgInfo | -- Resources
| -- English.lproj | -- InfoPlist.strings
|-- license.txt
`-- Readme.txt

$ /usr/local/sbin/pcscd --version
pcsc-lite version 1.8.8.
Copyright (C) 1999-2002 by David Corcoran [email protected].
Copyright (C) 2001-2011 by Ludovic Rousseau [email protected].
Copyright (C) 2003-2004 by Damien Sauveron [email protected].
Report bugs to [email protected].
Enabled features: Linux i686-pc-linux-gnu serial usb libudev usbdropdir=/usr/local/lib/pcsc/drivers debugatr ipcdir=/var/run/pcscd configdir=/usr/local/etc/reader.conf.d

$ sudo gdb /usr/local/sbin/pcscd
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http:https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
http:https://www.gnu.org/software/gdb/bugs/...
Reading symbols from /usr/local/sbin/pcscd...done.
(gdb) set args --foreground --debug --apdu
(gdb) run
Starting program: /usr/local/sbin/pcscd --foreground --debug --apdu
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
00000000 debuglog.c:269:DebugLogSetLevel() debug level=debug
00000043 debuglog.c:298:DebugLogSetCategory() Debug options: APDU
00001247 configfile.l:298:DBGetReaderList() Parsing conf file: /usr/local/etc/reader.conf.d
00000021 pcscdaemon.c:525:main() pcsc-lite 1.8.8 daemon ready.
00001820 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000152 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000159 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x04B9, PID: 0x1000, path: /dev/bus/usb/001/069
00000032 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x04B9, PID: 0x1000, path: /dev/bus/usb/001/069
00000006 hotplug_libudev.c:312:HPAddDevice() Adding USB device: rainbow
00000045 readerfactory.c:978:RFInitializeReader() Attempting startup of rainbow 00 00 using /usr/local/lib/pcsc/drivers/rnboifd.bundle/Contents/Linux/librnboifd.so
00011185 dyn_unix.c:81:DYN_GetAddress() IFDHCreateChannelByName: /usr/local/lib/pcsc/drivers/rnboifd.bundle/Contents/Linux/librnboifd.so: undefined symbol: IFDHCreateChannelByName
00000022 readerfactory.c:836:RFBindFunctions() Loading IFD Handler 2.0
00000034 readerfactory.c:327:RFAddReader() Using the pcscd polling thread
[New Thread 0xb7c56b40 (LWP 19136)]
[New Thread 0xb7455b40 (LWP 19137)]
[New Thread 0xb6c54b40 (LWP 19138)]
00034770 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010946 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010320 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010355 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011876 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010591 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010747 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011402 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011313 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011361 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011376 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010237 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011334 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011720 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011364 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010923 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011601 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011269 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011366 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011424 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010950 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011468 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010398 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011390 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011203 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011415 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011405 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011382 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011423 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010987 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011446 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010500 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011465 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010954 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011367 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011369 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011409 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011318 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010858 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011380 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010603 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011397 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00019677 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00028661 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00021706 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00015154 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00017322 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00021865 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00015737 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00016566 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00021686 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00015503 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00016964 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00021771 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00015666 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00016730 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00021688 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010880 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011103 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011279 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011330 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00014669 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011375 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011255 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011359 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010679 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010338 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011335 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011339 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011472 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011214 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011364 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011384 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011273 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010217 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011024 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011310 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011455 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011418 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011376 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011429 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011370 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00011044 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010711 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00010326 readerfactory.c:1309:RFWaitForReaderInit() Waiting init for reader: rainbow 00 00
00001145 eventhandler.c:256:EHStatusHandlerThread() powerState: POWER_STATE_POWERED
00000038 Card ATR: 3B 0F 52 4E 42 4F 24 56 23 2E 00 00 00 12 00 58 76
00452681 eventhandler.c:446:EHStatusHandlerThread() powerState: POWER_STATE_UNPOWERED


$ sudo LIBCCID_ifdLogLevel=0x000F pcscd --foreground --debug --apdu --color | tee log.txt
00000000 debuglog.c:269:DebugLogSetLevel() debug level=debug
00000039 debuglog.c:298:DebugLogSetCategory() Debug options: APDU
00000008 pcscdaemon.c:238:main() Force colored logs
00000781 configfile.l:245:DBGetReaderListDir() Parsing conf directory: /etc/reader.conf.d
00000012 configfile.l:257:DBGetReaderListDir() Skipping non regular file: .
00000004 configfile.l:257:DBGetReaderListDir() Skipping non regular file: ..
00000007 pcscdaemon.c:525:main() pcsc-lite 1.8.8 daemon ready.
00023419 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000142 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000141 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x04B9, PID: 0x1000, path: /dev/bus/usb/001/069
00000030 hotplug_libudev.c:260:get_driver() Looking for a driver for VID: 0x04B9, PID: 0x1000, path: /dev/bus/usb/001/069
00000004 hotplug_libudev.c:312:HPAddDevice() Adding USB device: vipinxxrx
00000040 readerfactory.c:978:RFInitializeReader() Attempting startup of vipinxxrx 00 00 using /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so
00041270 readerfactory.c:868:RFBindFunctions() Loading IFD Handler 3.0
00000084 ifdhandler.c:1842:init_driver() Driver version: 1.4.10
00000842 ifdhandler.c:1859:init_driver() LogLevel: 0x0003
00000010 ifdhandler.c:1870:init_driver() DriverOptions: 0x0000
00000217 ifdhandler.c:1883:init_driver() LogLevel from LIBCCID_ifdLogLevel: 0x000F
00000010 ifdhandler.c:83:CreateChannelByNameOrChannel() Lun: 0, device: usb:04b9/1000:libudev:0:/dev/bus/usb/001/069
00000010 ccid_usb.c:210:OpenUSBByName() Reader index: 0, Device: usb:04b9/1000:libudev:0:/dev/bus/usb/001/069
00000022 ccid_usb.c:242:OpenUSBByName() interface_number: 0
00000005 ccid_usb.c:258:OpenUSBByName() Using: /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
00000658 ccid_usb.c:276:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau ([email protected])
00000010 ccid_usb.c:277:OpenUSBByName() ifdProductString: Generic CCID driver
00000006 ccid_usb.c:278:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
00003563 ccid_usb.c:405:OpenUSBByName() Checking device: 1/69
00000009 ccid_usb.c:460:OpenUSBByName() Trying to open USB bus/device: 1/69
00000082 ccid_usb.c:855:get_ccid_device_descriptor() Extra field has a wrong length: 2
00000015 ccid_usb.c:518:OpenUSBByName() Unable to find the device descriptor for 1/69
00000241 ccid_usb.c:179:close_libusb_if_needed() libusb_exit
00000502 ifdhandler.c:117:CreateChannelByNameOrChannel() failed
00000012 readerfactory.c:1009:RFInitializeReader() Open Port 0x200000 Failed (usb:04b9/1000:libudev:0:/dev/bus/usb/001/069)
00000005 readerfactory.c:312:RFAddReader() vipinxxrx init failed.
00000007 readerfactory.c:529:RFRemoveReader() UnrefReader() count was: 1
00000006 readerfactory.c:1029:RFUnInitializeReader() Attempting shutdown of vipinxxrx 00 00.
00000005 readerfactory.c:905:RFUnloadReader() Unloading reader driver.
00000056 hotplug_libudev.c:384:HPAddDevice() Failed adding USB device: vipinxxrx

@LudovicRousseau
Copy link
Owner

This is not a PCSC issue.
You can find lots of gdb documentation on the Internet.

@vipint99
Copy link
Author

vipint99 commented May 19, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants