PyObject *p_btp_frame_cmp(PyObject *self, PyObject *args) { PyObject *compare_to; int compare_number; if (!PyArg_ParseTuple(args, "O!i", &FrameTypeObject, &compare_to, &compare_number)) return NULL; struct btp_frame *f1 = ((FrameObject *)self)->frame; struct btp_frame *f2 = ((FrameObject *)compare_to)->frame; return Py_BuildValue("i", btp_frame_cmp(f1, f2, compare_number)); }
/* we do not care about thread numbers and btp_thread_cmp does not allow us to * compare them */ static int thread_cmp_dont_compare_number(struct btp_thread *t1, struct btp_thread *t2) { struct btp_frame *f1 = t1->frames, *f2 = t2->frames; do { if (f1 && !f2) return 1; else if (f2 && !f1) return -1; else if (f1 && f2) { int frames = btp_frame_cmp(f1, f2, true); if (frames != 0) return frames; f1 = f1->next; f2 = f2->next; } } while (f1 || f2); return 0; }
int btp_thread_cmp(struct btp_thread *t1, struct btp_thread *t2) { int number = t1->number - t2->number; if (number != 0) return number; struct btp_frame *f1 = t1->frames, *f2 = t2->frames; do { if (f1 && !f2) return 1; else if (f2 && !f1) return -1; else if (f1 && f2) { int frames = btp_frame_cmp(f1, f2, true); if (frames != 0) return frames; f1 = f1->next; f2 = f2->next; } } while (f1 || f2); return 0; }