Is there a C example about using PTRACE_GETSIGMASK and PTRACE_SETSIGMASK?
I have not found any C example about using PTRACE_GETSIGMASK/PTRACE_SETSIGMASK, I wrote a simple code to test them, but it returns and EINVAL error.
I am trying to modify the trace signal mask
kernel sizeof(sigset_t)=8, userspace sizeof(sigset_t)=128. try addr=8
Related
boltdb/bolt is an embedded key/value database for Go.
When I read the source code of bolt, I find the following code,
p := db.pageInBuffer(buf[:], pgid(i))
from: https://github.com/boltdb/bolt/blob/master/db.go#L350
But I can not get the reason why it use buf[:] instead of buf, can anyone provide an explanation for this code style?
I am trying to take over some projects involving DEC BASIC, A.K.A. VAX BASIC, A.K.A. Alpha BASIC. I am really hoping to run into someone with experience here. I have been through the user manual for VAX/Alpha BASIC through and though but I can't figure out how to debug shareable code.
I can create, compile and link shareable code, I can debug the code that references the shareable code, but I can't debug the shareable code. Any help would be greatly appreciated.
The commands I am using to compile and link are:
$ BASIC/DEBUG/NOOPTIMIZE COMPARE_DATES_TEST.BAS,COMPARE_DATES.BAS
$ LINK/SHAREABLE/DEBUG COMPARE_DATES.OBJ,COMPARE_DATES_SUB/OPT
$ LINK/DEBUG COMPARE_DATES_TEST,COMPARE_DATES_MAIN/OPT
$ RUN COMPARE_DATES_TEST
The contents of the two option files are:
$ type COMPARE_DATES_SUB.OPT
! COMPARE_DATES_SUB.OPT
SYMBOL_VECTOR=(COMPARE_DATES=PROCEDURE)
$ type COMPARE_DATES_MAIN.OPT
! COMPARE_DATES_MAIN.OPT
COMPARE_DATES/SHAREABLE
My shareable code has a bug, but I don't know where, the debugger reports:
— SRC: module COMPARE_DATES_TEST$MAIN -scroll-source————————————————————————————
1: EXTERNAL INTEGER FUNCTION COMPARE_DATES(STRING,STRING)
2: DECLARE STRING A$, B$
3: A$ = "01-APR-18"
4: B$ = "15-MAY-2017"
5:
-> 6: PRINT COMPARE_DATES(A$, B$)
7: END
— OUT -output———————————————————————————————————————————————————————————————————
stepped to COMPARE_DATES_TEST$MAIN\COMPARE_DATES_TEST$MAIN\%LINE 3
stepped to COMPARE_DATES_TEST$MAIN\COMPARE_DATES_TEST$MAIN\%LINE 4
stepped to COMPARE_DATES_TEST$MAIN\COMPARE_DATES_TEST$MAIN\%LINE 6
%BAS-F-SUBOUTRAN, Subscript out of range
-BAS-I-FROFUN, In external function COMPARE_DATES
-BAS-I-FROMOD, In module COMPARE_DATES_TEST
break on unhandled exception preceding 18446744071563830960
— PROMPT -error-program-prompt——————————————————————————————————————————————————
%DEBUG-I-SOURCESCOPE, source lines not available for %PC in scope number 0
Displaying source for 6\%PC
DBG>
Too long for a comment: You compiled with /NOOPTIMIZE, so I would have expected that a STEP/INTO when at line 6, PRINT COMPARE_DATES(A$, B$), would have stepped to COMPARE_DATES in your shareable image. I don't know why that's not the case, here. The debugger is right, you don't have the sources for DEC$BASRTL. Your shareable image is not installed, it is in your address space. It seems PRINT has problems with the passed argument. I would try a SET IMAGE COMPARE_DATES; SET MODULE/ALL; SET BREAK COMPARE_DATES at the initial debugger prompt. That makes all debug symbols of the shareable image known and sets a breakpoint in your function. And then a GO should get you into your function. (I noticed, that you have the same names for the function, the source module and the shareable image. This shouldn't be a problem.)
I intent to use gsdll32 to display postscript in a Win32 window (not ghostview).
I need help with the parameters needed by gsdll_init_with_args.
The function immediately returns error -0x12 or -0x100.
I tried several parameter combinations in various sequences:
-sDisplayFormat=16#030804
-dDisplayHandle="1234"
-dDisplayResolution=96
-sDEVICE=display
postscriptfile.ps
As a second question:
What should the parameters be if I want to pipe in the postscript data programmatically ?
Examples would be nice.
Seppe
The supplied source code for Windows uses gs_dll_init_with_args(). If you look in /ghostpdl/psi/dwmain.c, function new_main(int argc, char *argv) then at about line 328 you can see the call happening.
You can follow this through in a debugger to see what the arguments look like (they get sanitised before arriving here). Get it to work the way you want on the command line, then break here with those arguments and you can see what your own code should be providing.
To send the data buffer-by-buffer, we don't have an example. However, you start by calling gsapi_run_string_begin(), then repeatedly calling gsapi_run_string_continue() until you exhaust the data, then call gsapi_run_string_end(). Obviously you will have to check the return code to see if an error occurred.
Finally; please check the AGPL to be sure you can conform to the license restrictions.
So I've been playing with the controllers for the PS2 game, Buzz. I've successfully used libusb to poll and read the buttons, and all is merry and bright.
The trouble is, I'd love to use the in-built lights to signal the folks who're using them (specifically to show them who has buzzed first). I know there's lights, I know that the PS2 was able to turn them on and off at will, and I know that someone has managed it with python. So I set out to implement their code with libusb in Ruby.
I've reproduced the SET_CONFIGURATION call they're making but I keep getting this error:
/home/ajfaraday/.rvm/gems/ruby-2.2.1/gems/libusb-0.5.0/lib/libusb/dev_handle.rb:539:in `submit_transfer':
error TRANSFER_STALL (LIBUSB::ERROR_PIPE)
I can't find any material online about what this error is, except that it's a USB pipe error which is being translated to TRANSFER_STALL by libusb.
I also wrote it out in python, with the specific line from the forum above, and I got something that looks like the same error:
usb.core.USBError: [Errno 32] Pipe error
So I'm at a loss to find out what I'm doing wrong. I've managed to make the opposite call (GET_CONFIGURATION) to a successful response (\x00).
Here's my reproduction script (depends on the libusb gem):
require 'libusb'
usb_context = LIBUSB::Context.new
device = usb_context.devices(
idVendor: 0x054c, idProduct: 0x0002
).first
handle = device.open
puts 'get configuration:'
x = handle.control_transfer(
:bmRequestType => "10000000".to_i(2),
:bRequest => 8,
:wValue => 0,
:wIndex => 0,
:dataIn => 1
)
puts x.inspect
puts 'set configuration:'
x = handle.control_transfer(
:bmRequestType => "00000000".to_i(2),
:bRequest => 9,
:wValue => 0,
:wIndex => 0,
:dataOut => "\x00\xFF\xFF\xFF\xFF"
)
puts x.inspect
And here's it's output:
get configuration:
"\x00"
set configuration:
/home/ajfaraday/.rvm/gems/ruby-2.2.1/gems/libusb-0.5.0/lib/libusb/dev_handle.rb:539:in `submit_transfer': error TRANSFER_STALL (LIBUSB::ERROR_PIPE)
from /home/ajfaraday/.rvm/gems/ruby-2.2.1/gems/libusb-0.5.0/lib/libusb/dev_handle.rb:515:in `control_transfer'
from sketches/raw_script.rb:22:in `<main>'
It looks like the pipe error means there's something wrong with the setup or data I'm sending out, but I can't find out anywhere what it is.
I've tried:
putting different amounts of data into the dataOut attribute, too.
detaching the kernel driver first, also re-opening the handle
expressing the dataOut attribute as an array
running it on another (linux) machine
checking the libusb source code (it's converting a USB message, nothing more)
Using different types of message as defined in http://www.usbmadesimple.co.uk/ums_4.htm
I'd be very grateful of any assistance. This really should be possible, and I know it's been done.
Libusb provides two functions named libusb_set_configuration and libusb_get_configuration. You should try to use those instead of rolling your own control transfers to do the same thing. They are documented here:
http://libusb.sourceforge.net/api-1.0/group__dev.html
You can check the source code or documentation of the Ruby libusb binding you are using to figure out how to call them from Ruby.
Also, setting a configuration is a semi-unusual thing to do to a USB device. You should make sure the drivers on your operating system do not already put the device into the correct configuration. Maybe you don't need to set the configuration.
Also, if this controller is an HID, the hidapi library might be a better fit than libusb.
I am wondering what is the equivalent of alm2fits in healpy.
Let's say I have 3 alms for T,E, and B in healpy, how do I export them so that they can be read by a fortran code trough fits2alm?
hp.fitsfunc.write_alm('alms.fits',[alm_T,alm_E,alm_B])
seems not to like a list and
hp.fitsfunc.mwrfits(filename= 'alm.fits',data=[alm_T,alm_E,alm_B],colnames=['T','E','B'],keys=None)
seems to save them in the wrong order, so that fits2alm raises a
'Inconsistent l^2+l+m+1 -> l,m mapping'
error
Thanks
A.