help with debugging a ctypes problem
I'm no c programmer, and I'm a ctypes newbie. I'll frame my problem as simply as I can. Sorry if it's too much or not enough info. I don't expect an explicit answer (but maybe), just help figuring out how to debug. WinXP, python 2.4.2 I'm using ctypes to access functions in a commercial dll. A certain function takes five arguments, foo(a, b, c, d, e). The last argument, e, is an integer that serves as a bit coded options flag. Zero means no option, 1+2+4 means the first three options combined, etc. I can call foo() successfully if e=c_int(0). However, if e=3, the function does not work. Execution of the python program continues after the call, no errors are raised, but foo() has not done its thing. If I now call bar(x, y, z) after foo(), two things happen. 1. The dll raises an error reporting that argument x is invalid 2. Python reports that too many bytes (4) have been passed to bar() I've checked the types of all the variables a million times, and they are correct according to the docs. The vendor sent me a c program that they claim works. It looks like a translation of mine. I can't run theirs, because I can't figure out how to compile it (I'm don't do c; I do have MinGW; the code was designed for MSVC; I'm lost). I'm suspecting that foo() screws up a stack somewhere. That might explain why bar() chokes on the *first* parameter, while it thinks that the number of arguments is wrong when it gets to the *last*. How can I debug this? Can I view the appropriate stack? What/where would I find it? Any other ideas or advice? etc? thanks, -gary -- http://mail.python.org/mailman/listinfo/python-list
Re: help with debugging a ctypes problem
[EMAIL PROTECTED] wrote: >> help figuring out how to debug ... ctypes ... >> a commercial dll. A certain function takes five arguments, foo(a, b, c, d, >> e). >> Can I view the appropriate stack? ... Any other ideas or advice? etc? > > Did you call the foo of _cdecl ctypes.cdll or the foo of _stdcall = > ctypes.windll? > > What is the sizeof each argument type? Preferably fetched by compiling > some C to printf them? > > Would it help to call C in another Dll to return the stack pointer, so > Python could print the stack? > Uh... windll, I think. I'm really green here. But there is news: If simply leave off the last argument of foo() and bar(), each works as expected. That is, I call foo() with four instead of the five that the docs and the c example call for, and I call bar() with one argument instead of the two that are called for. Everything works, but you gotta wonder. Meanwhile, I upgraded from ctypes 0.9.6 to 1.0.0, but I don't think that that changed anything. I'll see if I can implement your suggestions, and if I manage it, I'll report back. thanks, -g -- http://mail.python.org/mailman/listinfo/python-list
Jobs vacancies and openings in Asia. Create a more stable financial future by teaching English in Asia. Explore the options of starting a successful new career and lifestyle in Asia.
2008-11-03
Thread
Jobs, Work, Teaching English, TEFL, TESOL, Gap Year, Travel, Thailand, Cambodia, Vietnam Languagecorps
Jobs vacancies and openings in Asia. Create a more stable financial future by teaching English in Asia. Explore the options of starting a successful new career and lifestyle in Asia. Teach and travel in Asia. TEFL / TESOL training can give you the international skills you need to teach and travel around Asia as well as the world. Teach the English language within cultures and help improve global communication. TEFL / TESOL training programs, teaching English jobs, work placements, volunteer programs, learn a new language abroad and Travel around Asia. Jobs teaching English as a second language in Asia, (ELS) jobs. Work live and travel in Cambodia, China, Thailand or Vietnam. TEACHING ENGLISH JOBS Jobs vacancies and openings in Asia. Create a more stable financial future by teaching English in Asia. Explore the options of starting a successful new career and lifestyle in Asia. - http://www.cambodialanguagecorps.com CAMBODIA TEACHING JOBS - Pre University The University anticipates the need for approximately 10 new English language teachers for the start of each semester. Preferred applicants will have a Bachelors Degree and a TEFL / TESOL certificate for a minimum of 120 hours program that included at least 6 hours of observed teaching practice. CAMBODIA TEACHING ENGLISH JOBS - Pre University Teaching Institution: Pre University ESL Admissions programs Students Age: 17 - 25 years old Teaching Class Size: 25 - 30 students Teacher's Salary: $10 USD per hour up to 30 hours per week (Mon-Fri) Classrooms Conditions: Air Con Classrooms Teaching Facilities: Good Facilities Other Teaching Info: Well motivated students and cooperative administrative http://www.cambodialanguagecorps.com Jobs vacancies and openings in Asia. Create a more stable financial future by teaching English in Asia. Explore the options of starting a successful new career and lifestyle in Asia. - http://www.thailandlanguagecorps.com THAILAND TEACHING JOBS - Public, Private, Special Language Schools THAILAND TEACHING ENGLISH - Public, Private, Special Language Schools Teaching Institution: Teachers needed across the board from public schools to private schools to special language schools and corporate. Students Age: All Ages Teaching Class Size: Generally reasonable class sizes from reputable programs Teacher's Salary: 25000 Baht to 50,000 Baht and higher per month, depending on various factors Classrooms Conditions: Variable Teaching Facilities: Good Facilities Other Teaching Info: Well motivated students and cooperative administrative staff. More evening and weekend classes, less likely to have air con. http://www.thailandlanguagecorps.com Jobs vacancies and openings in Asia. Create a more stable financial future by teaching English in Asia. Explore the options of starting a successful new career and lifestyle in Asia. - http://www.vietnamlanguagecorps.com VIETNAM TEACHING JOBS - Language Schools VIETNAM TEACHING ENGLISH - Language Schools Teaching Institution: Primarily language schools, some of them extremely large. Students Age: All Ages Teaching Class Size: Reasonable to Large Teacher's Salary: Salaries run $12 to $18 per hour Classrooms Conditions: Air Con Classrooms Teaching Facilities: Generally have nice equipment Other Teaching Info: Salaries run $12 to $18 per hour http://www.vietnamlanguagecorps.com http://www.cambodialanguagecorps.com http://www.thailandlanguagecorps.com http://www.vietnamlanguagecorps.com Cambodia TEFL TESOL job work teaching English TESOL TEFL Cambodia Thailand TEFL TESOL job work teaching English TESOL TEFL Thailand Vietnam TEFL TESOL job work teaching English TESOL TEFL Vietnam TEFL Cambodia TEFL Thailand TEFL Vietnam TEFL Travel Cambodia Travel Thailand Travel Vietnam Jobs Teaching English & TEFL Courses in Thailand, Cambodia, China, Vietnam TEFL Thailand, TEFL Cambodia, TEFL Vietnam & Jobs Teaching English in Asia TEFL Cambodia, TEFL Vietnam TEFL Thailand & Jobs Teaching English in Asia Gap Year Students looking to Work and Travel around Cambodia, China, Vietnam, Thailand or Asia Graduate Jobs, Student Jobs, Graduate Recruitment Jobs, work & jobs abroad, work & jobs overseas, work & jobs Asia TEFL Cambodia TESOL Cambodia Gap Year Cambodia Student Travel Cambodia Expat Cambodia Teaching English Cambodia Travel Cambodia Holiday Cambodia Jobs Cambodia Work Cambodia TEFL Thailand TESOL Thailand Gap Year Thailand Student Travel Thailand Expat Thailand Teaching English Thailand Travel Thailand Holiday Thailand Jobs Thailand Work Thailand TEFL Vietnam TESOL Vietnam Gap Year Vietnam Student Travel Vietnam Expat Vietnam Teaching English Vietnam Travel Vietnam Holiday Vietnam Jobs Vietnam Work Vietnam TEFL Courses TEFL Programs TEFL Training TEFL Education TEFL Teaching TESOL Courses TESOL Programs TESOL Training TESOL Education TESOL Teaching ESL Teaching Lesson Plans Lesson Ideas Jobs Cambodia Thailand Vietnam China Asia Lifestyle - new car
